Re: file upload question

2008-05-06 Thread Kenneth Gonsalves


On 07-May-08, at 3:51 AM, Chris wrote:

>
> Hello I have a csv importer that I have made and I want to upload the
> csv file through a form field as so:
>
> from django import newforms as forms
>
> class ImportForm(forms.Form):
> """
> Form for importing CSV files
> """
> csv_file = forms.FileField()
>
> next I do something like this:
>
> form = ImportForm()
> if request.method == 'POST':
> form = ImportForm(request.POST, request.FILES)
> if form.is_valid():
> if ‘csv_file’ in request.FILES:
> try:
> csv_file = request.FILES[‘csv_file’][‘content’]
> except:
> request.FILES[‘csv_file’][‘error’] = True
>
> I am not really sure what I need to do here to get the file and store
> it somewhere. right now it is returning the exception. Any  
> suggestions?

what exception? are you getting request.FILES at all? have you set  
the correct enctype in your template?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Large Data Sizes, foreign keys, and indexes

2008-05-06 Thread RahulDave

Hello,

I have an application which looks lke this

Star: id, etc
Band:id, etc
LightCurve: id, star fkey(Star), band fkey(Band)

Postgres is the backend..8.2.3

Every Star basically has multiple light curves (brightness vs time
plots) in different spectral bands.

Now, there are about 1/2 a billion stars i want to add. Having the
foreign keys really slows things down, even when i set transactions to
happen with the manual transactions decorator every 3000 stars or so.

The timing goes thus:
first 15623   6mins 21:31
next 21681   14 mins 21:45
next 29262   31 mins 22.16
next 36158   57 mins 23.13

which seems to indicate that as more stars get created, fkey lookups
are taking longer and longer.

Also, django generates additional indexes such as:
"maindb_lightcurve_star_id" btree (star_id), which i presume is done
to allow for extremely
quick 'backwords' queries such as starinstance.lcot_set.all()

My questions are
(a) these additional indexes..do they affect performance on the
inserts...it would seem so..
(b) i can do fkeys later by having explicit integers for the ids, then
changing the model. Identically i can do the
indexes later too. But syncdb wont pick this up, right? However, with
a changed model, will everthing just work?

Any other ideas for large scale insert efficiency?



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



manage.py runserver woes

2008-05-06 Thread Roboto

so here is the scenario.  Everything works perfectly... online =P So I
don't have an issue with that, I've been doing a majority of my
development on a fast-cgi/apache shared hosting env and everything is
a-ok.

But now that I'm starting to get people to use the site, I can't just
go in and make modifications, so I'm back now needing my test env to
work.

I like to be on the go, and I don't always have a net connection so
I'm attempting to get my test env to be completely local.

I've got my db setup, django, and my runserver all works, template all
working.  The only thing I don't have working are static media.

I know the built in django server cannot host static media, so I opted
to used my only apache server to host it.

So I've got it setup the following.
http://localhost/media  <-- works (using apache) all my media files
being properly served (I suppose this is port 80)

in my settings.py file
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/Users/robchan/Sites/media/'   <-- this is the absolute
url of where my apache is pointing

# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com;
MEDIA_URL = 'http://localhost:8000/media/'  < this is where django
should look at this url and not urlize it.

However, when I try to access media files the following errors always
come up
Django version 0.96.1, using settings 'ready.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[06/May/2008 22:23:04] "GET /media/ HTTP/1.1" 404 2290
[06/May/2008 22:23:07] "GET /media/ HTTP/1.1" 404 2290

so 404 <-- meaning that it's thinks localhost:8000/media is a url and
not a static media folder.

Any thoughts on how to fix this?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Nested relations in a ValuesQuerySet

2008-05-06 Thread Martin Diers
Given a model like this (much simplified):

class Event(models.Model):
name = models.CharField(max_length=50)

class Text(models.Model):
name = models.CharField(max_length=50)
event = models.ForeignKey(Event)
name = models.CharField(max_length=50)

class TextRange(models.Model):
text = models.ForeignKey(Text)
start = IntegerField()
end = IntegerField()



I would like to be able to produce a ValueQuerySet object, would allow  
me to iterate in a nested for, in some such way as this (which  
obviously doesn't work):

events = Event.objects.values()
for event in events:
 print 'Event Name: %s' % event.name
 for text in events.text_set:
 print 'Text Name: %s' % text.name
 for textrange in text.textrange_set:
 print'Text Range: %s - %s' % (textrange.start,  
textrange.end)



Basically, the idea is that values() would return a dictionary which  
also contains related records as a list of dictionaries which can then  
be further iterated on through to the end.

The idea is that I am trying to display a hierarchical list in a view,  
and do not want the view making repeated queries. I don't like it when  
views are querying the database.

I understand that I can pull in the related fields from the bottom up,  
due to the qs-rf merge. However, I need to iterate from the top down.  
Since I need all the related data, it makes sense to do so in a large  
query, rather than tons of small ones, and avoid hitting the database  
repeatedly in the view.

Suggestions?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Should my Fields contain None values?

2008-05-06 Thread Greg

Hello,
I already have about 100 records in my db table.  I'm currently going
to add a date field to my model.

///
mydate = models.DateField(blank=True, null=True)
///

I have a save method for my class where i check to see if my 'mydate'
field has a value.

///
if self.mydate == None:
assert False, "Here"
///

My question is it good to have None as the value of my empty 'mydate'
field?  If empty shouldn't the field contain "" instead of None?

Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Traversing a backward relationship

2008-05-06 Thread Dmitriy Kurilov

Hi.

# models

class City(models.Model):
# Fields...

class Job(models.Model):
city = models.ForeignKey(City, related_name="jobs")
# Other fields


# views
City.objects.filter(jobs__pk__gt=0)


Is it?

-Original Message-
From: Michael J <[EMAIL PROTECTED]>
To: Django users 
Date: Tue, 6 May 2008 16:29:20 -0700 (PDT)
Subject: Traversing a backward relationship

> 
> 
> I hope this isn't a stupid question, so forgive me in advance.
> 
> I have a Job model and a City model. Job and City are linked via a
> ForeignKey in Job. On the website, users will select a city, from a
> list of cities, and then see the corresponding jobs.
> 
> Question is: how do I use the database API to only show cities that
> have jobs?
> > 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to make a or statement?

2008-05-06 Thread Marcelo Barbero

2008/5/6 Greg <[EMAIL PROTECTED]>:
>
>  Hello,
>  Quick question for ya.  For some reason I don't know how to make a OR
>  statment:  Below is my code:
>
>  
>
>  def Order(models.Model):
> order_status = models.CharField(max_length=2,
>  choices=ORDER_STATUS, blank=True)
>
> def save(self):
> if self.order_status == 3 or 4 (??)
>
>  
>
>  How do I make the if statement to check if the order_status is either
>  a 3 or 4
>
>  Thanks

if self.order_status in [3, 4]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to make a or statement?

2008-05-06 Thread Greg

Hello,
Quick question for ya.  For some reason I don't know how to make a OR
statment:  Below is my code:



def Order(models.Model):
order_status = models.CharField(max_length=2,
choices=ORDER_STATUS, blank=True)

def save(self):
if self.order_status == 3 or 4 (??)



How do I make the if statement to check if the order_status is either
a 3 or 4

Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: Django on MOSSO?

2008-05-06 Thread Bojan Ordev

I think he is referring to http://www.mosso.com the hosting company. I
may be wrong though.

-Original Message-
From: django-users@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Joseph Heck
Sent: Wednesday, 7 May 2008 11:05 AM
To: django-users@googlegroups.com
Subject: Re: Django on MOSSO?


what's MOSSO?

On Tue, May 6, 2008 at 12:01 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
>  Has anyone got it to work? Maybe with a hack or two?
>  >
>



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django on MOSSO?

2008-05-06 Thread Joseph Heck

what's MOSSO?

On Tue, May 6, 2008 at 12:01 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>  Has anyone got it to work? Maybe with a hack or two?
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reusable Web Controls

2008-05-06 Thread Juanjo Conti

Ben Firshman escribió:
> I like to use the {% include %} tag along with {% with %} around the  
> include tag to pass variables to the template. I'm not sure if this is  
> the best way to do it, but it works well for me!

You can define a inclusion tag for that.

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Russell Keith-Magee

On Wed, May 7, 2008 at 1:00 AM, Alen Ribic <[EMAIL PROTECTED]> wrote:
>
>  At this moment, to my knowledge, the only way to do this is by
>  overriding the save() method. Within your save, run the pre-save work
>  and then return the super.save().

Well - there is one other way: the default argument on a field. For example:

   position = models.IntegerField(blank=True, default=1)

You can also pass a callable:

from datetime import datetime
...
   pub_date = models.DateField(default=datetime.now)

Here, datetime.now() is a function; it will be invoked when the model
is saved to get the current value.

This won't work so well for your slots_available field, because it
requires access to the 'parent' field of the instance being saved. In
that case, overriding save() will be the best approach. If you for "id
is None" in the save() method, that will tell you whether the object
has been saved before, because the best marker for a new object is
that the PK hasn't been set yet.

You _could_ do all this with signals, but it's a bit over the top IMHO.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reusable Web Controls

2008-05-06 Thread Ben Firshman

I like to use the {% include %} tag along with {% with %} around the  
include tag to pass variables to the template. I'm not sure if this is  
the best way to do it, but it works well for me!

Ben

On 6 May 2008, at 19:24, [EMAIL PROTECTED] wrote:

>
> There is the includes tag, or you can make a template tag.
>
> On May 6, 1:20 pm, "Andrew English" <[EMAIL PROTECTED]> wrote:
>> Is there a way to embed templates in other templates using Django?   
>> For
>> example, you could have common elements like a navigation menu  
>> defined in a
>> single template, but included in others by reference.
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: mod_python vs. mod_wsgi

2008-05-06 Thread Bojan Ordev

The https one doesn't seem to work but the https one works:

https://blog.webfaction.com/django-setup-improvements 


-Original Message-
From: django-users@googlegroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of Jorge Vargas
Sent: Wednesday, 7 May 2008 8:48 AM
To: django-users@googlegroups.com
Subject: Re: mod_python vs. mod_wsgi


On Tue, May 6, 2008 at 5:43 PM, Adam Fast <[EMAIL PROTECTED]> wrote:
>
>  I'll check in the panel, but I get this when going to that URL (and
>  mentioned going to the main blog to find it, it's not there either):
>
>  "Not Found
>
>  The requested URL /django-setup-improvements was not found on this
>  server.:".404 error.

yea I got that for a while, but then refesh and it went away. I guess
we caught them with their server rebooting :)
>
>
>
>
>
>  On Tue, May 6, 2008 at 4:35 PM, Bernd <[EMAIL PROTECTED]> wrote:
>  >
>  >  This is the correct link:
>  >
>  > http://blog.webfaction.com/django-setup-improvements
>  >
>  >  This feature is still available in the control panel :-)
>  >
>  >
>  >
>  >
>  >  On Tue, 2008-05-06 at 16:18 -0500, Adam Fast wrote:
>  >  > Strangely enough, this link is now dead...and it's not mentioned
at
>  >  > the top of their blog either.  Maybe they pulled the plug?
>  >  >
>  >  >
>  >  >
>  >  > On Tue, May 6, 2008 at 2:45 PM, Brot <[EMAIL PROTECTED]> wrote:
>  >  > >
>  >  > >  Hello,
>  >  > >
>  >  > >  today webfaction announced
(http://blog.webfaction.com/django-setup-
>  >  > >  improvements) that they have now a one-click django/mod_wsgi
>  >  > >  installer.
>  >  > >
>  >  > >  What's your opinion with mod_wsgi? Is it better than
mod_python?
>  >  > >  What's the advantages/disadvantages?
>  >  > >
>  >  > >   Bernd
>  >  > >  >
>  >  > >
>  >  >
>  >  >
>  >
>  >  >
>  >
>
>  >
>



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Data Model Question

2008-05-06 Thread Peter Bailey

Thanks for the info and pointers Karen, I really appreciate it. I got
the feeling this might be a semi-scary way when searching the web for
meta and python this afternoon, and didn't really find a lot. I did up
screen prototypes for this app, and then designed a db model to
accommodate it, and now need to write the python code for the db and
the views, etc. That's probably the reverse order a lot of django devs
use, but it has worked well for me over the years. And, I always look
at the actual db structure and try to reduce wasted space etc. I'll do
some re-thinking here - I was actually torn on whether to use subtypes
or not. More complicated (bad) but better db space usage (good). I
guess disk space is pretty cheap these days lol.

Thanks again,

Peter

