Upon successful registration, the user should be prompted to create a new “thing”. However, the link for that doesn’t appear anywhere. I even tried copying and pasting the code from github repo but that didn’t work. I’m using django 1.9.4.
Cannot see "Create a thing" on registration
Hi there! Put your code in a public github repository so I can check it, or put on pastebin.com and link me the files. I can’t tell you what is wrong if I can’t see your code. :)
I can’t either, working on a fix. Please let me know what happens with this if it is not too much trouble
I am still having some trouble with this.
Here is my github repo:
When I create a new user, I just get redirected to the home screen. The users DO get created; I can see them and manage them as normal.
I tried a few tweaks from stack overflow and reading through the Django docs to no avail.
The code on the github is a little different than that in the book but I can’t get either to run.
Thanks!
Sorry the slow response, I was traveling! Thanks for the github repo, I’ll look through it, and if I can’t find anything immediate, I’ll try downloading and checking it on my end. I’ll return with an update soon. :)
Figured it out! The line in urls.py…
path('accounts/', include('registration.backends.simple.urls')),
…needs to be at the end of the file. See this for an example (it’s using the Python 2.7/Django 1.10 style, but the ordering is correct): https://github.com/hellowebbooks/hellowebapp-code/blob/master/hellowebapp/urls.py
(I’ll update that repo soon, I promise — it’s a bunch of work since I need to rebase everything but I promise it’ll be updated!)
AHA! Thanks! Such a relief!
That’s so strange; I am not used to the order mattering like that. Are there any other instances where that order will mess with you?
For urls.py it definitely does. :D Django basically reads it from top-down when it’s trying to match a URL, and as soon as it hits something that works, it’ll go with it. In this case, the account imports were overriding the following registration stuff (I think redux has some duplicates?)
Glad I could help!
…needs to be at the end of the file.
No. In that case you will get error on password reset and password change. All you need is place your
path('accounts/create_thing/', views.create_thing, name='registration_create_thing'),
path('accounts/register/', MyRegistrationView.as_view(), name='registration_register'),
above
path('accounts/', include('registration.backends.simple.urls')),
and after this block place your
path('accounts/password/reset/', PasswordResetView, {'template_name': 'registration/password_reset_form.html'}, name="password_reset"),
path('accounts/password/reset/done/', PasswordResetDoneView, {'template_name': 'registration/password_reset_done.html'}, name="password_reset_done"),
and other ‘accounts/…’ stuff
Please add this to book. Thanks.