Re: Installed apps settings, necessary?

2007-02-10 Thread voltron
Thank you all for the clarification! On Feb 10, 5:32 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 2/9/07, voltron <[EMAIL PROTECTED]> wrote: > > > what are the advantages of adding the apps to the settings file? > > Several things: > > * If an app is never listed in INSTALLED_APPS, syncdb

Re: are the Installed apps settings necessary?

2007-02-10 Thread voltron
Aha! Thanks for the answers. --~--~-~--~~~---~--~~ 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 [EM

Re: Running django with stackless

2007-02-10 Thread krypton
Django part of my code is in webpy and a differnet proj in django On Feb 10, 5:12 am, James Tauber <[EMAIL PROTECTED]> wrote: > Is your mention of webpy everywhere instead of Django a cut-and-paste > error? > > Are you really asking about django or about webpy? > > On 10/02/2007, at 7:30 AM, kr

newforms Validation Static vs Dynamic

2007-02-10 Thread johnny
What is the different between newforms, forms.CharField(max_length = 30, min_length = 5, error_message ='Must be at least 5 char length') and using clean method raise forms.ValidationError ('Display some error message') Is former for static error message and later for Dynamic Error Message? --~

Using NEWFORMS to select data from the MODEL

2007-02-10 Thread johnny
I have to include some fields from 3 different models. How do you create a selection field, for selecting a category data, in category model, using newforms? Thank You in advance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the G

Re: how to set the choices of Select Widget by code in the newforms

2007-02-10 Thread gordyt
> I don't think there's any way of accessing the request.user from the > Form class (is there?). If I could pass in the choices when I'm > instantiating the form from views.py my problem would be solved. Is > this possible? Cathy this is absolutely possible. Here is an example from one of my pro

Re: Subclassing models

2007-02-10 Thread Malcolm Tredinnick
On Sat, 2007-02-10 at 23:22 +, Zach Seifts wrote: > I don't want to use a ForeignKey. I want to be able to set up a class > in the model and not have a table created. Maybe the base model thing > is the way to do it. I've read somewhere about mixins, could these be > of interest? As Collin me

Re: Subclassing models

2007-02-10 Thread Zach Seifts
I don't want to use a ForeignKey. I want to be able to set up a class in the model and not have a table created. Maybe the base model thing is the way to do it. I've read somewhere about mixins, could these be of interest? On Feb 10, 4:37 pm, "Collin Grady" <[EMAIL PROTECTED]> wrote: > Subclassin

Re: 404 Error - Can't link to my css or image files from a template.

2007-02-10 Thread Dan Lynch
Thanks for the link, it sorted the problem. It did my head in for a while though I have to admit. I knew it would be something to do with the URLConf but I couldn't seem to find the answer, maybe my brain was just fried after a 5 hours staring at the screen, it seemed a lot easier after a break :-

Re: ForeignKey, null, and schema evolution

2007-02-10 Thread Ramiro Morales
On 2/10/07, David Abrahams <[EMAIL PROTECTED]> wrote: > > Whatever django bugs may be lurking asid, I need to move forward with > my project ASAP so I'd really appreciate it if someone could give me a > few hints about how to evolve my existing DB (which was created > without the primary_key=True

Re: Doing "in" subqueries on the server-side

2007-02-10 Thread Malcolm Tredinnick
On Sat, 2007-02-10 at 09:41 -0600, Tim Chase wrote: > For an app I've been assembling, I need to filter a particular > data-set based on multiple many-to-many criteria where the > criteria span multiple records in the far participant of the M2M. > The basics are the recordset (Items) and each Ite

Re: Subclassing models

2007-02-10 Thread Collin Grady
Subclassing doesn't work right yet, you need to use a ForeignKey or similar to the base model in order to relate them - if you do it the way you're trying it will break things randomly. On Feb 10, 12:25 pm, "Zach Seifts" <[EMAIL PROTECTED]> wrote: > I have been working on a project where I need t

Re: 404 Error - Can't link to my css or image files from a template.

2007-02-10 Thread Collin Grady
You cannot put images in your templates directory. You need to make a media folder and map it properly as detailed here: http://www.djangoproject.com/documentation/static_files/ On Feb 10, 1:05 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi folks, > > I am a bit of a newbie when it come

404 Error - Can't link to my css or image files from a template.

2007-02-10 Thread [EMAIL PROTECTED]
Hi folks, I am a bit of a newbie when it comes to Django so I apologize in advance. I know this is something simple I'm doing wrong but after hours of reading articles on the Django site and searching for answers I've had enough. I decided to bite the bullet and just ask :-) My problem is I went