On May 6, 6:25 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, May 6, 2008 at 3:01 PM, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > Hey Karen. I used manage.py validate. My model validated before I
> > added the abstract class and changed the class signatures. But I
> > probably did something silly. Here is a chunk of the code:
>
> > # will use this for subclassing into our item subtypes
> > class AbstractType(models.Model):
> >    name = models.CharField(max_length=100)
> >    class Meta:
> >        abstract = True
>
> > class Item(models.Model):
> >    """Item information for survey pages - pages will contain one or
> > more of these"""
> >    sub_item = models.ForeignKey(AbstractType)
>
> This is the problem: you can't have a ForeignKey to an abstract model.  See
> this thread:
>
> http://groups.google.com/group/django-developers/browse_thread/thread...
>
> particularly Malcolm's reply.  As mentioned in that thread, Django's way to
> have a ForeignKey "point" to an unknown (or incompletely specified) type is
> something called generic relations.  Though it might seem (as suggested at
> the beginning of that thread) that generic relations could be dropped in
> favor of model inheritance, that's not actually the case (as Malcolm
> describes).
>
> Alternatively, perhaps your use case would be better served by non-abstract
> inheritance?  Inheritance doc is here:
>
> http://www.djangoproject.com/documentation/model-api/#model-inheritance
>
> You probably want to give it a careful read and see which way best fits with
> they way you are approaching your problem.
>
> [snipped remainder of model definitions]
>
> > Well there is some of the model code - thanks for taking a look - I
> > think I need to spend a couple of weeks reading 24 hours a day to get
> > up to speed on all this technology, But I have just escaped from dot
> > niet and asp and sql server etc etc. Oh, what a feeling, what a rush!
>
> You are rather jumping into the deep end by starting off with inheritance,
> which only recently landed in the Django trunk.  So there are probably not
> that many blog posts or mailing list threads yet with guidance, sample
> scenarios, how to use the feature. etc.  But if you're comfortable with a
> steep learning curve, in the end I expect you will figure it out.  Good
> luck!
>
> Karen
>
> > Cheers
>
> > On May 6, 2:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > On Tue, May 6, 2008 at 2:25 PM, Peter Bailey <[EMAIL PROTECTED]>
> > wrote:
>
> > > > Hey alen. I have tried implementing this and it makes good sense as
> > > > far as I can see, but when I validate the model I always get an
> > > > AttributeError: 'NoneType' object has no attribute 'name'.
>
> > > How are you validating the model?
>
> > > I have tried removing name from the definition of the class - same
>
> > > > message (not sure where it is getting 'name' from since I deleted it.
> > > > I also looked around and saw that some other have had similar
> > > > problems, and it seemed to be a string definition problem. So I put
> > > > back 'name' and changed it to an IntegerField - same unhappy result.
>
> > > > Do you have any notion of what the problem is? The code looks right to
> > > > me.
>
> > > It sounds like you have some code somewhere that is expecting to always
> > be
> > > handed an instance of your model, and thus be able to access the field
> > > 'name', but it is in fact sometimes getting handed None.  When handed
> > None,
> > > it still tries to access 'name', but since None has no attribute 'name',
> > you
> > > get the error.  If you post the code someone could probably help
> > pinpoint
> > > the error more specifically.
>
> > > Karen
>
> > > > Thanks,
>
> > > > Peter
>
> > > > On May 6, 1:33 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> > > > > Thanks very much for your solution and reply alen. I'm learning the
> > > > > ins and outs of python and django at the same time - fun adventure -
> > > > > so far python is blowing me away - I love it. Better than anything I
> > > > > have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
> > > > > (guess I am dating myself lol - most people don't seem to even ever
> > > > > have looked at assembler these 

Traversing a backward relationship

2008-05-06 Thread Michael J

I hope this isn't a stupid question, so forgive me in advance.

I have a Job model and a City model. Job and City are linked via a
ForeignKey in Job. On the website, users will select a city, from a
list of cities, and then see the corresponding jobs.

Question is: how do I use the database API to only show cities that
have jobs?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "None of the above" in a form?

2008-05-06 Thread Scott SA

On 5/6/08, Kirk Strauser ([EMAIL PROTECTED]) wrote:

>I'm generating forms from models like so:
>
>class Role(models.Model):
>assignedcompanies = models.ManyToManyField(Company, blank=True)
>
>class RoleForm(ModelForm):
>class Meta:
>model = Role
>
>Whenever I print that form in a template, it displays nicely and it's mostly 
>OK.  However, the list of Company objects renders as a MultipleChoiceField, 
>and there's no way that I've found to clear the list of selected values.  
>Is there a way to get a "None of the above" option or a "Clear" button to 
>get rid of unwanted or accidentally selected options?

Check here:



and look for 'filter_interface' about 1/3 down.

These are M2M relationship records handled transparently for you. In reality, 
they are in a table in between your two 'Role' tables. If you want to delete 
them, then you can select and delete them programatically (i.e. from a button 
on your form)

Something _like_ this should work to get ahold of them.

RoleForm.objects.select_related()\
.filter(assignedcompanies=)\
.delete()

I'm sure someone else might have a better solution.

Scott

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python vs. mod_wsgi

2008-05-06 Thread Jorge Vargas

On Tue, May 6, 2008 at 5:43 PM, Adam Fast <[EMAIL PROTECTED]> wrote:
>
>  I'll check in the panel, but I get this when going to that URL (and
>  mentioned going to the main blog to find it, it's not there either):
>
>  "Not Found
>
>  The requested URL /django-setup-improvements was not found on this
>  server.:".404 error.

yea I got that for a while, but then refesh and it went away. I guess
we caught them with their server rebooting :)
>
>
>
>
>
>  On Tue, May 6, 2008 at 4:35 PM, Bernd <[EMAIL PROTECTED]> wrote:
>  >
>  >  This is the correct link:
>  >
>  > http://blog.webfaction.com/django-setup-improvements
>  >
>  >  This feature is still available in the control panel :-)
>  >
>  >
>  >
>  >
>  >  On Tue, 2008-05-06 at 16:18 -0500, Adam Fast wrote:
>  >  > Strangely enough, this link is now dead...and it's not mentioned at
>  >  > the top of their blog either.  Maybe they pulled the plug?
>  >  >
>  >  >
>  >  >
>  >  > On Tue, May 6, 2008 at 2:45 PM, Brot <[EMAIL PROTECTED]> wrote:
>  >  > >
>  >  > >  Hello,
>  >  > >
>  >  > >  today webfaction announced (http://blog.webfaction.com/django-setup-
>  >  > >  improvements) that they have now a one-click django/mod_wsgi
>  >  > >  installer.
>  >  > >
>  >  > >  What's your opinion with mod_wsgi? Is it better than mod_python?
>  >  > >  What's the advantages/disadvantages?
>  >  > >
>  >  > >   Bernd
>  >  > >  >
>  >  > >
>  >  >
>  >  >
>  >
>  >  >
>  >
>
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Data Model Question

2008-05-06 Thread Karen Tracey
On Tue, May 6, 2008 at 3:01 PM, Peter Bailey <[EMAIL PROTECTED]> wrote:

>
> Hey Karen. I used manage.py validate. My model validated before I
> added the abstract class and changed the class signatures. But I
> probably did something silly. Here is a chunk of the code:
>
> # will use this for subclassing into our item subtypes
> class AbstractType(models.Model):
>name = models.CharField(max_length=100)
>class Meta:
>abstract = True
>
> class Item(models.Model):
>"""Item information for survey pages - pages will contain one or
> more of these"""
>sub_item = models.ForeignKey(AbstractType)


This is the problem: you can't have a ForeignKey to an abstract model.  See
this thread:

http://groups.google.com/group/django-developers/browse_thread/thread/ba191252874570e4/9c6096d5e7059c2c

particularly Malcolm's reply.  As mentioned in that thread, Django's way to
have a ForeignKey "point" to an unknown (or incompletely specified) type is
something called generic relations.  Though it might seem (as suggested at
the beginning of that thread) that generic relations could be dropped in
favor of model inheritance, that's not actually the case (as Malcolm
describes).

Alternatively, perhaps your use case would be better served by non-abstract
inheritance?  Inheritance doc is here:

http://www.djangoproject.com/documentation/model-api/#model-inheritance

You probably want to give it a careful read and see which way best fits with
they way you are approaching your problem.

[snipped remainder of model definitions]



> Well there is some of the model code - thanks for taking a look - I
> think I need to spend a couple of weeks reading 24 hours a day to get
> up to speed on all this technology, But I have just escaped from dot
> niet and asp and sql server etc etc. Oh, what a feeling, what a rush!
>

You are rather jumping into the deep end by starting off with inheritance,
which only recently landed in the Django trunk.  So there are probably not
that many blog posts or mailing list threads yet with guidance, sample
scenarios, how to use the feature. etc.  But if you're comfortable with a
steep learning curve, in the end I expect you will figure it out.  Good
luck!

Karen


> Cheers
>
> On May 6, 2:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > On Tue, May 6, 2008 at 2:25 PM, Peter Bailey <[EMAIL PROTECTED]>
> wrote:
> >
> > > Hey alen. I have tried implementing this and it makes good sense as
> > > far as I can see, but when I validate the model I always get an
> > > AttributeError: 'NoneType' object has no attribute 'name'.
> >
> > How are you validating the model?
> >
> > I have tried removing name from the definition of the class - same
> >
> > > message (not sure where it is getting 'name' from since I deleted it.
> > > I also looked around and saw that some other have had similar
> > > problems, and it seemed to be a string definition problem. So I put
> > > back 'name' and changed it to an IntegerField - same unhappy result.
> >
> > > Do you have any notion of what the problem is? The code looks right to
> > > me.
> >
> > It sounds like you have some code somewhere that is expecting to always
> be
> > handed an instance of your model, and thus be able to access the field
> > 'name', but it is in fact sometimes getting handed None.  When handed
> None,
> > it still tries to access 'name', but since None has no attribute 'name',
> you
> > get the error.  If you post the code someone could probably help
> pinpoint
> > the error more specifically.
> >
> > Karen
> >
> >
> >
> > > Thanks,
> >
> > > Peter
> >
> > > On May 6, 1:33 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> > > > Thanks very much for your solution and reply alen. I'm learning the
> > > > ins and outs of python and django at the same time - fun adventure -
> > > > so far python is blowing me away - I love it. Better than anything I
> > > > have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
> > > > (guess I am dating myself lol - most people don't seem to even ever
> > > > have looked at assembler these days. I used to love it - 7 years of
> > > > that after university) Oh, and of course C was always the bomb too
> :-)
> >
> > > > Thanks again,
> >
> > > > Peter
> >
> > > > On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > > wrote:
> >
> > > > > Define a 'abstract' attribute of Meta inner class and set it to
> true
> > > > > like so:
> >
> > > > > class AbstractType(models.Model):
> > > > > name = models.CharField(max_length=100)
> >
> > > > > class Meta:
> > > > > abstract = True
> >
> > > > > class RadioBoxTypes(AbstractType):
> > > > > radio_lable = models.CharField(max_length=20)
> >
> > > > > Regards,
> > > > > -Alen
> >
> > > > > On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> >
> > > > > > I have designed a small db model (on paper) and want to
> implement it
> > > > > > in my models.py file. So far, this has been pretty straight
> forward,
> > > > > 

file upload question

2008-05-06 Thread Chris

Hello I have a csv importer that I have made and I want to upload the
csv file through a form field as so:

from django import newforms as forms

class ImportForm(forms.Form):
"""
Form for importing CSV files
"""
csv_file = forms.FileField()

next I do something like this:

form = ImportForm()
if request.method == 'POST':
form = ImportForm(request.POST, request.FILES)
if form.is_valid():
if ‘csv_file’ in request.FILES:
try:
csv_file = request.FILES[‘csv_file’][‘content’]
except:
request.FILES[‘csv_file’][‘error’] = True

I am not really sure what I need to do here to get the file and store
it somewhere. right now it is returning the exception. Any suggestions?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic

Signals rule. :-)
Gave it a test drive and works like a charm.


from django.db import models
from django.db.models import signals
from django.dispatch import dispatcher


def send_entry_created_email(sender, instance, signal, *args,
**kwargs):
if instance.id is None:
# load 'create' mail template
   else:
# load 'change/update' template
   send_mail(template, title=instance.short_title)


class Entry(models.Model):
short_title = models.CharField(max_length=25)


dispatcher.connect(send_entry_created_email,
signal=signals.post_save, sender=Entry)



-Alen

