I have some trouble with my Admin-URLs. When I set DEBUG=False (in the
settings.py) I become this error (I've changed some lines in the file
../django/core/handlers/base.py to see the error in no-debug-mode):
Using the URLconf defined in project.urls, Django tried these URL patterns, in
this order:
1.^admin/ ^$
2.^admin/ ^logout/$
3.^admin/ ^password_change/$
4.^admin/ ^password_change/done/$
5.^admin/ ^jsi18n/$
6.^admin/ ^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$
7.^admin/ ^(?P<app_label>\w+)/$
8.^admin/ ^auth/group/
9.^admin/ ^auth/user/
10.^admin/ ^sites/site/
The current URL, admin/hauptseite/beitrag/, didn't match any of these.
But when I set DEBUG=True, everything is OK and I have no errors.
(I use Django version 1.1 beta)
Thanks for your help
Stephan
I registered the models with:
admin.site.register(Beitrag, BeitragAdmin)
admin.site.register(Container, ContainerAdmin)
It works fine in debug-mode. I have problems only if debug is false.
Am Freitag, 27. März 2009 14:28:28 schrieb Karen Tracey:
Yes, both lines are in the file models.py as the last lines.> On Fri, Mar 27, 2009 at 9:19 AM, Stephan John <em...@stephanjohn.de> wrote:
> > I registered the models with:
> > admin.site.register(Beitrag, BeitragAdmin)
> > admin.site.register(Container, ContainerAdmin)
> >
> > It works fine in debug-mode. I have problems only if debug is false.
>
> And those lines are actually executed when DEBUG is False? What I'm saying
> is that the urlpatterns displayed when it is not working look like no calls
> to register have been made. I don't see anything in the admin code itself
> that is dependent on the DEBUG setting that would explain that, nor can I
> recreate the problem if I set DEBUG to False in my own app, so my first
> guess is that your code somehow doesn't actually execute those register
> lines when DEBUG is False.
>
> Karen
>
>
I've added the following lines in the file ../django/contrib/admin/sites.py
after line 87:
f = open('/tmp/error.tmp', 'w+')
f.write(str(admin_class))
f.write(str(model))
f.close()
The Output in the tmp-file is:
<class 'project.mainpage.models.ContainerAdmin'><class
'project.mainpage.models.Container'>
For me it looks ok – the model is registered.
>
> 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