Am Freitag, 27. März 2009 21:05:09 schrieb Karen Tracey:
> On Fri, Mar 27, 2009 at 9:44 AM, Stephan John <em...@stephanjohn.de> wrote:
>
> Your calls to admin.site.register should not be in your models.py file.
> They should be in a file named admin.py and a call to admin.autodiscover()
> ought to be included in your urls.py, as described here:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/
>
> If you put the calls in models.py first it is intdeterminate when that file
> will be loaded, so unpredictable when the registrations will happen.  I'd
> guess when you run with DEBUG set to True your models.py hapens to be
> loaded early on, but not when you run with DEBUG=False.  Another problem
> with register calls in models.py is that if/when models.py file is imported
> multiple times, you will get AlreadyRegistered exceptions on the register
> calls, since the models were registered the first time models.py was
> loaded.
>
> Placing the registrations in admin.py and calling admin.autodiscover() from
> urls.py ensures that the admin registrations happen only once, at a
> predictable time.
>

>
> I can't explain that, but as a first step I'd change your setup to match
> standard practice.  Having admin registrations in models.py is just asking
> for trouble.
>
> Karen


YES! :-) That's it. With the registration in the file admin.py it works ok.
Thanks a lot!

Stephan


--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to