On May 6, 8:05 pm, Alen Ribic <[EMAIL PROTECTED]> wrote:
> So something like this should do it:
>
> from django.db import models
> from django.db.models import signals
> from django.dispatch import dispatcher
>
> def send_entry_created_email():
>     # do some work...
>
> class Entry(models.Model):
>     # ...
>
> dispatcher.connect(send_entry_created_email,
>     signal=signals.post_save, sender=Entry)
>
> Regards,
> -Alen
>
> On May 6, 7:41 pm, Jashugan <[EMAIL PROTECTED]> wrote:
>
> > On May 6, 10:40 am, Alen Ribic <[EMAIL PROTECTED]> wrote:
>
> > > Not to sure though how one registers these signals.
>
> > This seems somewhat 
> > comprehensive:http://www.mercurytide.co.uk/whitepapers/django-signals/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python vs. mod_wsgi

2008-05-06 Thread David Zhou

It works for me.  Here's the body of that post:

* Support for mod_wsgi: Setting up a default Django app with mod_wsgi  
is now an option in our one-click installer. So if you prefer mod_wsgi  
over mod_python you will no longer have to install it manually. I just  
ran a simple benchmark using "ab -n 5000 -c 2" against a default  
Django site using mod_wsgi and the same using mod_python. Both were  
using 2 Apache worker processes. mod_wsgi was slightly faster (1400  
req/sec vs 1250 req/sec) and was using slightly less memory (10MB per  
Apache worker process vs 12MB). Note that you can also setup a  
standalone mod_wsgi application in our control panel (without Django).

* Support for the latest trunk: When you create a Django app you now  
have the option to use the latest trunk.

* More django docs: We've added some more knowledge base entries at 
https://help.webfaction.com/django 
  and we'll keep on adding more.


On May 6, 2008, at 5:43 PM, Adam Fast wrote:
>
> I'll check in the panel, but I get this when going to that URL (and
> mentioned going to the main blog to find it, it's not there either):
>
> "Not Found
>
> The requested URL /django-setup-improvements was not found on this
> server.:".404 error.
>
>
>
> On Tue, May 6, 2008 at 4:35 PM, Bernd <[EMAIL PROTECTED]> wrote:
>>
>> This is the correct link:
>>
>> http://blog.webfaction.com/django-setup-improvements
>>
>> This feature is still available in the control panel :-)
>>
>>
>>
>>
>> On Tue, 2008-05-06 at 16:18 -0500, Adam Fast wrote:
>>> Strangely enough, this link is now dead...and it's not mentioned at
>>> the top of their blog either.  Maybe they pulled the plug?
>>>
>>>
>>>
>>> On Tue, May 6, 2008 at 2:45 PM, Brot <[EMAIL PROTECTED]> wrote:

 Hello,

 today webfaction announced (http://blog.webfaction.com/django- 
 setup-
 improvements) that they have now a one-click django/mod_wsgi
 installer.

 What's your opinion with mod_wsgi? Is it better than mod_python?
 What's the advantages/disadvantages?

  Bernd
>

>>>
>>>
>>
>>>
>>
>
> >


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python vs. mod_wsgi

2008-05-06 Thread Adam Fast

I'll check in the panel, but I get this when going to that URL (and
mentioned going to the main blog to find it, it's not there either):

"Not Found

The requested URL /django-setup-improvements was not found on this
server.:".404 error.



On Tue, May 6, 2008 at 4:35 PM, Bernd <[EMAIL PROTECTED]> wrote:
>
>  This is the correct link:
>
> http://blog.webfaction.com/django-setup-improvements
>
>  This feature is still available in the control panel :-)
>
>
>
>
>  On Tue, 2008-05-06 at 16:18 -0500, Adam Fast wrote:
>  > Strangely enough, this link is now dead...and it's not mentioned at
>  > the top of their blog either.  Maybe they pulled the plug?
>  >
>  >
>  >
>  > On Tue, May 6, 2008 at 2:45 PM, Brot <[EMAIL PROTECTED]> wrote:
>  > >
>  > >  Hello,
>  > >
>  > >  today webfaction announced (http://blog.webfaction.com/django-setup-
>  > >  improvements) that they have now a one-click django/mod_wsgi
>  > >  installer.
>  > >
>  > >  What's your opinion with mod_wsgi? Is it better than mod_python?
>  > >  What's the advantages/disadvantages?
>  > >
>  > >   Bernd
>  > >  >
>  > >
>  >
>  >
>
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python vs. mod_wsgi

2008-05-06 Thread Bernd

This is the correct link:
http://blog.webfaction.com/django-setup-improvements

This feature is still available in the control panel :-)


On Tue, 2008-05-06 at 16:18 -0500, Adam Fast wrote:
> Strangely enough, this link is now dead...and it's not mentioned at
> the top of their blog either.  Maybe they pulled the plug?
> 
> 
> 
> On Tue, May 6, 2008 at 2:45 PM, Brot <[EMAIL PROTECTED]> wrote:
> >
> >  Hello,
> >
> >  today webfaction announced (http://blog.webfaction.com/django-setup-
> >  improvements) that they have now a one-click django/mod_wsgi
> >  installer.
> >
> >  What's your opinion with mod_wsgi? Is it better than mod_python?
> >  What's the advantages/disadvantages?
> >
> >   Bernd
> >  >
> >
> 
> 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



I'm working on a application where no data is shared between two accounts and multiple users share an account

2008-05-06 Thread [EMAIL PROTECTED]

I'm working on a application where no data is shared between two
accounts and multiple users share an account. Think backpackit or
sugarcrm.

The application hits the database frequently, many many queries are
performed for each page.

I've considered using the Sites app and just one database with all the
data being filtered for the current site but I think this might be to
slow and may cause additional problems when scaling.

The other option is to create a settings file per account with a
different database per user. Using mod_python, this would require a
python instance per settings file. Data requests would be faster
though I guess.

Does anyone have any experience implementing something like this?

Would like to hear from you.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python vs. mod_wsgi

2008-05-06 Thread Adam Fast

Strangely enough, this link is now dead...and it's not mentioned at
the top of their blog either.  Maybe they pulled the plug?



On Tue, May 6, 2008 at 2:45 PM, Brot <[EMAIL PROTECTED]> wrote:
>
>  Hello,
>
>  today webfaction announced (http://blog.webfaction.com/django-setup-
>  improvements) that they have now a one-click django/mod_wsgi
>  installer.
>
>  What's your opinion with mod_wsgi? Is it better than mod_python?
>  What's the advantages/disadvantages?
>
>   Bernd
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reusable Web Controls

2008-05-06 Thread Juanjo Conti

[EMAIL PROTECTED] escribió:
> There is the includes tag, or you can make a template tag.

You can even create a inclusion template tag: 
http://www.djangoproject.com/documentation/templates_python/

I have created some. Feel free to ask if you need help to get started 
with them.

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: customer serial numbers

2008-05-06 Thread Alen Ribic

forloop.counter like so:


{% for item in items %}
{{ forloop.counter }}
{% endfor %}


Regards,
-Alen Ribic


On May 6, 8:39 pm, "Ramdas S" <[EMAIL PROTECTED]> wrote:
> I know this sounds silly, but I am just not able to figure out a way to
> generate a custom serial number for
> generating reports.
>
> Is there a way to create a counter using for loops of django templates. Wr
> ite now I am using a  crude java script to do the same.
>
> RS
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python vs. mod_wsgi

2008-05-06 Thread Jorge Vargas

On Tue, May 6, 2008 at 3:45 PM, Brot <[EMAIL PROTECTED]> wrote:
>
>  Hello,
>
>  today webfaction announced 
> (http://blog.webfaction.com/django-setup-improvements) that they have now a 
> one-click django/mod_wsgi
>  installer.
>
>  What's your opinion with mod_wsgi? Is it better than mod_python?
>  What's the advantages/disadvantages?
they are several resources around the net with this information and in
general it is up to you.

some people say (including the webfaction post) that currently
mod_wsgi is a bit faster.

IMO it just depends on whether you are using wsgi and the support your
platform has for it.
>
>   Bernd
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Weird session problem

2008-05-06 Thread [EMAIL PROTECTED]

Ahh, I figured it out.  There was a java app server running on this
machine before and I for some reason that caused django to choke.  I
removed all of them and now it works.

Does this seem like a bug?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Weird session problem

2008-05-06 Thread [EMAIL PROTECTED]

I am seeing a weird session problem on one machine.  I have had my app
up and running on one machine for a while and it works fine.  I tried
copying all the code to another machine, setting up django/flup/
lighttpd and then running it.  The app starts up fine but then when I
go to log in I get an error on this:

user = request.session['userinfo']

It's a KeyError saying that it can't find 'userinfo'.  This is odd as
it works fine on my other machine and everything is set up the same.
Both are using Revision: 7519 from svn and lighttpd 1.4.19 with the
same lighttpd config file.

Additionally, here's the http_cookie from the error page:
'JSESSIONID=f341e291877de59a1155f9086b95;
JSESSIONID=ee65b7269fb6d0db0d4e6a1f2229; form:tree-
hi=form:tree:applications:webApplications;
sessionid=bd7443906e6b49ef7424b7366c667f16'

and from the interpreter:
>>> from django.contrib.sessions.backends.db import SessionStore
>>> s = SessionStore(session_key='bd7443906e6b49ef7424b7366c667f16')
>>> s.keys()
['userinfo']

We can see that the key exists under that session.  Why is it getting
this error?  This is really confusing me.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



"None of the above" in a form?

2008-05-06 Thread Kirk Strauser
I'm generating forms from models like so:

class Role(models.Model):
assignedcompanies = models.ManyToManyField(Company, blank=True)

class RoleForm(ModelForm):
class Meta:
model = Role

Whenever I print that form in a template, it displays nicely and it's mostly 
OK.  However, the list of Company objects renders as a MultipleChoiceField, 
and there's no way that I've found to clear the list of selected values.  
Is there a way to get a "None of the above" option or a "Clear" button to 
get rid of unwanted or accidentally selected options?
-- 
Kirk Strauser


signature.asc
Description: This is a digitally signed message part.


mod_python vs. mod_wsgi

2008-05-06 Thread Brot

Hello,

today webfaction announced (http://blog.webfaction.com/django-setup-
improvements) that they have now a one-click django/mod_wsgi
installer.

What's your opinion with mod_wsgi? Is it better than mod_python?
What's the advantages/disadvantages?

 Bernd
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sorting Drop-down fields on Admin site

2008-05-06 Thread Alen Ribic

It actually like this, sorry...to trigger happy today :)

class Composer(models.Model):
name = models.CharField(max_length=20)

class Meta:
ordering = ['name']

class Chart(models.Model):
composer = models.ForeignKey(Composer)



-Alen Ribic


On May 6, 9:20 pm, Alen Ribic <[EMAIL PROTECTED]> wrote:
> *correction:
>
> Need probably a comma at the end of the order tuple unless you use a
> list instead:
>
> class Chart(models.Model):
>     composer = models.ForeignKey(Composer)
>
>     class Meta:
>         ordering = ('composer',)
>
> --Alen Ribic
>
> On May 6, 9:17 pm, Alen Ribic <[EMAIL PROTECTED]> wrote:
>
> > You should be able to do it like so:
>
> > class Chart(models.Model):
> >     composer = models.ForeignKey(Composer)
>
> >     class Meta:
> >         ordering = ('composer')
>
> > Regards,
> > -Alen Ribic
>
> > PS check out:http://www.djangoproject.com/documentation/models/ordering/
>
> > On May 6, 8:48 pm, "Greg Lindstrom" <[EMAIL PROTECTED]> wrote:
>
> > > Hello-
>
> > > Is there a way to sort the drop down select boxes on the Admin site?
> > > I have a class, Chart, which represents a piece of music for my brass
> > > quintet library.  Each charts has a composer, an arranger and a
> > > publisher which are represented by the Composer, Arranger, and
> > > Publisher classes.  When I add a new chart to the database I click on
> > > the composer drop down to see if they are already listed in the db,
> > > but it appears they are ordered as they are entered.  I tried placing
> > > a sort_order in the Composer class, but that didn't seem to do it.
>
> > > Thanks,
> > > --greg
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sorting Drop-down fields on Admin site

2008-05-06 Thread Alen Ribic

*correction:

Need probably a comma at the end of the order tuple unless you use a
list instead:

class Chart(models.Model):
composer = models.ForeignKey(Composer)

class Meta:
ordering = ('composer',)

--Alen Ribic

On May 6, 9:17 pm, Alen Ribic <[EMAIL PROTECTED]> wrote:
> You should be able to do it like so:
>
> class Chart(models.Model):
>     composer = models.ForeignKey(Composer)
>
>     class Meta:
>         ordering = ('composer')
>
> Regards,
> -Alen Ribic
>
> PS check out:http://www.djangoproject.com/documentation/models/ordering/
>
> On May 6, 8:48 pm, "Greg Lindstrom" <[EMAIL PROTECTED]> wrote:
>
> > Hello-
>
> > Is there a way to sort the drop down select boxes on the Admin site?
> > I have a class, Chart, which represents a piece of music for my brass
> > quintet library.  Each charts has a composer, an arranger and a
> > publisher which are represented by the Composer, Arranger, and
> > Publisher classes.  When I add a new chart to the database I click on
> > the composer drop down to see if they are already listed in the db,
> > but it appears they are ordered as they are entered.  I tried placing
> > a sort_order in the Composer class, but that didn't seem to do it.
>
> > Thanks,
> > --greg
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sorting Drop-down fields on Admin site

