Saturday, February 27, 2016

Re: errors while trying to add extra context (detailview, __getitem__)



On Fri, Feb 26, 2016 at 6:04 PM, Malik Rumi <malik.a.rumi@gmail.com> wrote:
JAMES wrote:  >>> Can you post the entire section for your urls.py, as well as the entire traceback? Nothing is immediately jumping out at me. Do you get this error when you start the Django server, or when you visit the page that matches this URL?

This error comes when I try to start the server.

I am starting the traceback here because at first I had it as a free standing module and not inside views.py, but i thought they said a view is a callable and so can be anywhere and be named anything?

 File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 14, in <module>
    url(r'code/', CodeDetail.as_view(template_name='code_family_detail')),
AttributeError: 'module' object has no attribute 'as_view'

Why? It is clearly subclassed from list view. I got it straight from the docs


Then I put it in views.py. Now I see an unhandled exception, but I don't know what it means or what to do about it.

 File "/home/malikarumi/Projects/cannon/jamf/essell/urls.py", line 9, in <module>
    from essell.views import CodeDetail
ImportError: cannot import name CodeDetail
Unhandled exception in thread started by <function wrapper at 0x7f85a2b7e230>

Did you catch the ImportError here? Everything else is going to tumble until that gets fixed. 

I noticed that you use both CodeDetail and CodeDetailView. Near as I can tell, they are both supposed to be the same (or one was created as part of the troubleshooting process here). 

I would highly, highly recommend that you standardize on one or the other (my preference is the latter). It seems like you may be dealing with two different views and getting the names crossed.

-James

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciV5HiWBwsoHQB_2qgxhPBoa5RNJUJWK_PhY3J-Br2ZSAA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment