Re: Advice on project structure

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 22:59 -0800, Matt Doran wrote: [...] > The whole > "startproject" thing and the default layout feels like it's forcing me > to make decisions that I'm not ready to (i.e. it's on page 1 of the > tutorial). Hmmm. "startproject" doesn't require you to make any decisions at

Re: Advice on project structure

2009-03-07 Thread Matt Doran
Hi Malcolm, Thanks for the very detailed (and well thought-out) response! Greatly appreciated. On Mar 8, 4:57 pm, Malcolm Tredinnick wrote: > On Sat, 2009-03-07 at 21:29 -0800, Matt Doran wrote: > > > Is there a recommended best-practice approach to this type of > >

Advice on project structure

2009-03-07 Thread Matt Doran
Hi there, I'm an experienced developer, but new to Django. I've experimented with Django over the years, but I'm now in the process of planning a medium sized Django app. We have an in-house support/email system written in python, but it needs an overhaul. :) The application will become a

IntegrityError: columns app_label, model are not unique

2009-03-07 Thread He Jibo
Dear All, I ran into the following error of "IntegrityError: columns app_label, model are not unique" when I tried to Sync the data to the db with the command of "manage.py syncdb". I am using python2.5, Django-1.0.2-final, and Window XP. Could anyone be kindly to tell me how to solve this

Re: Trouble passing keyword arg to post_save signal

2009-03-07 Thread Jacob Kaplan-Moss
On Sat, Mar 7, 2009 at 11:14 PM, Brandon Taylor wrote: > When I attempt to pass a keyword arg to it: > > models.signals.post_save.connect(scrub_directory, sender=TheModel, > {'my_kwarg' : 'some_value'}) > > I get a syntax error: keyword argument appeared after a

Re: Django an STI

2009-03-07 Thread Vitaly Babiy
Thanks Malcolm for the response, I am only really instressed in the last part: The "complex" thing that we might do, one day, is providing a way to also retrieve all the descendents from a base table. It won't be particularly efficient, but that's because SQL is relational and not

Trouble passing keyword arg to post_save signal

2009-03-07 Thread Brandon Taylor
Hi everyone, Syntax trouble. My post_save signal is defined as: def scrub_directory(sender, instance, **kwargs): pass When I attempt to pass a keyword arg to it: models.signals.post_save.connect(scrub_directory, sender=TheModel, {'my_kwarg' : 'some_value'}) I get a syntax error: keyword

Re: variable attributes in templates

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 18:54 -0800, only wrote: > Is it possible to use variable attributes in templates, something like > the following (which does not work of course), where form is a > dictionary and attribs is a list of attribute strings? > > {% for attrib in attribs %} > {{attrib}}:

variable attributes in templates

2009-03-07 Thread only
Is it possible to use variable attributes in templates, something like the following (which does not work of course), where form is a dictionary and attribs is a list of attribute strings? {% for attrib in attribs %} {{attrib}}: {{form}}.{{attrib}} {% endfor %}

Re: Users suddenly becoming inactive?

2009-03-07 Thread jeff
Figured it out. I had a model form that included is_active as a field, but that field was not being displayed in the form for regular users. It was evidently unsetting the value. On Mar 7, 5:08 pm, Malcolm Tredinnick wrote: > On Sat, 2009-03-07 at 10:12 -0800, jeff

Re: Inserting Into Cleaned_Data Inside a ModelForm

2009-03-07 Thread Chris Spencer
> Now, I cant remember but I believe that if you add missing key data in > cleaned method, giving the name django would expect, you would be able > to just save the form. You could also just manually access the key > field from the cleaned_data and apply it on the model. Unfortunately, this

Re: How are request.session assignments persisted?

2009-03-07 Thread Rex
On Mar 7, 5:12 pm, Malcolm Tredinnick wrote: > Sure, "request" is a local variable, but since Python uses > pass-by-reference, it is a reference to an object that is also > referenced by other variables in other scopes (including the session > middleware). > > So by

Re: Meta, order_with_respect_to for recursive relation

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 16:37 -0800, NicoEchániz wrote: > Hi, > > I have a model with a recursive relation: > > class Category(models.Model): > name = models.CharField(max_length=100, blank=False, > db_index=True) > parent_category = models.ForeignKey('self', >

Re: How are request.session assignments persisted?

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 13:42 -0800, Rex wrote: > I'm reading the documentation on sessions (http:// > docs.djangoproject.com/en/dev/topics/http/sessions/?from=olddocs) and > saw the following example: > > def post_comment(request, new_comment): > if request.session.get('has_commented',

Re: Users suddenly becoming inactive?

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 10:12 -0800, jeff wrote: > I'm finding random instances in my application where a new user > registers or an existing user changes their password and then can't > log in the next time because their account is no longer active. It > doesn't happen consistently, which is

Re: Read Only Form Field

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 08:29 -0800, Chris wrote: [..] > Others have posted similar questions in this forum, but it doesn't > look like anyone's found a good solution to this problem. There have been plenty of reasonable solutions posted to the forum. It's close to trivial to write a class to

Re: Django an STI

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 06:50 -0600, Tim Chase wrote: [...] > A slightly less DRY solution than ideal (ideal=solving the VERY > complex STI problem in Django's ORM), Um .. no. That's the one thing that is almost certainly not going to happen. Single-table inheritance --- a.k.a shoving all your

Meta, order_with_respect_to for recursive relation

2009-03-07 Thread NicoEchániz
Hi, I have a model with a recursive relation: class Category(models.Model): name = models.CharField(max_length=100, blank=False, db_index=True) parent_category = models.ForeignKey('self', related_name='child_categories', blank=True, null=True) And I want it's members to be ordered with

Re: I can't decide on a migration framework

2009-03-07 Thread Briel
A fixed migration is the code run to get from one step to another. Migrations uses the, maybe at some point you needed to add an extra table to the db. Then you could write a migration that would add the table if you wanted to progress or delete the table if you wanted to get back. You would have

Re: Inserting Into Cleaned_Data Inside a ModelForm

2009-03-07 Thread Briel
When using a modelform there are some ways to get you where you want. You can get your form using request.POST. If it validates you can save it like this creating a model. record = form.save(commit=false) record.key = 123 record.save() Now, I cant remember but I believe that if you add missing

I can't decide on a migration framework

2009-03-07 Thread Ben Davis
I've been looking into both the "South" and "django-evolution" migration frameworks. There are things I like about both of them, although I'm leaning towards django-evolution. The thing I like about django-evolution is that migrations are described in the same "language" as your model, that

Re: Best practice for a site-wide form (ie: search)?

2009-03-07 Thread Alex Gaynor
On Sat, Mar 7, 2009 at 4:29 PM, luell.m...@gmail.com wrote: > > What variable? The search term? > > So your search view gets the query and does the actual search, then > stuffs results and search_term (or something) into the context, and > passes search_term into the

Re: Best practice for a site-wide form (ie: search)?

2009-03-07 Thread luell.m...@gmail.com
What variable? The search term? So your search view gets the query and does the actual search, then stuffs results and search_term (or something) into the context, and passes search_term into the template tag? Making sure I got it, that does sound better. Thanks. On Mar 7, 4:25 pm, Alex

Re: Best practice for a site-wide form (ie: search)?

2009-03-07 Thread Alex Gaynor
On Sat, Mar 7, 2009 at 4:03 PM, luell.m...@gmail.com wrote: > > What's the best way to include a form in every page, such as a search > form in the header? > > You could stuff a blank form in with a context processor, and override > that variable in the actual search view so

Best practice for a site-wide form (ie: search)?

2009-03-07 Thread luell.m...@gmail.com
What's the best way to include a form in every page, such as a search form in the header? You could stuff a blank form in with a context processor, and override that variable in the actual search view so you can fill in the term that searched for. Or do people prefer a template tag? Or

Re: How are request.session assignments persisted?

2009-03-07 Thread Daniel Roseman
On Mar 7, 9:42 pm, Rex wrote: > I'm reading the documentation on sessions (http:// > docs.djangoproject.com/en/dev/topics/http/sessions/?from=olddocs) and > saw the following example: > > def post_comment(request, new_comment): >     if

Re: URL Calls

2009-03-07 Thread Daniel Roseman
On Mar 7, 7:59 pm, timlash wrote: > I see.  Thanks. > > I've been using render_to_response() without difficulties.  Under what > conditions should I use reverse() vs. render_to_response()?  Can they > be used interchangeably? > > Thanks again, > > Tim > Eh? They do completely

How are request.session assignments persisted?

2009-03-07 Thread Rex
I'm reading the documentation on sessions (http:// docs.djangoproject.com/en/dev/topics/http/sessions/?from=olddocs) and saw the following example: def post_comment(request, new_comment): if request.session.get('has_commented', False): return HttpResponse("You've already commented.")

Re: Compressed fixtures?

2009-03-07 Thread Alex Gaynor
On Sat, Mar 7, 2009 at 3:08 PM, Karen Tracey wrote: > On Sat, Mar 7, 2009 at 11:17 AM, Ben Davis wrote: > >> Ahh. Searching for "compressed fixtures" on djangoproject.com under the >> "1.0" documentation option reveals the following page: >>

Re: get_object_or_404 and foreignkey

2009-03-07 Thread Daniel Roseman
On Mar 7, 8:21 pm, Jamie Pittock wrote: > Thanks Daniel.  Yeah it's just a way of getting the county so I'll try > your second option.  Could you possibly point me to the docs that > explain the double underscore? It's the standard syntax for lookups across relationships.

Re: Compressed fixtures?

2009-03-07 Thread Karen Tracey
On Sat, Mar 7, 2009 at 11:17 AM, Ben Davis wrote: > Ahh. Searching for "compressed fixtures" on djangoproject.com under the > "1.0" documentation option reveals the following page: > http://docs.djangoproject.com/en/dev/ref/django-admin/?from=olddocs > > That page has the

Re: TemplateSyntaxError on unicode strings

2009-03-07 Thread Karen Tracey
On Sat, Mar 7, 2009 at 3:07 PM, juanefren wrote: > > I am using django 1.1 and MYSQL 5.0 with collation utf8_unicode_ci > Django 1.1 doesn't exist yet, so I guess you are either running 1.1 alpha1 or an SVN trunk checkout. I doubt the specific version really matters here

Re: Use django.contrib.auth.login at root of site

2009-03-07 Thread Alex Gaynor
On Sat, Mar 7, 2009 at 1:59 PM, jmat wrote: > > I'm trying to figure out a way to use the django.contrib.auth tools at > the root of the site for login but I'm running into one issue (I know > I can write my own viewbut not trying not to do that here). > > So I have

Re: get_object_or_404 and foreignkey

2009-03-07 Thread Jamie Pittock
Thanks Daniel. Yeah it's just a way of getting the county so I'll try your second option. Could you possibly point me to the docs that explain the double underscore? On Mar 7, 7:39 pm, Daniel Roseman wrote: > On Mar 7, 5:42 pm, Jamie Pittock

TemplateSyntaxError on unicode strings

2009-03-07 Thread juanefren
I am using django 1.1 and MYSQL 5.0 with collation utf8_unicode_ci I have no problems storing unicode strings to database, but when I try to render a template using any of these chars ñáéíóúÑÁÉÍÓÚ from database, it throws a TemplateSyntaxError, what should I do ?

Use django.contrib.auth.login at root of site

2009-03-07 Thread jmat
I'm trying to figure out a way to use the django.contrib.auth tools at the root of the site for login but I'm running into one issue (I know I can write my own viewbut not trying not to do that here). So I have this in my urls.py (r'^$', login, {'template_name':'login_base.html'}), so

Re: URL Calls

2009-03-07 Thread timlash
I see. Thanks. I've been using render_to_response() without difficulties. Under what conditions should I use reverse() vs. render_to_response()? Can they be used interchangeably? Thanks again, Tim On Mar 7, 2:37 pm, Daniel Roseman wrote: > On Mar 7, 4:27 pm,

Re: get_object_or_404 and foreignkey

2009-03-07 Thread Daniel Roseman
On Mar 7, 5:42 pm, Jamie Pittock wrote: > Hi, > > I have an app with countries and counties.  The simplified model is: > > class Country(models.Model): >         name = models.CharField(max_length=50) >         slug = models.SlugField() > >         def __unicode__(self): >  

Re: URL Calls

2009-03-07 Thread Daniel Roseman
On Mar 7, 4:27 pm, timlash wrote: > I've read the doc several times but am still confused by the way > Django references URLs.  I'm running Python 2.4 and Django 1.0.2 on my > Debian Etch box. > > My urls.py reads: > >    from django.conf.urls.defaults import * >    from

Users suddenly becoming inactive?

2009-03-07 Thread jeff
I'm finding random instances in my application where a new user registers or an existing user changes their password and then can't log in the next time because their account is no longer active. It doesn't happen consistently, which is driving me crazy. I am not using the authentication views

Re: get_object_or_404 and foreignkey

2009-03-07 Thread Jamie Pittock
Sorry, the correct url would be domain.com/country/county/ On Mar 7, 5:42 pm, Jamie Pittock wrote: > Hi, > > I have an app with countries and counties.  The simplified model is: > > class Country(models.Model): >         name = models.CharField(max_length=50) >         slug

get_object_or_404 and foreignkey

2009-03-07 Thread Jamie Pittock
Hi, I have an app with countries and counties. The simplified model is: class Country(models.Model): name = models.CharField(max_length=50) slug = models.SlugField() def __unicode__(self): return self.name class County(models.Model): name =

Re: Inserting Into Cleaned_Data Inside a ModelForm

2009-03-07 Thread Chris Spencer
On Fri, Mar 6, 2009 at 12:57 PM, rajeesh wrote: > > You may change the save_model() method of corresponding AdminClass for > that: > e.g, to set the attribute 'a' of model 'Book' , write inside > BookAdmin.save_model() something like this: > > obj.a =

Read Only Form Field

2009-03-07 Thread Chris
Is it possible to include a field in a ModelForm, and display it with its default widget, but include the readonly="1" attribute so it's not editable? I don't want to make the corresponding Model field not editable, and I don't want to reinvent all the default widgets just to add the readonly

URL Calls

2009-03-07 Thread timlash
I've read the doc several times but am still confused by the way Django references URLs. I'm running Python 2.4 and Django 1.0.2 on my Debian Etch box. My urls.py reads: from django.conf.urls.defaults import * from django.conf import settings urlpatterns =

Re: Compressed fixtures?

2009-03-07 Thread Ben Davis
Ahh. Searching for "compressed fixtures" on djangoproject.com under the "1.0" documentation option reveals the following page: http://docs.djangoproject.com/en/dev/ref/django-admin/?from=olddocs That page has the "1.0 Docs" label, so I'm guessing this is an error in the documentation? Is there

Re: Programmtically accessing properties on a model field?

2009-03-07 Thread Brandon Taylor
Wonderful! Thank you so much for the help. Brandon On Mar 6, 3:24 pm, Rajesh D wrote: > > I'm working on some code to scrub an images directory of anything not > > currently stored in the database, and would like to de-couple some > > things. I'm using signals, passing

Re: Django and Python Warnings

2009-03-07 Thread Jacob Kaplan-Moss
On Sat, Mar 7, 2009 at 12:50 AM, Graham Dumpleton wrote: > BTW, if there is anything else you would like to see in mod_wsgi, now > is the time to speak up as am close to point where can wrap up work on > mod_wsgi 3.0. For the sites I work on, mod_wsgi is already

Re: Upload picture -> AJAX Thumbnail -> Save in DB

2009-03-07 Thread Oni
Thats not quite what I mean. The AJAX bit is only there to get a set of co-ordinates that will be passed to PIL to do its stuff. In fact, forget Ajax for now. What i want is a multipart form in the admin section BUT the image uploaded in the first form MUST be available in the second form. One

Re: Upload picture -> AJAX Thumbnail -> Save in DB

2009-03-07 Thread Alex Gaynor
On Sat, Mar 7, 2009 at 8:22 AM, Oni wrote: > > Hi all. Im wondering about an admin modification. I've managed to > create a few ajax forms for the admin interface of django before now > but I'm what I'm really after is getting the user to upload an image. > This image is

Upload picture -> AJAX Thumbnail -> Save in DB

2009-03-07 Thread Oni
Hi all. Im wondering about an admin modification. I've managed to create a few ajax forms for the admin interface of django before now but I'm what I'm really after is getting the user to upload an image. This image is saved "somewhere" and the next page of the form comes up. This page has my

Re: Django an STI

2009-03-07 Thread Vitaly Babiy
How would generic relations solve this problem, It has been recommend for me to look at it a few times but I can't seem to understand how it would work. Vitaly Babiy On Sat, Mar 7, 2009 at 7:50 AM, Tim Chase wrote: > > >> class Tracker(models.Model): > >>

Django-Logging Problem..

2009-03-07 Thread Harish
Hi Everybody... I am trying out the Django-logging Middleware for my application. I am using Ubuntu as an OS, with Python Version 2.5 and Django Version 0.97-pre-SVN-7049. I just tried the way they specified in the following link http://code.google.com/p/django-logging/wiki/Overview This is

Re: Django an STI

2009-03-07 Thread Tim Chase
>> class Tracker(models.Model): >>notifications = models.ForeignKey(Notification) >> >> class Notification(models.Model): >> # Common fields >> pass >> >> class EmailNotification(Notification): >>pass >> >> class SmsNotification(Notification): >>pass >> >> >> # I would be able

Re: FileField - Forms - upload to not available

2009-03-07 Thread tom
Unfortunatly I still haven't found a solution and I tryed it with and without a trailing /. No difference. I will post the solution, if there is one and if I find it. :) -Tom On 5 Mrz., 16:39, Francis wrote: > Did you found any solution? > > Because I have the same

Re: Django and Python Warnings

2009-03-07 Thread Graham Dumpleton
On Mar 7, 7:29 pm, Malcolm Tredinnick wrote: > Hi Graham, > > On Fri, 2009-03-06 at 21:50 -0800, Graham Dumpleton wrote: > > [...] > > > I am still toying with whether I add a few things or not. The first of > > these is optionally enabled support in daemon mode for

Re: include file, filename itself is variable.

2009-03-07 Thread jago
Sorry. Found the problem. My bad - simple stupidity. --~--~-~--~~~---~--~~ 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

Re: include file, filename itself is variable.

2009-03-07 Thread jago
Oh, actually I tried that but when it didn't work I got creative with {% include {{ include_filename }} %} I believe my problem is somewhere else. In my main HTML file index.html I use {% include "header_viz_js.html" %} in header_viz_js.html I use {% include template_name %} Result:

Re: include file, filename itself is variable.

2009-03-07 Thread Malcolm Tredinnick
On Sat, 2009-03-07 at 00:28 -0800, jago wrote: > Hi, > > I want to include a file using {% include "header.html" %} > > However I want to be able to dynamically use different files then > "header.html" > > Obviously {% include {{ include_filename }} %} does not work. > > Can I make this work

Re: Django an STI

2009-03-07 Thread Malcolm Tredinnick
On Fri, 2009-03-06 at 22:09 -0800, Vbabiy wrote: > I know django does not support STI, Based on what follows, I guess you mean "single table inheritance", meaning all columns for all models in the same table. > but I was wondering if there is > any way I can implement this behaviour. > > Here

Re: Figuring out what has changed at save()

2009-03-07 Thread Rama Vadakattu
Keep track of a variable which tells us the action user is currently doing like "draft,publish,edit "? the first time the user does a publish you need to trigger an action. details: How to know the current action of user? --- a) 1.

Re: Figuring out what has changed at save()

2009-03-07 Thread Rama Vadakattu
Keep track of a variable which tells us the action user is currently doing like "draft,publish,edit "? the first time the user does a publish you need to trigger an action. details: How to know the current action of user? --- a) 1.

Re: Django and Python Warnings

2009-03-07 Thread Malcolm Tredinnick
Hi Graham, On Fri, 2009-03-06 at 21:50 -0800, Graham Dumpleton wrote: [...] > I am still toying with whether I add a few things or not. The first of > these is optionally enabled support in daemon mode for X-Sendfile > header where sending of file is actually performed back in main Apache >

include file, filename itself is variable.

2009-03-07 Thread jago
Hi, I want to include a file using {% include "header.html" %} However I want to be able to dynamically use different files then "header.html" Obviously {% include {{ include_filename }} %} does not work. Can I make this work somehow? --~--~-~--~~~---~--~~ You