2008-05-06 Thread Alen Ribic

You should be able to do it like so:

class Chart(models.Model):
composer = models.ForeignKey(Composer)

class Meta:
ordering = ('composer')


Regards,
-Alen Ribic

PS check out: http://www.djangoproject.com/documentation/models/ordering/

On May 6, 8:48 pm, "Greg Lindstrom" <[EMAIL PROTECTED]> wrote:
> Hello-
>
> Is there a way to sort the drop down select boxes on the Admin site?
> I have a class, Chart, which represents a piece of music for my brass
> quintet library.  Each charts has a composer, an arranger and a
> publisher which are represented by the Composer, Arranger, and
> Publisher classes.  When I add a new chart to the database I click on
> the composer drop down to see if they are already listed in the db,
> but it appears they are ordered as they are entered.  I tried placing
> a sort_order in the Composer class, but that didn't seem to do it.
>
> Thanks,
> --greg
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Data Model Question

2008-05-06 Thread Peter Bailey

Hey Karen. I used manage.py validate. My model validated before I
added the abstract class and changed the class signatures. But I
probably did something silly. Here is a chunk of the code:

# will use this for subclassing into our item subtypes
class AbstractType(models.Model):
name = models.CharField(max_length=100)
class Meta:
abstract = True

class Item(models.Model):
"""Item information for survey pages - pages will contain one or
more of these"""
sub_item = models.ForeignKey(AbstractType)
order = models.IntegerField()
class Admin:
pass

class Page(models.Model):
"""Page information for pages - surveys will contain one or more
of these"""
survey = models.ForeignKey(Survey)
item = models.ForeignKey(Item)
order = models.IntegerField()
file_name = models.CharField(max_length=50)
class Admin:
pass

class RadioBoxType(AbstractType):
"""A Radio Button object with its specific attributes"""
question_text = models.CharField(max_length=100)
question_sub_text = models.CharField(max_length=100)
item_type = models.CharField(max_length=20)
required = models.BooleanField()
randomize = models.BooleanField()
splitlist = models.BooleanField()
include_other = models.BooleanField()
other_prompt = models.CharField(max_length=100)
other_maxlen = models.IntegerField()
other_box_size = models.IntegerField()
class Admin:
pass

Well there is some of the model code - thanks for taking a look - I
think I need to spend a couple of weeks reading 24 hours a day to get
up to speed on all this technology, But I have just escaped from dot
niet and asp and sql server etc etc. Oh, what a feeling, what a rush!

Cheers

On May 6, 2:34 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Tue, May 6, 2008 at 2:25 PM, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > Hey alen. I have tried implementing this and it makes good sense as
> > far as I can see, but when I validate the model I always get an
> > AttributeError: 'NoneType' object has no attribute 'name'.
>
> How are you validating the model?
>
> I have tried removing name from the definition of the class - same
>
> > message (not sure where it is getting 'name' from since I deleted it.
> > I also looked around and saw that some other have had similar
> > problems, and it seemed to be a string definition problem. So I put
> > back 'name' and changed it to an IntegerField - same unhappy result.
>
> > Do you have any notion of what the problem is? The code looks right to
> > me.
>
> It sounds like you have some code somewhere that is expecting to always be
> handed an instance of your model, and thus be able to access the field
> 'name', but it is in fact sometimes getting handed None.  When handed None,
> it still tries to access 'name', but since None has no attribute 'name', you
> get the error.  If you post the code someone could probably help pinpoint
> the error more specifically.
>
> Karen
>
>
>
> > Thanks,
>
> > Peter
>
> > On May 6, 1:33 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> > > Thanks very much for your solution and reply alen. I'm learning the
> > > ins and outs of python and django at the same time - fun adventure -
> > > so far python is blowing me away - I love it. Better than anything I
> > > have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
> > > (guess I am dating myself lol - most people don't seem to even ever
> > > have looked at assembler these days. I used to love it - 7 years of
> > > that after university) Oh, and of course C was always the bomb too :-)
>
> > > Thanks again,
>
> > > Peter
>
> > > On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > Define a 'abstract' attribute of Meta inner class and set it to true
> > > > like so:
>
> > > > class AbstractType(models.Model):
> > > >     name = models.CharField(max_length=100)
>
> > > >     class Meta:
> > > >         abstract = True
>
> > > > class RadioBoxTypes(AbstractType):
> > > >     radio_lable = models.CharField(max_length=20)
>
> > > > Regards,
> > > > -Alen
>
> > > > On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > > > > I have designed a small db model (on paper) and want to implement it
> > > > > in my models.py file. So far, this has been pretty straight forward,
> > > > > but I have a generic superclass and several subclasses, and I am
> > > > > unsure how to implement this.
>
> > > > > My DB has page objects (webpages) with a few common attributes, and
> > a
> > > > > fk to an Item object. The item object is the generic superclass. It
> > > > > could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
> > > > > have attributes specific to themselves.
>
> > > > > Anyway, I don't grok how to set up this type of relationship in my
> > > > > models.py file. Is there a standard way of doing this, or does
> > anyone
> > > > > have an suggestions or can point me to some relevant info?
>
> > > > > 

Sorting Drop-down fields on Admin site

2008-05-06 Thread Greg Lindstrom

Hello-

Is there a way to sort the drop down select boxes on the Admin site?
I have a class, Chart, which represents a piece of music for my brass
quintet library.  Each charts has a composer, an arranger and a
publisher which are represented by the Composer, Arranger, and
Publisher classes.  When I add a new chart to the database I click on
the composer drop down to see if they are already listed in the db,
but it appears they are ordered as they are entered.  I tried placing
a sort_order in the Composer class, but that didn't seem to do it.

Thanks,
--greg

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



customer serial numbers

2008-05-06 Thread Ramdas S
I know this sounds silly, but I am just not able to figure out a way to
generate a custom serial number for
generating reports.

Is there a way to create a counter using for loops of django templates. Wr
ite now I am using a  crude java script to do the same.

RS

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Data Model Question

2008-05-06 Thread Karen Tracey
On Tue, May 6, 2008 at 2:25 PM, Peter Bailey <[EMAIL PROTECTED]> wrote:

>
> Hey alen. I have tried implementing this and it makes good sense as
> far as I can see, but when I validate the model I always get an
> AttributeError: 'NoneType' object has no attribute 'name'.
>

How are you validating the model?

