urlconf problem

26 views
Skip to first unread message

Joel Goldstick

unread,
Aug 5, 2014, 11:01:03 PM8/5/14
to django...@googlegroups.com
I have this:

from django.conf.urls import patterns, include, url

from django.contrib import admin, admindocs
import blog_app

admin.autodiscover()

patterns = patterns('',
url(r'^admin/doc/', include(admindocs.urls)),
url(r'^blog/', include(blog_app.urls)),
url(r'^admin/', include(admin.site.urls)),
)

i am using virtualenv, django 1.6

I get this error:

Exception Value:

'module' object has no attribute 'urls'

Exception Location:
/home/jcg/code/python/venvs/joelgoldstick.com.16/blog/blog/urls.py in
<module>, line 9

It worked earlier today. I think I have a typo but can't find it.

--
Joel Goldstick
http://joelgoldstick.com

Lachlan Musicman

unread,
Aug 5, 2014, 11:15:53 PM8/5/14
to django...@googlegroups.com
Make sure the blog_app is in your settings.py?
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPM-O%2ByT4kZJZmVzsLFrvsYo7qtjgzGeuNOKwx8GQERxLcV2_Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
You have to be really clever to come up with a genuinely dangerous
thought. I am disheartened that people can be clever enough to do that
and not clever enough to do the obvious thing and KEEP THEIR IDIOT
MOUTHS SHUT about it, because it is much more important to sound
intelligent when talking to your friends.
This post was STUPID.
-----------------------------------------------------------------------------------------------------------
The Most Terrifying Thought Experiment of All Time
http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html

Joel Goldstick

unread,
Aug 5, 2014, 11:45:06 PM8/5/14
to django...@googlegroups.com
On Tue, Aug 5, 2014 at 7:15 PM, Lachlan Musicman <dat...@gmail.com> wrote:
> Make sure the blog_app is in your settings.py?

It is:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog_app',
)

I'm thinking its a typo. It actually worked before some unknown small change...
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiM7LjoorbTPvoGr2TW8rnVPcw766sW61gTWokb3X6xAmQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
Joel Goldstick
http://joelgoldstick.com

Lachlan Musicman

unread,
Aug 6, 2014, 12:06:35 AM8/6/14
to django...@googlegroups.com
Bugger - I find that error when left out of the settings or the wsgi
points to the wrong settings file. Usually when I'm swapping between
envs "settings.dev" "settings.prod"

L.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPM-O%2Bx6eDNR5Uhm-R%3Dc6aS%3D8%2BtxqXuzeMCJTDxOPm9x8qk5Yg%40mail.gmail.com.

Joel Goldstick

unread,
Aug 6, 2014, 12:18:44 AM8/6/14
to django...@googlegroups.com
what's strange to me is that I can comment out each of the urls and I
get basically the same error message. When all three are gone, it
complains there are no urls. But I'm stuck on thinking I have a type.

background:
this was a 1.3 project that I converted to 1.6 today using virtualenv
to keep things clean. I'm feeling like I haven't given enough
environment info. It worked at 4pm without adding admindocs. Not
sure what I did.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiPTqyjSm%3DLrGj46d4O%2BfUb0GmhLXwUFo9aWqVSt%3DcjT7Q%40mail.gmail.com.

Erik Cederstrand

unread,
Aug 6, 2014, 7:30:53 AM8/6/14
to Django Users
Den 06/08/2014 kl. 01.00 skrev Joel Goldstick <joel.go...@gmail.com>:

> I have this:
>
> from django.conf.urls import patterns, include, url
>
> from django.contrib import admin, admindocs
> import blog_app
>
> admin.autodiscover()
>
> patterns = patterns('',
> url(r'^admin/doc/', include(admindocs.urls)),
> url(r'^blog/', include(blog_app.urls)),
> url(r'^admin/', include(admin.site.urls)),
> )
>
> i am using virtualenv, django 1.6
>
> I get this error:
>
> Exception Value:
>
> 'module' object has no attribute 'urls'
>
> Exception Location:
> /home/jcg/code/python/venvs/joelgoldstick.com.16/blog/blog/urls.py in
> <module>, line 9

You need to actually import the urls module from admindocs (and the other modules):

Either:

from django.contrib.admindocs import urls as admindocs_urls
url(r'^admin/doc/', include(admindocs_urls)),

Or:

import django.contrib.admindocs.urls
url(r'^admin/doc/', include(django.contrib.admindocs.urls)),

> It worked earlier today. I think I have a typo but can't find it.

That's what a version control system is for :-)

Erik

Collin Anderson

unread,
Aug 6, 2014, 12:22:26 PM8/6/14
to django...@googlegroups.com
shouldn't it be:

urlpatterns = patterns('',
)

And blog_app/__init__.py and blog_app/urls.py exist?

Could you include a longer traceback?

Joel Goldstick

unread,
Aug 6, 2014, 5:06:36 PM8/6/14
to django...@googlegroups.com
On Wed, Aug 6, 2014 at 8:22 AM, Collin Anderson <cmawe...@gmail.com> wrote:
> shouldn't it be:
>
> urlpatterns = patterns('',
> )
>
Thanks for catching that!

As it ended up, the problem was in the blog_app view code. When I
ported from earlier version I had to edit some things, and I had bad
code in the view that never ran, so my blog_app stuff worked, but when
admin inspects the modules, it apparently couldn't resolve something.
I fixed my view code, then admin stuff worked.

thanks all.

Put into git ;)
Reply all
Reply to author
Forward
0 new messages