Re: ForeignKey, null, and schema evolution

2007-02-10 Thread David Abrahams
"yary" <[EMAIL PROTECTED]> writes: > IIRC, Django's admin can't handle a field with null=True and > blank=False (which is a bit of a shame...) Try adding blank=True to > your model's field? Read my latest post and you'll see that I have tried that. It works, but only if I explicitly specify the

Re: ForeignKey, null, and schema evolution

2007-02-10 Thread yary
IIRC, Django's admin can't handle a field with null=True and blank=False (which is a bit of a shame...) Try adding blank=True to your model's field? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" gro

Subclassing models

2007-02-10 Thread Zach Seifts
I have been working on a project where I need to create a few classes in the model that are very similar. What I want to do is subclass a model but have it not set up a database table. I know there are ways of doing this I just haven't figured out yet. Here's an example of what I am trying to do

NEW MONEY NETWORK AGLOCO

2007-02-10 Thread efendy
Hi ... I recently joined AGLOCO because of a friend recommended it to me. I am now promoting it to you because I like the idea and I want you to share in what I think will be an exciting new Internet concept. Sign in : http://www.agloco.com/r/BBBV9253 AGLOCO's story is simple: Do you realize

Re: how to set the choices of Select Widget by code in the newforms

2007-02-10 Thread Cathy Young
On Feb 10, 5:33 pm, "canen" <[EMAIL PROTECTED]> wrote: > If I understand what you are asking, choices can be set to a function, > as long as it returns the correct format. If you return a generator I > think there is a bug that will only call it the first time the form > is rendered (e.g. if ther

Re: DB API - dict of emails

2007-02-10 Thread Dirk Eschler
On Samstag, 10. Februar 2007, Ned Batchelder wrote: > But is is simple to convert what you have into what you want: > > l = > User.objects.filter(username__in=['foo','bar']).values('username', 'email') > emails = dict([(d['username'], d['email']) for d in l]) > > It would be a little simpl

Re: ForeignKey, null, and schema evolution

2007-02-10 Thread David Abrahams
David Abrahams <[EMAIL PROTECTED]> writes: > My models.py is enclosed. It doesn't have any special dependencies. > Would you mind trying to reproduce the problem? > >> Try creating a smaller project with a trimmed >> down model -- doing the standard "remove stuff until it starts working >> or you

Re: Use of post_save on newly created objects

2007-02-10 Thread daev
I've write in my project: def create_profile_for_user(sender, instance, signal, *args, **kwargs): try: User.objects.get(id=instance._get_pk_val()) except (User.DoesNotExist, AssertionError): profile = Profile( user = instance ) profile.save() dispatcher.connect(cr

Re: are the Installed apps settings necessary?

2007-02-10 Thread daev
On Feb 10, 8:41 pm, "canen" <[EMAIL PROTECTED]> wrote: > You don't need INSTALLED_APPS for views, it's more for models if I am > not mistaken, for example, syncdb won't work if your app is not in > INSTALLED_APPS. Yes. Its true --~--~-~--~~~---~--~~ You received t

Re: Using __str__ with DateField

2007-02-10 Thread Andrew Diederich
On 2/10/07, Adrian Holovaty <[EMAIL PROTECTED]> wrote: > > On 2/10/07, Andrew Diederich <[EMAIL PROTECTED]> wrote: > > Is there an easy way to munge the return self.end_date into a string? > > This is a Python requirement -- __str__() methods must return a > string. To fix the problem, wrap self.e

Authenticate during middleware call

2007-02-10 Thread Mike H
Hi all, I am putting together a system where logging in and out is triggered by calls from a seperate application. The other application posts a username and a session id to my application, and sets a cookie so that when the user visits my site, my app sees the cookie, looks up which username i

Re: Using __str__ with DateField

2007-02-10 Thread Adrian Holovaty
On 2/10/07, Andrew Diederich <[EMAIL PROTECTED]> wrote: > Is there an easy way to munge the return self.end_date into a string? This is a Python requirement -- __str__() methods must return a string. To fix the problem, wrap self.end_date in str(), like so: return str(self.end_date) Adrian

Using __str__ with DateField

2007-02-10 Thread Andrew Diederich
I'm setting up a simple timecard app as a django proof-of-concept. One of my models is "Period" that specifies the end-date of the time period (usually a Friday). I'm not getting __repr__ right. Trying to add a period in the admin side: TypeError at /admin/timekeeper/period/add/ __str__ returne

Re: are the Installed apps settings necessary?

2007-02-10 Thread canen
You don't need INSTALLED_APPS for views, it's more for models if I am not mistaken, for example, syncdb won't work if your app is not in INSTALLED_APPS. voltron wrote: > I posted this yesterday, but It did not show up, strange. > > According to the manual, one has to add apps to the INSTALLED_APP

Re: ForeignKey, null, and schema evolution

2007-02-10 Thread David Abrahams
Malcolm Tredinnick <[EMAIL PROTECTED]> writes: > On Sat, 2007-02-10 at 03:34 -0500, David Abrahams wrote: >> >> In my attempt to use >> >>ForeignKey(Track, null=True) >> >> When I actually tried to use a null Track value, I got: > [...traceback snipped...] >> >> ProgrammingError at /

Re: how to set the choices of Select Widget by code in the newforms

2007-02-10 Thread daev
On Feb 10, 8:07 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > how? In my project i have that code: #in some view form_class = AddPostForm #form adds post to the blog form_class.base_fields[ 'category' ].choices = getCategoriesTuple( request.blog ) #sets choices to ChoiceField --~--~-

Re: how to set the choices of Select Widget by code in the newforms

2007-02-10 Thread canen
If I understand what you are asking, choices can be set to a function, as long as it returns the correct format. If you return a generator I think there is a bug that will only call it the first time the form is rendered (e.g. if there is an error in the form the choices won't show up when it ren

Re: how to make a list of allowable arguments for filter()

2007-02-10 Thread abe
On Feb 10, 8:12 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Fri, 2007-02-09 at 23:22 -0800, abe wrote: > > > > I really tried hard to understand your problem, but then my brain > > > started to leak out of my ears and I had to stop. :-( [...] > > 'model1__model2__field_of_model2' > >

how to set the choices of Select Widget by code in the newforms

2007-02-10 Thread [EMAIL PROTECTED]
how? --~--~-~--~~~---~--~~ 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

Re: Installed apps settings, necessary?

2007-02-10 Thread James Bennett
On 2/9/07, voltron <[EMAIL PROTECTED]> wrote: > what are the advantages of adding the apps to the settings file? Several things: * If an app is never listed in INSTALLED_APPS, syncdb will never see it and so will never install DB tables for its models. * If an app is never listed in INSTALLED_AP

Re: Filtering foreign items in admin

2007-02-10 Thread Rob Hudson
Take a look at "limit_choices_to" in the model api docs and see if that will do what you need. On Feb 9, 4:27 am, "Rob Slotboom" <[EMAIL PROTECTED]> wrote: > For a several models I use a FK to photos. The drop down in admin to > choose from lists all photos. > Can this list be filtered so I can r

Re: custom validator or other way to avoid double bed bookings

2007-02-10 Thread Nebojša Đorđević
On Feb 9, 2007, at 09:32 , Benedict Verheyen wrote: > my app is used to manage patients of a ward in a hospital. > This ward has a number of beds available. > A patient has a room id referring to the room/bed where he's laying. > > Now i would want to avoid being able to select a bed that is >

Doing "in" subqueries on the server-side

2007-02-10 Thread Tim Chase
For an app I've been assembling, I need to filter a particular data-set based on multiple many-to-many criteria where the criteria span multiple records in the far participant of the M2M. The basics are the recordset (Items) and each Item has a M2M relationship with Properties (a key/value pair)

Re: new forms - problem populating with data from a table

2007-02-10 Thread Honza Král
On 2/10/07, Lawrence Oluyede <[EMAIL PROTECTED]> wrote: > > > I now want to take an existing user record and create an edit account > > form, where the data entered by the user in the registration form is > > represented and available to edit. Seemed simple when I set out to do > > it, but I can't

Re: new forms - problem populating with data from a table

2007-02-10 Thread Honza Král
On 2/10/07, daev <[EMAIL PROTECTED]> wrote: > > On Feb 9, 10:12 pm, "Tipan" <[EMAIL PROTECTED]> wrote: > > > else: > > form=UserAccountForm() > > return render_to_response('account.html',{'form':form}) > somthing like this: > form = UserAccountForm( u

Re: new forms - problem populating with data from a table

2007-02-10 Thread daev
On Feb 9, 10:12 pm, "Tipan" <[EMAIL PROTECTED]> wrote: > else: > form=UserAccountForm() > return render_to_response('account.html',{'form':form}) somthing like this: form = UserAccountForm( user.__dict__ ) --~--~-~--~~~

Re: Use of post_save on newly created objects

2007-02-10 Thread Benjamin Slavin
On 2/9/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > Using the signal system might be overkill here. Can you achieve whatever > you want with your own save() method (remember that you can then call > the model's default save() method after doing your own stuff)? > Malcom, Thanks for the

Re: DB API - dict of emails

2007-02-10 Thread Ned Batchelder
But is is simple to convert what you have into what you want: l = User.objects.filter(username__in=['foo','bar']).values('username', 'email') emails = dict([(d['username'], d['email']) for d in l]) It would be a little simpler like this: emails = dict([(r.username, r.email) for r in

Re: image response from Httpresponse

2007-02-10 Thread Ned Batchelder
You want something like this: image = Image.open('/home/www-data/html/picture_lib/0002/0002.jpg') response = HttpResponse(mimetype='image/jpeg') image.save(response, "JPEG") return response() The response object is file-like, you can write your content data to it,

Re: Running django with stackless

2007-02-10 Thread James Tauber
Is your mention of webpy everywhere instead of Django a cut-and-paste error? Are you really asking about django or about webpy? On 10/02/2007, at 7:30 AM, krypton wrote: > > Guys I m using threads to use concurrecy in my webapps and I find it > to be needlessly slow, because most of the stuff

Re: Installed apps settings, necessary?

2007-02-10 Thread James Tauber
They need to be in INSTALLED_APPS for syncdb to pick up the models and make any necessary additions to the database. There may be other uses as well (contrib.admin might use it too, for example) but I'm not sure. James On 09/02/2007, at 11:23 AM, voltron wrote: > > Hi all, going bto instal

image response from Httpresponse

2007-02-10 Thread Lasse Borchard
Hi all, one simple quest, but i dont find anything at google... Ive an image gallery and i dont want to store the images in my "static" (handler none) directory, because to view the image it is necesaary to be logged in. Therefore django must serve the images. But i'm sadly still a newbie. I t

Re: DB API - dict of emails

2007-02-10 Thread Dirk Eschler
On Samstag, 10. Februar 2007, Malcolm Tredinnick wrote: > Hi Dirk, > > On Sat, 2007-02-10 at 12:02 +0100, Dirk Eschler wrote: > > Hello, > > > > i'm trying to get a dict of emails with usernames as keys. > > > > User.objects.filter(username__in=['foo', 'bar']).values('username', > > 'email') > > >

Re: DB API - dict of emails

2007-02-10 Thread Malcolm Tredinnick
Hi Dirk, On Sat, 2007-02-10 at 12:02 +0100, Dirk Eschler wrote: > Hello, > > i'm trying to get a dict of emails with usernames as keys. > > User.objects.filter(username__in=['foo', 'bar']).values('username', 'email') > > The above returns a list of dicts: > [{'username': 'foo', 'email': '[EMAI

DB API - dict of emails

2007-02-10 Thread Dirk Eschler
Hello, i'm trying to get a dict of emails with usernames as keys. User.objects.filter(username__in=['foo', 'bar']).values('username', 'email') The above returns a list of dicts: [{'username': 'foo', 'email': '[EMAIL PROTECTED]'}, {'username': 'bar', 'email': '[EMAIL PROTECTED]'}] Is it possib

Re: new forms - problem populating with data from a table

2007-02-10 Thread Lawrence Oluyede
> I now want to take an existing user record and create an edit account > form, where the data entered by the user in the registration form is > represented and available to edit. Seemed simple when I set out to do > it, but I can't seem to populate the form. It's pretty easy. You provide a page

Re: ForeignKey, null, and schema evolution

2007-02-10 Thread Malcolm Tredinnick
On Sat, 2007-02-10 at 03:34 -0500, David Abrahams wrote: > > In my attempt to use > >ForeignKey(Track, null=True) > > When I actually tried to use a null Track value, I got: [...traceback snipped...] > > ProgrammingError at /admin/program/session/15/ > ERROR: invalid input syntax

ForeignKey, null, and schema evolution

2007-02-10 Thread David Abrahams
In my attempt to use ForeignKey(Track, null=True) When I actually tried to use a null Track value, I got: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 77. response = callback(request, *callback_args, **cal

Re: how to make a list of allowable arguments for filter()

2007-02-10 Thread Malcolm Tredinnick
On Fri, 2007-02-09 at 23:22 -0800, abe wrote: > > > > I really tried hard to understand your problem, but then my brain > > started to leak out of my ears and I had to stop. :-( > > > > Could you post an example of how all these models are related? You seem > > to have Relmodl2, model2 and model1