I have tried removing name from the definition of the class - same
> message (not sure where it is getting 'name' from since I deleted it.
> I also looked around and saw that some other have had similar
> problems, and it seemed to be a string definition problem. So I put
> back 'name' and changed it to an IntegerField - same unhappy result.
>
> Do you have any notion of what the problem is? The code looks right to
> me.
>

It sounds like you have some code somewhere that is expecting to always be
handed an instance of your model, and thus be able to access the field
'name', but it is in fact sometimes getting handed None.  When handed None,
it still tries to access 'name', but since None has no attribute 'name', you
get the error.  If you post the code someone could probably help pinpoint
the error more specifically.

Karen



>
> Thanks,
>
> Peter
>
>
> On May 6, 1:33 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> > Thanks very much for your solution and reply alen. I'm learning the
> > ins and outs of python and django at the same time - fun adventure -
> > so far python is blowing me away - I love it. Better than anything I
> > have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
> > (guess I am dating myself lol - most people don't seem to even ever
> > have looked at assembler these days. I used to love it - 7 years of
> > that after university) Oh, and of course C was always the bomb too :-)
> >
> > Thanks again,
> >
> > Peter
> >
> > On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Define a 'abstract' attribute of Meta inner class and set it to true
> > > like so:
> >
> > > class AbstractType(models.Model):
> > > name = models.CharField(max_length=100)
> >
> > > class Meta:
> > > abstract = True
> >
> > > class RadioBoxTypes(AbstractType):
> > > radio_lable = models.CharField(max_length=20)
> >
> > > Regards,
> > > -Alen
> >
> > > On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> >
> > > > I have designed a small db model (on paper) and want to implement it
> > > > in my models.py file. So far, this has been pretty straight forward,
> > > > but I have a generic superclass and several subclasses, and I am
> > > > unsure how to implement this.
> >
> > > > My DB has page objects (webpages) with a few common attributes, and
> a
> > > > fk to an Item object. The item object is the generic superclass. It
> > > > could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
> > > > have attributes specific to themselves.
> >
> > > > Anyway, I don't grok how to set up this type of relationship in my
> > > > models.py file. Is there a standard way of doing this, or does
> anyone
> > > > have an suggestions or can point me to some relevant info?
> >
> > > > e.g. Pages - pointed to by fk in Items
> > > >   --
> >
> > > >   Items - has key to one of the below
> > > >   
> >
> > > > RadioBoxTypes   CheckboxTypes   VerbatimTypes   etc
> > > > ---   ---
> > > > -
> >
> > > > Thanks very much. Sorry if this is a dumb question - always fun
> being
> > > > a newbie :-(
> >
> > > > Peter
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Data Model Question

2008-05-06 Thread Peter Bailey

Hey alen. I have tried implementing this and it makes good sense as
far as I can see, but when I validate the model I always get an
AttributeError: 'NoneType' object has no attribute 'name'.

I have tried removing name from the definition of the class - same
message (not sure where it is getting 'name' from since I deleted it.
I also looked around and saw that some other have had similar
problems, and it seemed to be a string definition problem. So I put
back 'name' and changed it to an IntegerField - same unhappy result.

Do you have any notion of what the problem is? The code looks right to
me.

Thanks,

Peter


On May 6, 1:33 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> Thanks very much for your solution and reply alen. I'm learning the
> ins and outs of python and django at the same time - fun adventure -
> so far python is blowing me away - I love it. Better than anything I
> have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
> (guess I am dating myself lol - most people don't seem to even ever
> have looked at assembler these days. I used to love it - 7 years of
> that after university) Oh, and of course C was always the bomb too :-)
>
> Thanks again,
>
> Peter
>
> On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Define a 'abstract' attribute of Meta inner class and set it to true
> > like so:
>
> > class AbstractType(models.Model):
> >     name = models.CharField(max_length=100)
>
> >     class Meta:
> >         abstract = True
>
> > class RadioBoxTypes(AbstractType):
> >     radio_lable = models.CharField(max_length=20)
>
> > Regards,
> > -Alen
>
> > On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > > I have designed a small db model (on paper) and want to implement it
> > > in my models.py file. So far, this has been pretty straight forward,
> > > but I have a generic superclass and several subclasses, and I am
> > > unsure how to implement this.
>
> > > My DB has page objects (webpages) with a few common attributes, and a
> > > fk to an Item object. The item object is the generic superclass. It
> > > could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
> > > have attributes specific to themselves.
>
> > > Anyway, I don't grok how to set up this type of relationship in my
> > > models.py file. Is there a standard way of doing this, or does anyone
> > > have an suggestions or can point me to some relevant info?
>
> > > e.g.     Pages - pointed to by fk in Items
> > >           --
>
> > >           Items - has key to one of the below
> > >           
>
> > > RadioBoxTypes   CheckboxTypes   VerbatimTypes   etc
> > > ---   ---
> > > -    
>
> > > Thanks very much. Sorry if this is a dumb question - always fun being
> > > a newbie :-(
>
> > > Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reusable Web Controls

2008-05-06 Thread [EMAIL PROTECTED]

There is the includes tag, or you can make a template tag.

On May 6, 1:20 pm, "Andrew English" <[EMAIL PROTECTED]> wrote:
> Is there a way to embed templates in other templates using Django?  For
> example, you could have common elements like a navigation menu defined in a
> single template, but included in others by reference.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Reusable Web Controls

2008-05-06 Thread Andrew English
Is there a way to embed templates in other templates using Django?  For
example, you could have common elements like a navigation menu defined in a
single template, but included in others by reference.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Empty Result set

2008-05-06 Thread Richard Dahl

try this:
result_set = Model.objects.all()
if result_set:
result_set has data
else:
result_set is empty

On 5/6/08, jwwest <[EMAIL PROTECTED]> wrote:
>
> What's the preferred method of checking to see if a result set is
> empty in a view? For instance, I'm writing blog software and have a
> view by year method. If there are no posts, I want to raise a http404.
>
> I've tried == {} and == [] to no avail.
>
> Thanks,
>
> - James
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



0.96.1 lighttpd + FastCGI

2008-05-06 Thread Panos Laganakos

This is the lighty setup:

$HTTP["host"] == "manishop.solhost.org" {
   var.serverpath   = "/panos/manishop.solhost.org"
   server.document-root = basedir + serverpath + "/manigifts/static"
   server.errorlog  = basedir + serverpath + "/logs/server.log"
   accesslog.filename   = basedir + serverpath + "/logs/access.log"

   fastcgi.server= (".fcgi" =>
(
"localhost-9010" => ("host" => "127.0.0.1", "port" =>
9010),
)
   )
}

And fcgi is spawned by the user:

python manage.py runfcgi method=threaded host=127.0.0.1 port=9010

Trying to visit the site, spits an unhandled exception.

using `runserver` works fine though.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic

So something like this should do it:

from django.db import models
from django.db.models import signals
from django.dispatch import dispatcher

def send_entry_created_email():
# do some work...

class Entry(models.Model):
# ...

dispatcher.connect(send_entry_created_email,
signal=signals.post_save, sender=Entry)


Regards,
-Alen

On May 6, 7:41 pm, Jashugan <[EMAIL PROTECTED]> wrote:
> On May 6, 10:40 am, Alen Ribic <[EMAIL PROTECTED]> wrote:
>
>
>
> > Not to sure though how one registers these signals.
>
> This seems somewhat 
> comprehensive:http://www.mercurytide.co.uk/whitepapers/django-signals/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Empty Result set

2008-05-06 Thread jwwest

What's the preferred method of checking to see if a result set is
empty in a view? For instance, I'm writing blog software and have a
view by year method. If there are no posts, I want to raise a http404.

I've tried == {} and == [] to no avail.

Thanks,

- James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Jashugan



On May 6, 10:40 am, Alen Ribic <[EMAIL PROTECTED]> wrote:
>
> Not to sure though how one registers these signals.
>

This seems somewhat comprehensive: 
http://www.mercurytide.co.uk/whitepapers/django-signals/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic

> Do you know anything about pre_save and post_save signals that occur
> during a save? They are mentioned 
> here:http://www.djangoproject.com/documentation/db-api/#what-happens-when-...,
> but are not expounded.

To be honest, I didn't. However I took a look at it and there are
indeed signal hooks for pre_save and post_save in django/db/models/
base.py.
There is also a  django/db/models/signals.py

Not to sure though how one registers these signals.

-Alen

On May 6, 7:22 pm, Jashugan <[EMAIL PROTECTED]> wrote:
> Thanks, Alex.
>
> Do you know anything about pre_save and post_save signals that occur
> during a save? They are mentioned 
> here:http://www.djangoproject.com/documentation/db-api/#what-happens-when-...,
> but are not expounded.
>
> Also I modified my code (under the assumption that pk would be None
> for newly created models):
>
> if self.pk == None:
>             self.slots_available = self.storage_unit_type.total_slots
>             self.position = 1
>
> On May 6, 10:00 am, Alen Ribic <[EMAIL PROTECTED]> wrote:
>
> > At this moment, to my knowledge, the only way to do this is by
> > overriding the save() method. Within your save, run the pre-save work
> > and then return the super.save().
>
> > I have suggested a pre_save / post_save hooks for ModelForm with some
> > code recently 
> > here:http://groups.google.com/group/django-developers/browse_thread/thread...
>
> > -Alen Ribic
>
> > On May 6, 6:50 pm, Jashugan <[EMAIL PROTECTED]> wrote:
>
> > > I'd like to set some attributes to some default values before the
> > > model is created. Here's what I have so far:
>
> > >     slots_available = models.IntegerField(blank=True)
> > >     position = models.IntegerField(blank=True)
>
> > >     def save(self):
> > >         if slots_availalbe == None:
> > >             slots_available =
> > > StorageUnitType.objects.get(pk=parent).total_slots
> > >         if position == None:
> > >             position = 1
> > >         super(StorageUnit, self).save()
>
> > > Is this the best way of doing this? Is there a way I can specify that
> > > this code should run only when a model is first saved? I read
> > > something about using listeners for some post and pre save signals,
> > > but wasn't able to find any documentation on it.
>
> > > TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Code works with Django's server, but not with Apache+mod_python?

2008-05-06 Thread mw

Ahh, after running the code with both the django server and apache and
mod_python there are different paths listed.

I shall investigate on my own and come back if I need more help!

Thank you both very much!
mw

On May 5, 7:13 pm, "Chatchai Neanudorn" <[EMAIL PROTECTED]> wrote:
> When I installed my web at webfaction I did this to see which module python
> use,
>
> at settings.py
>
> import os
> import django, PIL
> logfile = open('path.log', 'w')
>
> django_path = django.__file__
> pil_path = PIL.__file__
>
> logfile.write('django - %\n pil - %s\n' % (django_path, pil_path))
>
> logfile.close()
>
> ...
>
> With this code, you can see which module you are using.
>
> I can successfully install my web with this trip.
>
> Regards
>
> 2008/5/5 TP <[EMAIL PROTECTED]>:
>
>
>
> > Could you have different PYTHONPATH settings for mod_python vs command
> > line where you're running the admin server? Different versions of PIL
> > or something between those two versions? libjpeg and friends installed
> > in non-standard locations where they're found by the command line
> > python but not the python being loaded by mod_python?
>
> > On May 2, 5:02 pm, mw <[EMAIL PROTECTED]> wrote:
> > > Hello,
>
> > > I've emailed the mailing list in the past because of problems with PIL
> > > and and image field upload in the admin interface.  The problem, just
> > > got weirder.
>
> > > I noticed that images were never validating as actual images and were
> > > constantly being rejected.  Out of a hunch, I fired up the django
> > > built-in server and tried the same page with the same image.  This
> > > time, the image validated and it was correctly uploaded.
>
> > > Does anyone happen to know what would then be stopping the code from
> > > validating the image upload when run through apache instead of the
> > > django development server?
>
> > > I'm using the SVN of django on OS X.
>
> > > Thanks in advance,
> > > mw
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Data Model Question

2008-05-06 Thread Peter Bailey

Thanks very much for your solution and reply alen. I'm learning the
ins and outs of python and django at the same time - fun adventure -
so far python is blowing me away - I love it. Better than anything I
have used before - 3 assemblers,c, c++ java, vb, ruby, php, asp, etc
(guess I am dating myself lol - most people don't seem to even ever
have looked at assembler these days. I used to love it - 7 years of
that after university) Oh, and of course C was always the bomb too :-)

Thanks again,

Peter


On May 6, 12:46 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Define a 'abstract' attribute of Meta inner class and set it to true
> like so:
>
> class AbstractType(models.Model):
>     name = models.CharField(max_length=100)
>
>     class Meta:
>         abstract = True
>
> class RadioBoxTypes(AbstractType):
>     radio_lable = models.CharField(max_length=20)
>
> Regards,
> -Alen
>
> On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
> > I have designed a small db model (on paper) and want to implement it
> > in my models.py file. So far, this has been pretty straight forward,
> > but I have a generic superclass and several subclasses, and I am
> > unsure how to implement this.
>
> > My DB has page objects (webpages) with a few common attributes, and a
> > fk to an Item object. The item object is the generic superclass. It
> > could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
> > have attributes specific to themselves.
>
> > Anyway, I don't grok how to set up this type of relationship in my
> > models.py file. Is there a standard way of doing this, or does anyone
> > have an suggestions or can point me to some relevant info?
>
> > e.g.     Pages - pointed to by fk in Items
> >           --
>
> >           Items - has key to one of the below
> >           
>
> > RadioBoxTypes   CheckboxTypes   VerbatimTypes   etc
> > ---   ---
> > -    
>
> > Thanks very much. Sorry if this is a dumb question - always fun being
> > a newbie :-(
>
> > Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic

*correction:
I was thinking of ModelForm instead of Model.
It should be self.pk instead.

if self.pk is None:
# new model
else:
# existing model

-Alen

On May 6, 7:25 pm, Jashugan <[EMAIL PROTECTED]> wrote:
> On May 6, 10:20 am, Alen Ribic <[EMAIL PROTECTED]> wrote:
>
> > > Is there a way I can specify that
> > > this code should run only when a model is first saved?
>
> > in save() method, you can check if this is a new model like so:
> > if self.instance.pk is None:
> >     # new model
> > else:
> >     # existing model
>
> what is the difference between self.pk versus self.instance.pk?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Jashugan



On May 6, 10:20 am, Alen Ribic <[EMAIL PROTECTED]> wrote:
> > Is there a way I can specify that
> > this code should run only when a model is first saved?
>
> in save() method, you can check if this is a new model like so:
> if self.instance.pk is None:
>     # new model
> else:
>     # existing model
>

what is the difference between self.pk versus self.instance.pk?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Jashugan

Thanks, Alex.

Do you know anything about pre_save and post_save signals that occur
during a save? They are mentioned here:
http://www.djangoproject.com/documentation/db-api/#what-happens-when-you-save,
but are not expounded.

Also I modified my code (under the assumption that pk would be None
for newly created models):

if self.pk == None:
self.slots_available = self.storage_unit_type.total_slots
self.position = 1


On May 6, 10:00 am, Alen Ribic <[EMAIL PROTECTED]> wrote:
> At this moment, to my knowledge, the only way to do this is by
> overriding the save() method. Within your save, run the pre-save work
> and then return the super.save().
>
> I have suggested a pre_save / post_save hooks for ModelForm with some
> code recently 
> here:http://groups.google.com/group/django-developers/browse_thread/thread...
>
> -Alen Ribic
>
> On May 6, 6:50 pm, Jashugan <[EMAIL PROTECTED]> wrote:
>
> > I'd like to set some attributes to some default values before the
> > model is created. Here's what I have so far:
>
> >     slots_available = models.IntegerField(blank=True)
> >     position = models.IntegerField(blank=True)
>
> >     def save(self):
> >         if slots_availalbe == None:
> >             slots_available =
> > StorageUnitType.objects.get(pk=parent).total_slots
> >         if position == None:
> >             position = 1
> >         super(StorageUnit, self).save()
>
> > Is this the best way of doing this? Is there a way I can specify that
> > this code should run only when a model is first saved? I read
> > something about using listeners for some post and pre save signals,
> > but wasn't able to find any documentation on it.
>
> > TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic

> Is there a way I can specify that
> this code should run only when a model is first saved?

in save() method, you can check if this is a new model like so:
if self.instance.pk is None:
# new model
else:
# existing model


Regards,
-Alen Ribic

On May 6, 7:00 pm, Alen Ribic <[EMAIL PROTECTED]> wrote:
> At this moment, to my knowledge, the only way to do this is by
> overriding the save() method. Within your save, run the pre-save work
> and then return the super.save().
>
> I have suggested a pre_save / post_save hooks for ModelForm with some
> code recently 
> here:http://groups.google.com/group/django-developers/browse_thread/thread...
>
> -Alen Ribic
>
> On May 6, 6:50 pm, Jashugan <[EMAIL PROTECTED]> wrote:
>
> > I'd like to set some attributes to some default values before the
> > model is created. Here's what I have so far:
>
> >     slots_available = models.IntegerField(blank=True)
> >     position = models.IntegerField(blank=True)
>
> >     def save(self):
> >         if slots_availalbe == None:
> >             slots_available =
> > StorageUnitType.objects.get(pk=parent).total_slots
> >         if position == None:
> >             position = 1
> >         super(StorageUnit, self).save()
>
> > Is this the best way of doing this? Is there a way I can specify that
> > this code should run only when a model is first saved? I read
> > something about using listeners for some post and pre save signals,
> > but wasn't able to find any documentation on it.
>
> > TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: approach on newforms fields for foreign key that can be selected or created

2008-05-06 Thread Dan Conner

Thanks for the input Christian. The question of filtering the
Collections for the particular user was one I dealt with, and I
recognize your site as one that did help me on that question a few
days ago.

Now, I want to have two form inputs related to selecting a Collection
on a form to create new Items. The first input is the standard select
box that {{ form.collection }} generates from a form based on the Item
model.

However, I also want to let the user enter a name for a *new*
Collection, not select an existing from the list, and handle that case
while processing the form.

Thanks for the input!

dc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Setting attributes before model is created

2008-05-06 Thread Alen Ribic

At this moment, to my knowledge, the only way to do this is by
overriding the save() method. Within your save, run the pre-save work
and then return the super.save().

I have suggested a pre_save / post_save hooks for ModelForm with some
code recently here: 
http://groups.google.com/group/django-developers/browse_thread/thread/c28da166daeea23c

-Alen Ribic

On May 6, 6:50 pm, Jashugan <[EMAIL PROTECTED]> wrote:
> I'd like to set some attributes to some default values before the
> model is created. Here's what I have so far:
>
>     slots_available = models.IntegerField(blank=True)
>     position = models.IntegerField(blank=True)
>
>     def save(self):
>         if slots_availalbe == None:
>             slots_available =
> StorageUnitType.objects.get(pk=parent).total_slots
>         if position == None:
>             position = 1
>         super(StorageUnit, self).save()
>
> Is this the best way of doing this? Is there a way I can specify that
> this code should run only when a model is first saved? I read
> something about using listeners for some post and pre save signals,
> but wasn't able to find any documentation on it.
>
> TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Setting attributes before model is created

2008-05-06 Thread Jashugan

I'd like to set some attributes to some default values before the
model is created. Here's what I have so far:

slots_available = models.IntegerField(blank=True)
position = models.IntegerField(blank=True)

def save(self):
if slots_availalbe == None:
slots_available =
StorageUnitType.objects.get(pk=parent).total_slots
if position == None:
position = 1
super(StorageUnit, self).save()

Is this the best way of doing this? Is there a way I can specify that
this code should run only when a model is first saved? I read
something about using listeners for some post and pre save signals,
but wasn't able to find any documentation on it.

TIA
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newbie Data Model Question

2008-05-06 Thread [EMAIL PROTECTED]

Define a 'abstract' attribute of Meta inner class and set it to true
like so:

class AbstractType(models.Model):
name = models.CharField(max_length=100)

class Meta:
abstract = True

class RadioBoxTypes(AbstractType):
radio_lable = models.CharField(max_length=20)


Regards,
-Alen

On May 6, 5:43 pm, Peter Bailey <[EMAIL PROTECTED]> wrote:
> I have designed a small db model (on paper) and want to implement it
> in my models.py file. So far, this has been pretty straight forward,
> but I have a generic superclass and several subclasses, and I am
> unsure how to implement this.
>
> My DB has page objects (webpages) with a few common attributes, and a
> fk to an Item object. The item object is the generic superclass. It
> could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
> have attributes specific to themselves.
>
> Anyway, I don't grok how to set up this type of relationship in my
> models.py file. Is there a standard way of doing this, or does anyone
> have an suggestions or can point me to some relevant info?
>
> e.g.     Pages - pointed to by fk in Items
>           --
>
>           Items - has key to one of the below
>           
>
> RadioBoxTypes   CheckboxTypes   VerbatimTypes   etc
> ---   ---
> -    
>
> Thanks very much. Sorry if this is a dumb question - always fun being
> a newbie :-(
>
> Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Few things ive been wondering

2008-05-06 Thread Norman Harman

phillc wrote:
  > first:
> 
> How does one develop tests for django web apps?
> im having trouble writing tests.
> i understand there are view tests, but those are so overly complex to
> write.
> i was just wondering how other people approach it, and if anyone can
> point me to some open source application that uses tests properly.
> i would love to give test driven development a try, but right now, i
> feel that my code is too bound to code in my view, which im having
> trouble making unit tests for. (id love to see a django project
> somewhere that was test driven)

TDD is very hard.  I rarely muster the discipline to do pure TDD.  But, 
TDD isn't required to have unittests, which are awesome by themselves.

If you haven't already read 
http://www.djangoproject.com/documentation/testing/

View tests don't have to be complex, the minimal test for a non-form 
view checks quite alot:

urls.py
urlpatterns = patterns("specials.views",
 url(r"^$", "ads", name="ts_ads"))

tests.py
 def test_specials(self):
 url = reverse("ts_ads")
 response = self.client.get(url)
 self.assertTemplateUsed(response, "specials/ads.html")


Basically if I write it I test it.  Don't test that Django works or your 
database works.  They should have their own tests.

For views I mostly don't check they return the expected html(it changes 
too often during development and I think that is better handled with a 
tool such as Selenium).  Instead I check that they use correct template, 
redirect to login page, don't raise exceptions, etc.  I also have 
written a custom UnitTest (extending Django's) that checks for empty 
template vars using TEMPLATE_STRING_IF_INVALID='test_oops_test'.

I do POST to views that have forms and check they work as expected. 
Although, I usually check form validation in separate forms tests.

I check forms with any custom validators or logic.

I check every method I write for models and model managers including 
things like __unicode__ via str(modelinstance).

Also, Every time I find a bug I first write a unittest that fails 
because of that bug.  Then I fix the bug and check unittest then passes.


> fourth:
> 
> i never understood this, why do people do
> 
> somevar = "blah blah %s" % anothervar
> 
> instead of "blah bla" + anothervar
> ?

Since python strings are immutable using + causes a lot of unnecessary 
copying.  It's probably not such a big deal in rarely executed code but 
is a real performance killer in loops.  For consistency and clarity, 
people tend to avoid using + with strings altogether.

For example this is slow/unnecessary:
   s = ""
   for txt in somelist:
 s += txt
   print s

The Pythonic way is to use a list:
   s = list()
   for txt in somelist:
 s.append(txt)
   print "".join(s)

Joining a list of strings is neat because instead of "" you can use ", " 
or "\n", "\t" which are all fairly common and join takes care of not 
having a trailing ", ".

For more see http://www.omahapython.org/IdiomaticPython.html

> fifth:
> 
> in my models, a model object is only aware of the objects above it,
> and not below it.
> in C, i remember i just declared all functions, with no body to it, at
> the top of the file
> then all functions were aware of all functions.
> how do i do this in python?

AFAIK you can't.  In some places with Django you can put names in quotes 
to have the same effect. See 
http://www.djangoproject.com/documentation/model-api/#relationships

-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman
___
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Newbie Data Model Question

2008-05-06 Thread Peter Bailey

I have designed a small db model (on paper) and want to implement it
in my models.py file. So far, this has been pretty straight forward,
but I have a generic superclass and several subclasses, and I am
unsure how to implement this.

My DB has page objects (webpages) with a few common attributes, and a
fk to an Item object. The item object is the generic superclass. It
could be a RadioType, a CheckBoxType, a VerbatimType, etc. These all
have attributes specific to themselves.

Anyway, I don't grok how to set up this type of relationship in my
models.py file. Is there a standard way of doing this, or does anyone
have an suggestions or can point me to some relevant info?

e.g. Pages - pointed to by fk in Items
  --

  Items - has key to one of the below
  

RadioBoxTypes   CheckboxTypes   VerbatimTypes   etc
---   ---
-

Thanks very much. Sorry if this is a dumb question - always fun being
a newbie :-(

Peter


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Few things ive been wondering

2008-05-06 Thread phillc

wow, thanks a ton to both of you.

richard, i understand what you mean about the children and ill think
about it more the next time i approach the problem

scott, youve defenietly convicned me about that. i dont think youve
convinced me enough to replace my already written code, but i will
defenitely be using that structure in the future.

On May 5, 7:42 pm, Scott SA <[EMAIL PROTECTED]> wrote:
> On 5/5/08, phillc ([EMAIL PROTECTED]) wrote:
>
> >fourth:
> >
> >i never understood this, why do people do
>
> >somevar = "blah blah %s" % anothervar
>
> >instead of "blah bla" + anothervar
> >?
>
> Because you can perform specific string formatting operations at the same 
> time. Plus, the formatting and data are separated, not to mention the 
> readability IMO is better as you'll see below.
>
> Take for example a float value of 3.141526. Depending upon the circumstance, 
> you may wish to round this value but you don't want to lose the precision.
>
> >>> '%0.2f' % 3.1425
> '3.14'
>
> It gets _much_ better as there is the ability to name that value for 
> formatting. There are a couple of ways to tap into this but the one I use all 
> the time is from a dictionary, here is a simplistic example.
>
> First, you need a dictionary, here's a simple one:
>
> >>> somedict = {}
> >>> somedict['first_name'] = 'Wilber'
> >>> somedict['last_name'] = 'Snodtgrass'
> >>> somedict['salutation'] = 'Mr.'
>
> Then, when ready, you can use string formatting like this:
>
> >>> 'Dear %(salutation)s %(first_name)s %(last_name)s,' % somedict
> 'Dear Mr. Wilber Snodtgrass,'
>
> Sure beats the snod out of:
>
> >>> 'Dear ' + somedict['salutation'] + \
> ... ' ' + somedict['first_name'] + ' ' + \
> ... somedict['last_name'] + ','
> 'Dear Mr. Wilber Snodtgrass,'
>
> As you can see, complex string formatting is possible. My examples only show 
> a the shiny tail-pipe of a very sweet and powerful vehicle.
>
> HTH
>
> Scott
>
> PS. If all you are doing is terminating a line, then this is fine:
> text_block + '/n'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: approach on newforms fields for foreign key that can be selected or created

2008-05-06 Thread Christian Joergensen

Dan Conner wrote:

[...]

> Any thoughts on a good approach, or link to examples?

I have a draft text on my blog that i was working on some time ago. 
Maybe you can get inspired:

http://www.technobabble.dk/2008/jan/06/filtering-foreign-key-choices-newforms-admin/

Maybe I should test it against the current nfa-branch and finish it off 
some day ;-)

Regards,
Christian

-- 
Christian Joergensen
http://www.technobabble.dk

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



approach on newforms fields for foreign key that can be selected or created

2008-05-06 Thread Dan Conner

My models define Item and Collection, where Item has a foreign key set
to Collection.

On the form to create new Items, I want the user to be able to select
from their existing Collections (which is simple to implement) but
also be able to not select from their existing Collections, but enter
text in a text input to create a new Collection.

I have tried a few things, read through the newforms documentation,
and am not seeing what an appropriate approach to doing this is.
Particularly if I don't want to create the new Collection if there's
something else in the form that is invalid.

My latest attempt was just having a text input, where the form submit
process did a get_or_create on the name entered, but was having
troubles setting the Collection on the Item through the Form object.

Any thoughts on a good approach, or link to examples?

Thanks,
dc
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Row-level permissions, recommendations?

2008-05-06 Thread Jay Parlar

On 5/6/08, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote:
>
>  What's the state of the art for row-level permissions in Django?
>  I'm working on an application where I need to allow users to edit
>  their own personal info but nobody else's. What app, hack, patch or
>  branch should I use in order to be able to do this via the admin site?

Going into the future, row-level permissions are going to be
implemented by making use of the newforms-admin branch. At least,
that's the last I heard about it.

The RLP branch that exists in SVN is *WAY* out of date.

Jay P.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New to django and python. error following tutorial w/ the shell

2008-05-06 Thread Rodrigo Culagovski

Can you post the code 5 lines before and after the one that's giving
you the error?
Many times python will report a syntax error in one line that's
actually caused by a missing parenthesis, semicolon, etc., in a line
before.

On May 6, 9:58 am, Jason Ourscene <[EMAIL PROTECTED]> wrote:
> I tried with the space and without the space and i am still getting
> that error.
> what do you think?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New to django and python. error following tutorial w/ the shell

2008-05-06 Thread Jason Ourscene

I tried with the space and without the space and i am still getting
that error.
what do you think?

On May 6, 12:28 am, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 06-May-08, at 9:37 AM, Jason Ourscene wrote:
>
> >   def __unicode__(self):
>
> def __unicode__(self):   <- space after 'def'. If you use a  
> python editor it will find errors like this
>
> --
>
> regards
> kghttp://lawgon.livejournal.comhttp://nrcfosshelpline.in/code/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Row-level permissions, recommendations?

2008-05-06 Thread Rodrigo Culagovski

What's the state of the art for row-level permissions in Django?
I'm working on an application where I need to allow users to edit
their own personal info but nobody else's. What app, hack, patch or
branch should I use in order to be able to do this via the admin site?

Thanks,

Rodrigo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django.cgi on Linux Hosting

2008-05-06 Thread Seamus

Hey Aldo,
I just stumbled across this thread.
Just looking at your django.cgi script i reckon musicisc maybe should
be musicischarity

as in sys.path.append("/hsphere/local/home/musicisc/Django-0.96")
should be sys.path.append("/hsphere/local/home/musicischarity/
Django-0.96")
just going on the dir structure that I have in my digiweb account


Seamus

On Apr 15, 9:07 am, Aldo <[EMAIL PROTECTED]> wrote:
> Thanks for your help on this Karen,
>
> Its apache returning the 404. So as i suspected the rewrite rules are
> not working for some reason. Yes admin is in the urls.
> Sure the rewrite rules - 
> rewriteswww.musicischarity.comtowww.musicischarity.com/homeso it really 
> should be working off the
> bat.
>
> Initially i got in touch with my hosting provider to confirm the
> rewrite rules were working - which they confirmed. Ive just sent an
> email again.
>
> On Apr 14, 3:21 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Mon, Apr 14, 2008 at 3:41 AM, Aldo <[EMAIL PROTECTED]> wrote:
> > > Yes, so thats fair enough - it just means that maybe MAYBE the dj
> > > script is being called - but when i access it viawww.gfdfdf.com/admin/
> > > it gives me a 404
>
> > (You've switched 
> > fromhttp://www.musicischarity.comtowww.gfdfdf.com
> > ?)
>
> > So the next step is to figure out if the 404 is coming from Apache or
> >Django.  Do you have the admin urls configured for yourDjangoapp?  If not,
> > then it's expected you'd get a 404 trying to access that url -- I just used
> > it as an example of one that might work since I have no idea what your own
> > application urls are.
>
> > Some ways to determine if the 404 is coming from Apache orDjango:
> > 1 - appearance -- does it look like the standard Apache "not found" or your
> > own 404.html template?
> > 2 - turn on DEBUG=True in your settings file and you will see theDjango
> > debug "page not found" page that includes all the urlpatterns and how the
> > one it was handed didn't match any of them, if you are getting toDjango
> > 3 - the Apache error log will have "File not found" errors listed for
> > something ending in "admin" if it is Apache returning the 404, but not if it
> > isDjango.
> > 4 - How long does it take for the 404 to be returned?  Quick means it's
> > probably coming from Apache, slow means probably your script is running and
> > it's your app/Djangothat is ultimately returning the 404.  (This config is
> > a VERY slow way of runningDjango, and I'm not sure you will find
> > performance acceptable even if/when you get it to work.)
>
> > If it is Apache returning the 404 then somehow your rewrite rules are not
> > kicking in.  What you list below rewrites everything ending in a slash (you
> > did include the trailing slash on the attempt to access admin?) except for
> > those that start withcgi-bin or media, plus it rewrites an empty url to a
> >Djangourl of 'home/' (so you'd need a urlpattern for 'home/' in yourDjango
> > config).
>
> > If it isDjangoreturning the 404 than the urlpattern configuration is not
> > handling the incoming urls as you expect, and you need to fix them.
>
> > Karen
>
> > > On Apr 11, 4:28 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> > > > On Fri, Apr 11, 2008 at 9:28 AM, Aldo <[EMAIL PROTECTED]> wrote:
>
> > > > > Fair point.
>
> > > > > My problem is - Initially i created my index.html in the root(DOCUMENT
> > > > > ROOT).
> > > > > Now I have downloadedDjangoas described - put it in my root.
> > > > > I have created my .htaccess files as
> > > > > RewriteEngine on
> > > > > RewriteRule ^cgi-bin/ - [L]
> > > > > RewriteRule ^media/ - [L]
> > > > > RewriteRule ^(.*)(/)$cgi-bin/dj/$1/
> > > > > RewriteRule ^$cgi-bin/dj/home/
> > > > > Ive created thecgi-bin/dj file and gave permissions.
> > > > > However when i try to access that file(http://www.musicischarity.com/
> > > > >cgi-bin/dj ) it gives me an
> > > > > error -  Error 500: Internal Server Error
>
> > > > You are not supposed to access the script directly like this.  Rather
> > > you
> > > > are supposed to use your application's normal urls (e.g.
> > >http://www.muicscharity.com/admin/for, say, theDjangoadmin app), and the
> > > > RewriteRules convert that to an invocation of your dj script.
>
> > > > > (Usually I would have content-type in it - but its not in the
> > > > > examples. tried it and still no good.)
> > > > > The dj file was edited to contain my own details. paths etc. maybe i
> > > > > have them wrong.
> > > > > sys.path.append("/hsphere/local/home/musicisc/Django-0.96")
> > > > > sys.path.append("/hsphere/local/home/musicisc")
> > > > > and
> > > > > # Change this to the directory above your site code.
> > > > > sys.path.append("/hsphere/local/home/musicisc/Django-0.96/")
> > > > > os.chdir("/hsphere/local/home/musicisc/Django-0.96/")
> > > > > # Change mysite to the name of your site package
> > > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'musicischarity.settings'

Re: Problem sending email

2008-05-06 Thread Emil

Nevermind. Turns out I'm just incredibly stupid, and had, for some
unknown reason, commented out the line with the admins-tuple, so the
mail had absolutely no recipient...

On May 6, 2:57 pm, Emil <[EMAIL PROTECTED]> wrote:
> Hi folks.
>
> I'm wrestling with a hosting company where I'm trying to deploy a
> django powered site. Pretty much the only remaining problem is sending
> email via the contact form. I don't get any errors while sending, but
> they never arrive... The following shows up in the sendmail logs:
> "did not issue MAIL/EXPN/VRFY/ETRN during connection to daemon0"
>
> The sendmail server is on localhost, port 25, and does not require a
> user/password. I've tried without any values (since the default values
> should suffice) and with the values explicitly set, both using ip
> (both the actual IP of the machine, and 127.0.0.1) and 'localhost'
> etc.
>
> The hosting company are not that familliar with django, but say that
> sandmail has been working perfectly on that machine for other (non-
> django) apps, so they suggest that some setting or other in Python or
> Django might be the culprit. The setup (using django-contact-form by
> James Bennett) has worked previously on a different host (Webfaction).
>
> Any mail experts out there that have any idea if this might be Django-
> related at all, or if there is any other reason this happens?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: frames

2008-05-06 Thread Trevor

In the link generation insert target="right".

For example My link message

This is where "right" is the name of the right panel.



On Tue, 2008-05-06 at 05:46 -0700, Gboro54 wrote:
> I am using links to do frames in my code...My problem is that I want
> the right frame to display the new stuff and the left to stay the
> same(after clicking a hyper-link in the left)Is this possible to do
> without using Javascript?
> > 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem sending email

2008-05-06 Thread Emil

Hi folks.

I'm wrestling with a hosting company where I'm trying to deploy a
django powered site. Pretty much the only remaining problem is sending
email via the contact form. I don't get any errors while sending, but
they never arrive... The following shows up in the sendmail logs:
"did not issue MAIL/EXPN/VRFY/ETRN during connection to daemon0"

The sendmail server is on localhost, port 25, and does not require a
user/password. I've tried without any values (since the default values
should suffice) and with the values explicitly set, both using ip
(both the actual IP of the machine, and 127.0.0.1) and 'localhost'
etc.

The hosting company are not that familliar with django, but say that
sandmail has been working perfectly on that machine for other (non-
django) apps, so they suggest that some setting or other in Python or
Django might be the culprit. The setup (using django-contact-form by
James Bennett) has worked previously on a different host (Webfaction).

Any mail experts out there that have any idea if this might be Django-
related at all, or if there is any other reason this happens?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



frames

2008-05-06 Thread Gboro54

I am using links to do frames in my code...My problem is that I want
the right frame to display the new stuff and the left to stay the
same(after clicking a hyper-link in the left)Is this possible to do
without using Javascript?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I get full path ( Include QUERY_STRING )?

2008-05-06 Thread Davide.D

Thank you!

On May 6, 5:56 pm, "Jonas Oberschweiber" <[EMAIL PROTECTED]>
wrote:
> From what I can see, request.get_full_path() seems to be what you
> want. Details 
> here:http://www.djangoproject.com/documentation/request_response/
>
> Regards
>
> Jonas
>
> 2008/5/6 Davide.D <[EMAIL PROTECTED]>:
>
>
>
> >  example:
> >  http://127.0.0.1:8000/search/?q=keyword
>
> >  "request.path" can just get "/search/"
>
> >  How can I get "/search/?q=keyword " ?
>
> >  
> >  My current solution:
>
> >  In my view:
> >  full_path = request.path + '?' + request.META['QUERY_STRING']
>
> >  In my template:
> >  Sign in
>
> >  It worked, but I think it's not a good way.
> >  
> >  Is there a better way to do this?
> >  Just like:
> >  Sign in
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



YUI for Django widgets?

2008-05-06 Thread Swaroop

Hi,

Is there a project already out there that allows me to use YUI rich
text editor as a newforms widget?

Thanks,
Swaroop
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



download mallu masala clips shakeela maria hema sizzling

2008-05-06 Thread saritha

download mallu masala clips shakeela maria hema sizzling

http://besthotmovies.blogspot.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



getting a value from bound_field in field_line.html template

2008-05-06 Thread mbdtsmh

Hi All,

Appologies if this is a stupid question but before I go any further
I'm new to Django!

I have modified the field_line.html template (from within the
change_form.html admin template) so it looks like this:

{% load admin_modify %}
{% load designset_extras %}
{% for bound_field in bound_fields %}{{ bound_field.html_error_list }}
{% endfor %}
{% for bound_field in bound_fields %}
  {% ifequal bound_field.field.name "exemplar_smiles" %}
 Exemplar / Generic Structure...

   Exemplar
smiles:
   
 
 

  {% else %}
{% if bound_field.has_label_first %}{% field_label2 bound_field %}
{% endif %}
{% field_widget bound_field %}
{% if not bound_field.has_label_first %}{% field_label2
bound_field %}{% endif %}
{% if bound_field.field.help_text %}{{ bound_field.field.help_text|safe }}{% endif %}
  {% endifequal %}
{% endfor %}


I basically want to replace the exemplar_smiles part of the form with
a custom form field. However, I still need to pass in the value from
exemplar_smiles into this custom form field. In the above example I
have tried to do this using {{ bound_field.field.data }} but with no
luck.

Is there a way to extract the value from the bound_field object???

Any help would be greatly appreciated.

Thanks, Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Model Setup for Admin

2008-05-06 Thread shocks

Hi

I'm trying to figure out the structure of a model that has singleton
elements within it.  I guessing this should be 2 seperate models that
are bound together.  I would like to use the admin utility to present
the following to the admin user:

Clients Section
   - Client Section Title
   - Client Section Intro Copy
   - Client list
   - Client 1
   - Client 1 Title
   - Client 1 Copy
- Client 2
   - Client 2 Title
   - Client 2 Copy
- Client 3
   - Client 3 Title
   - Client 3 Copy

etc...

Ideally I would like to select the 'Clients' section from the main
admin screen and then be able to add or remove clients from list from
within that section.  I have it working whereby the client list is in
the root of admin (in a previous project).  How do I edit my model to
allow this?

Thanks
Ben






--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: where can i download newformsadmin

2008-05-06 Thread David Reynolds


On 5 May 2008, at 7:06 pm, Horst Gutmann wrote:

>
> $ svn co http://code.djangoproject.com/svn/django/branches/newforms- 
> admin
>
> Works for me. What error do you get?

You could also do:

svn switch http://code.djangoproject.com/svn/django/branches/newforms- 
admin

in a trunk checkout.

-- 
David Reynolds
[EMAIL PROTECTED]



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How can I get full path ( Include QUERY_STRING )?

2008-05-06 Thread Jonas Oberschweiber

>From what I can see, request.get_full_path() seems to be what you
want. Details here:
http://www.djangoproject.com/documentation/request_response/

Regards

Jonas

2008/5/6 Davide.D <[EMAIL PROTECTED]>:
>
>  example:
>  http://127.0.0.1:8000/search/?q=keyword
>
>  "request.path" can just get "/search/"
>
>  How can I get "/search/?q=keyword " ?
>
>  
>  My current solution:
>
>  In my view:
>  full_path = request.path + '?' + request.META['QUERY_STRING']
>
>  In my template:
>  Sign in
>
>  It worked, but I think it's not a good way.
>  
>  Is there a better way to do this?
>  Just like:
>  Sign in
>
>  >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What is reverse() good for? Not really reversing...

2008-05-06 Thread web-junkie

Okay, if you take the perspective that it reverses the normal order,
it does what it should. But then I don't know why we have such a
function in there, as the ordering can easily manipulated.
What I expected from the method is, when iterating, to give me the
last item instead of the first one an so on.. that has nothing to do
with how it sould execute SQL so I don't know why I should state any
SQL here.

On 2 Mai, 17:51, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, May 2, 2008 at 11:11 AM, web-junkie <[EMAIL PROTECTED]> wrote:
>
> > On 1 Mai, 19:32, "Justin Lilly" <[EMAIL PROTECTED]> wrote:
> > > While it may be the long way around, can you not do the following?
> > > a = Articles.objects.all()[:3]
> > > a.reverse()
>
> > > That would probably be my solution.
>
> > That's exactly what I tried, and as I described, it gives you
> > something wrong, not the queryset reversed...
>
> Now, I don't think what it give you is wrong, it's just not what you
> wanted/expected.  Instead of reversing the result after retrieval/slicing
> using the normal ordering, it is reversing the normal ordering and then
> retrieving/slicing the result.  So, given a sequence with normal ordering:
>
> a,b,c,x,y.z
>
> You are looking to get (c,b,a) instead of (z,y,x).  Below, you mention a doc
> note that explains why it doesn't do what you want by noting that there is
> no efficient way in SQL to produce the result you are looking for and say
> that is nonsense.  If it is nonsense, could you please state the SQL
> statement you would use to achieve the result you are looking for?
>
> Karen
>
>
>
>
>
> > > On Thu, May 1, 2008 at 12:36 PM, web-junkie <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > what is the new reverse() method good for? Seems it just swaps the
> > > > order_by statement?
> > > > I would appreciate a reverse() method that, if used after slicing,
> > > > would actually reverse the queryset.
> > > > In the docs it's said: "Django doesn't support that mode of access
> > > > (slicing from the end), because it's not possible to do it efficiently
> > > > in SQL."
> > > > That is nonsense, because reverse should not slice from anywhere, it
> > > > should just reverse, and you can do that in python.
> > > > So when I have Articles.objects.all()[:3] which gives me a,b,c,
> > > > Articles.objects.all()[:3].reverse() would make c,b,a out of it, not
> > > > z,y,x! Or am I missing something?
>
> > > --
> > > Justin Lilly
> > > Web Developer/Designerhttp://justinlilly.com-Zitierten Text ausblenden
> > -
>
> > > - Zitierten Text anzeigen -- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What is reverse() good for? Not really reversing...

2008-05-06 Thread web-junkie

That is what I do at the moment, putting it in a list in such an order
that it is reversed.

On 2 Mai, 19:58, "J. Cliff Dyer" <[EMAIL PROTECTED]> wrote:
> On Thu, 2008-05-01 at 09:36 -0700, web-junkie wrote:
> > Hi,
>
> > what is the newreverse() method good for? Seems it just swaps the
> > order_by statement?
> > I would appreciate areverse() method that, if used after slicing,
> > would actuallyreversethe queryset.
> > In the docs it's said: "Django doesn’t support that mode of access
> > (slicing from the end), because it’snotpossible to do it efficiently
> > in SQL."
> > That is nonsense, becausereverseshouldnotslice from anywhere, it
> > should justreverse, and you can do that in python.
> > So when I have Articles.objects.all()[:3] which gives me a,b,c,
> > Articles.objects.all()[:3].reverse() would make c,b,a out of it,not
> > z,y,x! Or am I missing something?
>
> The problem seems to be in getting the ORM to write an appropriate query
> to return the results you want.  Would it work for your needs if you
> pull it out of the queryset into a list, and thenreverseit at the
> python level?
>
> Something like this (untested code follows)
>
> py>>> arts = Articles.objects.all()[:3]
> py>>> arts = list(arts)
> py>>> arts.reverse()
>
> The drawback, of course, is that you no longer have a query set, so
> whether this will work for you depends on your use case.
>
> Cheers,
> Cliff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How can I get full path ( Include QUERY_STRING )?

2008-05-06 Thread Davide.D

example:
http://127.0.0.1:8000/search/?q=keyword

"request.path" can just get "/search/"

How can I get "/search/?q=keyword " ?


My current solution:

In my view:
full_path = request.path + '?' + request.META['QUERY_STRING']

In my template:
Sign in

It worked, but I think it's not a good way.

Is there a better way to do this?
Just like:
Sign in

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Database Migration Question

2008-05-06 Thread jack

Russ - We had a few back and forths about this several weeks ago, if
you recall.  I now am much better versed in Django and so maybe a bit
more capable of making intelligent comments.

It would seem to me that with the primitives that I am seeking (which
is basically a continuation of hiding the SQL specifics of each DMBS
using Python code) all kinds of migration capabilities can easily be
implemented.  In fact, I can see several options, all valid, that each
developer can choose for their project.  That way Django would not
have to decide in advance how to do migrations.   Some may prefer
whole frameworks and specific methodologies, others will prefer to
roll their own.  For all intents and purposes, many of these
primitives already exist, at least for the initial creation of tables
from model class definitions, why not extend it to the next level and
provide the same toosl for Django developers to create tables and
modify them?  Seems like a natural to me.  I would write it myself,
but I am too rusty with SQL and the different syntaxes across
databases to be able to really dive in at this point.  But I would
enjoy collaborating on design and proposed implementation with anyone
who was willing and capable of tackling this task.

Jack

On May 5, 9:34 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Tue, May 6, 2008 at 11:57 AM, jack <[EMAIL PROTECTED]> wrote:
>
> >  Are there any Python/Django methods that represent generic database
> >  commands such as creating a new table, renaming or dropping a column,
> >  etc.?  My thinking is that if these generic methods existed, so that
> >  all I needed to do was specifiy the correct info abt my DBMS in the
> >  Settings file, I could create my own migrations as custom Views.  I
> >  could invoke these via the web as well after having copied my latest
> >  code to my production server.
>
> There isn't anything built into Python or Django, but there are a few
> projects running externally to Django that implement this sort of
> feature.
>
> Personally, I would recommend Django Evolution [1] - but then, I'm one
> of the developers of that project. If you search the django-users and
> django-developers archives for "schema evolution", you will find
> references to a few other projects.
>
> [1]http://code.google.com/p/django-evolution
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: disabling a field

2008-05-06 Thread Kenneth Gonsalves


On 06-May-08, at 12:28 PM, Adam Findley wrote:

> So I've been wondering how one goes about disabling a field in
> newforms.  I want it to look something like this:
>
> 
>
> Anyone have any suggestions?  I have been digging through google,
> documentation and widgets, but have been unable to come to a
> conclusive answer.

try 'attrs' for the widget?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django on MOSSO?

2008-05-06 Thread [EMAIL PROTECTED]

Has anyone got it to work? Maybe with a hack or two?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Default Pluralize logic

2008-05-06 Thread [EMAIL PROTECTED]

> Regardless, the context for that discussion is quite
> different to the context of this current discussion.

I take back what I said on my last note.

-Alen

On May 6, 8:43 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Tue, May 6, 2008 at 2:16 PM, [EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> wrote:
>
> >  > You might want to check the date on that thread before you pull it in
> >  > for moral support.
>
> >  If you bothered taking a look at the thread, you would have seen that
> >  the decision to keep the pluralize simple was discussed and probably
> >  introduced as the way forward at the time. Hence my reference. (Below
> >  the belt Russ! :-))
>
> If you felt my comment was below the belt, I apologize. It wasn't
> intended as such.
>
> I did look at the thread, and I stand by my point. The discussion you
> reference was from a time when pluralization was important for
> different reasons. Pre-magic removal (the time from which that thread
> comes), the plural name was used as part of the API - i.e., you didn't
> ask for Entry.objects.all(), you said entries.get_list(). As a result,
> the pluralization process was an important part of the API, so getting
> pluralization right was important. The magic removal process turned
> pluralization into almost entirely a presentation issue. The
> requirements of pluralization in the API are quite different to those
> at the presentation layer.
>
> There is a side discussion in the thread about adding pluralize as a
> class method. I suspect that this was also on the table for
> pre-magic-removal reasons - back in the day, there were limitations on
> your ability to associate methods with models. Since the magic has
> been removed, this is no longer an issue - if you want to put a
> pluralize() method on your models to assist with rendering, you are
> free to do so. Regardless, the context for that discussion is quite
> different to the context of this current discussion.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



disabling a field

2008-05-06 Thread Adam Findley

So I've been wondering how one goes about disabling a field in
newforms.  I want it to look something like this:



Anyone have any suggestions?  I have been digging through google,
documentation and widgets, but have been unable to come to a
conclusive answer.

Thanks,
Adam

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Default Pluralize logic

2008-05-06 Thread Russell Keith-Magee

On Tue, May 6, 2008 at 2:16 PM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
>  > You might want to check the date on that thread before you pull it in
>  > for moral support.
>
>  If you bothered taking a look at the thread, you would have seen that
>  the decision to keep the pluralize simple was discussed and probably
>  introduced as the way forward at the time. Hence my reference. (Below
>  the belt Russ! :-))

