I have a custom urls.py file in myapp directory. The main url points
to the one in myapp. I don't have any trouble getting any of my own
custom views working. However, when I try to access the change
password view I keep getting a view does not exist. I'm not sure why
this is happening.
Here is what I have:
main urls.py
urlpatterns = patterns('',
url(r'^myapp/',include('myapp.urls')),
)
In the myapp folder in urls.py I have a bunch of views like this:
urlpatterns = patterns('',
url(r'^accounts/login/$', 'django.contrib.auth.views.login'),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout'),
url(r'^accounts/out/in/$', 'django.contrib.auth.views.logout_then_login'),
url(r'^accounts/password/change/$',
'django.contrib.auth.views.password_change'),
url(r'^index/?','hcp.views.index'),
)
Attempting to access the following link works perfectly:
http://localhost:8000/myapp/accounts/login/?next=/myapp/home
However, attempting to access any of the other built-in-views, such as:
http://localhost:8000/myapp/accounts/password/change/
renders a ViewDoesNotExist error when logged in as the user.......
I've followed the directions on the django site and created the
registration/password_change_form.html file in my templates directory
right next to my login.html file.
I'm not sure what I can do, I've been struggling with getting these
views to work for most of the day again today.
When I try to access the logout_then_login via the following link:
http://localhost:8000/myapp/accounts/out/in
everything works perfectly.
What could be some possible issues causing this problem? Thanks.
--
Scott
Anyone have any ideas? Thanks.
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
--
Scott A. Macri
www.ScottMacri.com
(571) 234-1581
First, from the manage.py shell, can you import your view's module, and can
you reference your view function (or class) off of the name of your import?
Run type on it, and otherwise inspect it. Call it from pdb.run() (you have
to put the expression that calls the view in quotes, since pdb.run() wants
a string). I've had trouble doing this lately: you may need to define a
function at the command line that calls pdb.set_trace() and then calls the
view, then simply call the new def (that is, no pdb.run()). You will have to
supply the correct number of arguments for the view, but they can all be
None, since the point is to see if you can single step into the first real
code of the function. Actually, you may have to dummy something that
looks like a request if your view function is decorated, since the decorators
are highly likely to need something or other from the decorator.
The other approach is to stick a pdb.set_trace() in the code that parses
the request path through your urlconf, and, while in the development
server, make the corresponding request, either with your browser, or
with a separate python program (makes it easy to POST without having
to get the form first -- You can also use curl for this, but reading the
man page takes me longer than calling urlib2.urlopen, so I thing of
python first). See if what it finds is your view function or not.
Also, urlconf is sometimes built early (some module calls reverse() at
top level, so the urlconf is built before reverse returns). So you may
want to look at how it's being constructed, by finding the right place
for a set_trace() in that code.
I'd also grep the sources to see who can raise ViewDoesNotExist.
It's not a primitive error, so it must be defined and raised within
the Django sources somewhere. That might give you a hint, or
give you a finer grained place to put a set_trace() and look at the
local variable there and on up the stack.
I tend to run things I expect to call set_trace() from an emacs
sub-shell window, since python-mode recognizes the pdb print
outs and puts up the corresponding file with a pointer on the
current line. Perhaps your favorite IDE has a similar capability.
It makes single stepping along and knowing the context (and
thus what variables are interesting) a lot more pleasant than
just looking at the pdb output yourself.
Bill
>>> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
>>> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Django users" group.
>> To post to this group, send email to django...@googlegroups.com.
>> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
>> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Scott A. Macri
> www.ScottMacri.com
> (571) 234-1581
If I call /accounts/password_reset/ I get the following error:
Request Method: GET
Request URL: http://localhost:8000/myapp/accounts/password_reset/
Django Version: 1.3.1
Exception Type: ViewDoesNotExist
Exception Value:
Tried logout_user in module myapp.views. Error was: 'module' object
has no attribute 'logout_user'
Exception Location: /Library/Python/2.6/site-packages/django/core/urlresolvers.py
in _get_callback, line 170
Python Executable: /usr/bin/python
Python Version: 2.6.1
Here is my current url setting:
url(r'^accounts/password_reset/$',
'django.contrib.auth.views.password_reset', name='password_reset'),
It's not even seeing password_reset. I've even tried importing it and
replacting the url with password_reset.
from django.contrib.auth import password_reset
url(r'^accounts/password_reset/$',password_reset, name='password_reset'),
I'm not sure where the logout_user nonsense is coming from. I only
have one url pointing to password_reset. I get the same exact error
for the password change view. I finally got fed up and wrote my own
password change functionality, but would rather use the built in
stuff. Especially for the reset pwd.
>> >>> django-users...@googlegroups.com.
>> >>> For more options, visit this group at
>> >>> http://groups.google.com/group/django-users?hl=en.
>> >>>
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups "Django users" group.
>> >> To post to this group, send email to django...@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> >
>> >
>> > --
>> > Scott A. Macri
>> > www.ScottMacri.com
>> > (571) 234-1581
>>
>> --
>> Scott A. Macri
>> www.ScottMacri.com
>> (571) 234-1581
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/dSOpzDqSvHYJ.
>
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
Caught ViewDoesNotExist while rendering: Tried logout_user in module
hcp.views. Error was: 'module' object has no attribute 'logout_user'
Request Method: GET
Request URL: http://localhost:8000/myapp/admin/
Django Version: 1.3.1
Exception Type: TemplateSyntaxError
Exception Value:
Caught ViewDoesNotExist while rendering: Tried logout_user in module
myapp.views. Error was: 'module' object has no attribute 'logout_user'
Exception Location: /Library/Python/2.6/site-packages/django/core/urlresolvers.py
in _get_callback, line 170
Python Executable: /usr/bin/python
Python Version: 2.6.1
Exception Type: ViewDoesNotExist
Exception Value:Tried logout_user in module myapp.views. Error was: 'module' object has no attribute 'logout_user'
Here is my current url setting:
url(r'^accounts/password_reset/$',
'django.contrib.auth.views.password_reset', name='password_reset'),
It's not even seeing password_reset. I've even tried importing it and
replacting the url with password_reset.
Did you remember to put those login apps in your settings file under
INSTALLED_APPS ?
--
Joel Goldstick