views:

43

answers:

2

Hi, In my urls file I have configured the django admin application to run off the url /adminDJ/. However it doesn't run. It loads up my own admin stuff. Here is my urls.py:

 (r'^admin/add/member/$', 'astonomyStuff.attendance.views.newMember'),
 (r'^admin/add/$', 'astonomyStuff.attendance.views.addPage'), 
(r'^admin/$', 'astonomyStuff.attendance.views.adminPage'),
 (r'^adminDJ/$', include(admin.site.urls)),
 (r'^talks/$', 'astonomyStuff.attendance.views.talksIndex'),
 (r'^talks/past/$', 'astonomyStuff.attendance.views.viewAllTalks'),
 (r'^members/$', 'astonomyStuff.attendance.views.viewMembers'),
 (r'^members/(?P<member_number>[^/]+)/$', 'astonomyStuff.attendance.views.viewMember'), 
 (r'^members/(?P<member_number>[^/]+)/delete$', 'astonomyStuff.attendance.views.deleteMember'),
 (r'^admin/add/talk/$', 'astonomyStuff.attendance.views.newTalk'),
 (r'^talks/(?P<talk_title>[^/]+)/$', 'astonomyStuff.attendance.views.viewTalk'), 
 (r'^attendance/(?P<talk_title>[^/]+)/$', 'astonomyStuff.attendance.views.viewAttendance'),  
 (r'^databrowse/(.*)', databrowse.site.root),
 (r'^adminDoc/doc/', include('django.contrib.admindocs.urls')),
 (r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
 (r'^accounts/profile/$', 'astonomyStuff.attendance.views.adminPage'),
 (r'^admin/add/attendance/$', 'astonomyStuff.attendance.views.addAttendance'),
 (r'^members/(?P<member_number>[^/]+)/edit$', 'astonomyStuff.attendance.views.editMember'),
 (r'^public/talks/$', 'astonomyStuff.attendance.views.publicViewTalks')

I have rearranged the order to see if this was the problem but thats not fixed it. Must the django admin application run on /admin/?
Thanks in Advance,
Dean

EDIT: I have had the admin application working before just to let you know it only broke when i played around with the urls.

EDIT 2: Here is my complete urls.py:

from django.conf.urls.defaults import *

from astonomyStuff.attendance.models import Member
from astonomyStuff.attendance.models import Non_Member
from astonomyStuff.attendance.models import Talk
from astonomyStuff.attendance.models import Event_Attendance
from django.contrib import admin
from django.contrib import databrowse


admin.autodiscover()
admin.site.register(Member)
admin.site.register(Non_Member)
admin.site.register(Talk)
admin.site.register(Event_Attendance)   
databrowse.site.register(Member)
databrowse.site.register(Non_Member)
databrowse.site.register(Talk)
databrowse.site.register(Event_Attendance)

urlpatterns = patterns('',
# Example:
# (r'^astonomyStuff/', include('astonomyStuff.foo.urls')),

# Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
 # (r'^admin/add/member/$', 'astonomyStuff.attendance.views.newMember'),
 # (r'^admin/add/$', 'astonomyStuff.attendance.views.addPage'), 
 #     (r'^admin/$', 'astonomyStuff.attendance.views.adminPage'),
 (r'^admin/$', include(admin.site.urls)),
 (r'^talks/$', 'astonomyStuff.attendance.views.talksIndex'),
 (r'^talks/past/$', 'astonomyStuff.attendance.views.viewAllTalks'),
 (r'^members/$', 'astonomyStuff.attendance.views.viewMembers'),
 (r'^members/(?P<member_number>[^/]+)/$', 'astonomyStuff.attendance.views.viewMember'), 
 (r'^members/(?P<member_number>[^/]+)/delete$', 'astonomyStuff.attendance.views.deleteMember'),
 # (r'^admin/add/talk/$', 'astonomyStuff.attendance.views.newTalk'),
 (r'^talks/(?P<talk_title>[^/]+)/$', 'astonomyStuff.attendance.views.viewTalk'), 
 (r'^attendance/(?P<talk_title>[^/]+)/$', 'astonomyStuff.attendance.views.viewAttendance'),  
 (r'^databrowse/(.*)', databrowse.site.root),
 (r'^adminDoc/doc/', include('django.contrib.admindocs.urls')),
 (r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}),
 (r'^accounts/profile/$', 'astonomyStuff.attendance.views.adminPage'),
 # (r'^admin/add/attendance/$', 'astonomyStuff.attendance.views.addAttendance'), 
 (r'^members/(?P<member_number>[^/]+)/edit$', 'astonomyStuff.attendance.views.editMember'),
 (r'^public/talks/$', 'astonomyStuff.attendance.views.publicViewTalks'),
)
+1  A: 

Not this (r'^adminDJ/$', include(admin.site.urls)),

But this (r'^adminDJ/', include(admin.site.urls)), ##note, no $ in the regex

Remember folks, gotta check your regexes...

stevejalim
nope thats not fixed it. I had the `$` because i was trying it with and with out.
Dean
Try the Django admin regex as the first item in the urlconf
stevejalim
Nope tried it with both and even changed it back to `/admin/` and commented out my admin application still no success.
Dean
if you reverted to the original setup and it didn't work... you didn't actually revert to the original setup. Are you doing admin.autodiscover ?
stevejalim
See my edit, ive added the my urls.py file.
Dean
Why are you registering models for the admin in your urls.py rather than in an admin.py? and (r'^admin/$', include(admin.site.urls)) is wrong - the regex terminator will mean it never looks beyond 'admin/'
stevejalim
A: 

This is probably nothing but it caught my eye. From the first snippet:

(r'^admin/$', 'astonomyStuff.attendance.views.adminPage'), 
(r'^adminDJ/$', include(admin.site.urls)),

And the second snippet:

(r'^admin/$', include(admin.site.urls)),

Is this how you want it? The first snippet uses ^adminDJ/$ while the second one uses admin/$ opposite include(admin.site.urls).

Are these two files? And are the both used? In that case the first snippet could very well override the second, thereby causing your admin views to show up instead of Django's.

Manoj Govindan
Ahh no i would like it the first way yet it wasn't working with it's original settings. Thats why i posted the whole file.
Dean