If you felt my comment was below the belt, I apologize. It wasn't
intended as such.

I did look at the thread, and I stand by my point. The discussion you
reference was from a time when pluralization was important for
different reasons. Pre-magic removal (the time from which that thread
comes), the plural name was used as part of the API - i.e., you didn't
ask for Entry.objects.all(), you said entries.get_list(). As a result,
the pluralization process was an important part of the API, so getting
pluralization right was important. The magic removal process turned
pluralization into almost entirely a presentation issue. The
requirements of pluralization in the API are quite different to those
at the presentation layer.

There is a side discussion in the thread about adding pluralize as a
class method. I suspect that this was also on the table for
pre-magic-removal reasons - back in the day, there were limitations on
your ability to associate methods with models. Since the magic has
been removed, this is no longer an issue - if you want to put a
pluralize() method on your models to assist with rendering, you are
free to do so. Regardless, the context for that discussion is quite
different to the context of this current discussion.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Default Pluralize logic

2008-05-06 Thread [EMAIL PROTECTED]

> You might want to check the date on that thread before you pull it in
> for moral support.

If you bothered taking a look at the thread, you would have seen that
the decision to keep the pluralize simple was discussed and probably
introduced as the way forward at the time. Hence my reference. (Below
the belt Russ! :-))

Non-the less, I do have a better understanding now why it should
perhaps stay as is.

