decoupled url confs- can't reach admin page now

9 views
Skip to first unread message

Ross

unread,
Oct 4, 2009, 3:39:03 PM10/4/09
to Django users
I was going through the tutorial and following directions (I think)
when it instructed me to decouple the url confs near the end of part 3
of the Django Tutorial. After I did this, I was no longer able to
reach the admin page. Now, whenever I try to reach the admin, I get
this error message:

TemplateSyntaxError at /admin/

Caught an exception while rendering: Tried vote in module
mysite.player_info.views. Error was: 'module' object has no attribute
'vote'

which is weird since I am typing http://127.0.0.1:8000/admin/ as the
url and this has nothing to do with the line:

(r'^(?P<poll_id>\d+)/vote/$', 'vote'),

in the urlconf.

What might have happened?

Ross

unread,
Oct 4, 2009, 8:24:40 PM10/4/09
to Django users
FYI, my mysite/urls.py looks like this:

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^league/', include('mysite.polls.urls')),
(r'^admin/', include(admin.site.urls)),
)

and the mysite/polls/urls.py looks like this:

from django.conf.urls.defaults import *

urlpatterns = patterns('mysite.player_info.views',
(r'^$', 'index'),
(r'^(?P<poll_id>\d+)/$', 'detail'),
(r'^(?P<poll_id>\d+)/results/$', 'results'),
(r'^(?P<poll_id>\d+)/vote/$', 'vote'),
)

When I comment out the (r'^league/', include('mysite.polls.urls')),
line in mysite/urls.py, I can get to the admin page. Otherwise I
can't. Does this provide more insight into my problem?

On Oct 4, 3:39 pm, Ross <ross.j...@gmail.com> wrote:
> I was going through the tutorial and following directions (I think)
> when it instructed me to decouple the url confs near the end of part 3
> of the Django Tutorial. After I did this, I was no longer able to
> reach the admin page. Now, whenever I try to reach the admin, I get
> this error message:
>
> TemplateSyntaxError at /admin/
>
> Caught an exception while rendering: Tried vote in module
> mysite.player_info.views. Error was: 'module' object has no attribute
> 'vote'
>
> which is weird since I am typinghttp://127.0.0.1:8000/admin/as the

Karen Tracey

unread,
Oct 4, 2009, 8:51:57 PM10/4/09
to django...@googlegroups.com

Admin requires your entire URLConf be valid.  Fix the error noted in the exception, and admin will work again.  The reason why Admin requires a fully valid URLConf is because it generates links on its pages using reverse URL mapping using the url template tag or the reverse utility function (http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse).  That process iterates through the entire URLConf and any errors found will cause it to fail.

Karen

Ross

unread,
Oct 4, 2009, 9:21:11 PM10/4/09
to Django users
I'm struggling to find where the error is in my urlconf. When that
line I referenced previously is uncommented, I am able to get to the
other pages for which I have made views (which is just the home page
at the moment), but I can't access the admin. Could the problem be
that I have not written views for everything that the urlconf
references? Because I'm struggling to find an error in any of my
syntax in the urlconfs.

On Oct 4, 8:51 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Sun, Oct 4, 2009 at 3:39 PM, Ross <ross.j...@gmail.com> wrote:
>
> > I was going through the tutorial and following directions (I think)
> > when it instructed me to decouple the url confs near the end of part 3
> > of the Django Tutorial. After I did this, I was no longer able to
> > reach the admin page. Now, whenever I try to reach the admin, I get
> > this error message:
>
> > TemplateSyntaxError at /admin/
>
> > Caught an exception while rendering: Tried vote in module
> > mysite.player_info.views. Error was: 'module' object has no attribute
> > 'vote'
>
> > which is weird since I am typinghttp://127.0.0.1:8000/admin/as the

Christophe Pettus

unread,
Oct 4, 2009, 9:27:48 PM10/4/09
to django...@googlegroups.com

On Oct 4, 2009, at 6:21 PM, Ross wrote:
> Could the problem be
> that I have not written views for everything that the urlconf
> references?

Precisely. The documentation that Karen Tracey mentions discusses this:

http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse

--
-- Christophe Pettus
x...@thebuild.com

Daniel Roseman

unread,
Oct 5, 2009, 2:39:44 AM10/5/09
to Django users
On Oct 5, 2:27 am, Christophe Pettus <x...@thebuild.com> wrote:
> On Oct 4, 2009, at 6:21 PM, Ross wrote:
>
> > Could the problem be
> > that I have not written views for everything that the urlconf
> > references?
>
> Precisely.  The documentation that Karen Tracey mentions discusses this:
>
>        http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse

Yes. At the least write stub views, declaring the function but just
using 'pass' as the body.
--
DR.
Reply all
Reply to author
Forward
0 new messages