-Alen

On May 6, 1:41 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Tue, May 6, 2008 at 6:10 AM, [EMAIL PROTECTED]
>
> <[EMAIL PROTECTED]> wrote:
>
> >  Important, related, post on the dev list:
>
> >  "Ditch pluralisation entirely"
> >  http://groups.google.com/group/django-developers/browse_thread/thread...
>
> You might want to check the date on that thread before you pull it in
> for moral support. November 2005 was in the 'pre-magic-removal' era of
> Django - the discussion that is going on there was the start of some
> fundamental changes to the way you compose queries - changes that are
> now fully integrated into Django.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New to django and python. error following tutorial w/ the shell

2008-05-06 Thread LaundroMat

On 6 mei, 06:32, Norman <[EMAIL PROTECTED]> wrote:
> and what editor do you use?
> some advice?

Geany (PC & Linux, Mac probably too) is the one I use.
As for books, Core Python Programming is invaluable (to me at least) -
see 
http://www.amazon.com/Core-Python-Programming-2nd/dp/0132269937/ref=pd_bbs_sr_7?ie=UTF8=books=1210054267=8-7
, and certainly have a look at these this online books as well:
http://www.diveintopython.org/

Mathieu


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: xml serialization with nested models

2008-05-06 Thread [EMAIL PROTECTED]



On May 6, 11:14 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Tue, May 6, 2008 at 8:52 AM, Explore <[EMAIL PROTECTED]> wrote:
>
> >  Hi. I have been trying to get django to return my models as xml.  I
> >  have tried using the xml serializer but i cannot get it to send back
> >  anything but the initial model.
>
> >  I would like to get nested xml like below (where Department has a
> >  ForeignKey to Organization).
>
> That may be what you want, but that's not what the Django serializer
> provides. The original design goal of the Django serializer was to
> allow for the definition of fixtures; output in the format you
> describe only serves to complicate the deserialization process.
>
> However, the idea is a good one. What you have requested has been
> suggested before. It is logged as ticket 4656 [1], and has been
> accepted as a feature request.
>
> [1]http://code.djangoproject.com/ticket/4656
>
> As I see it, you have two options:
> 1) Write your own custom XML serializer that outputs the format you
> want. Serializers are actually pretty simple to write - it's
> deserializers that cause the most problems, so this probably isn't as
> difficult as you think.
>
> 2) Work out a patch to allow this sort of expansion in the Django
> serializers. If a patch (with tests and documentation) were to be
> provided, it would eventually find itself in the trunk.
>
> Yours,
> Russ Magee %-)

I have such a "full" serializer already written for JSON which I
really should have released by now :( . I don't think it would be too
hard to extend it to XML.

I've written it as an independent python module from the Django
serializers so I can just put this in my settings.py:

SERIALIZATION_MODULES = {
'json': 'nong.api.serializers.json',
}

It is backwards compatible to a degree, i.e. it accepts all the same
arguments and produces identical output as the Django serializer, but
if you use any of the extra arguments then you'll run into trouble
deserializing as I haven't written that part yet. I discuss how it
works here in this thread [1].

Let me get my act together and release it. I'll post an update to the
list soon.

[1] 
http://groups.google.com/group/django-users/browse_thread/thread/c930cf920e726bbd/4faa358b8c91365d#4faa358b8c91365d


regards

Matthew

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: reverse: TypeError: dict objects are unhashable

2008-05-06 Thread sector119

I use reverse('staticpages-staticpage_delete', kwargs={'object_id':
4}) in my code.
It works (the same code) for many models, and only this one doesn't
work properly.

On May 6, 1:12 am, Lemuel Formacil <[EMAIL PROTECTED]> wrote:
> Try this:
>
> On May 5, 2008, at 6:32 PM, sector119 wrote:
>
>  reverse('staticpages-staticpage_delete', {'object_id': 4})
>
> reverse('staticpages-staticpage_delete', kwargs={'object_id': 4})
>
> --
> Lemuel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---