K
K
kpronink2017-10-26 09:36:50
Django
kpronink, 2017-10-26 09:36:50

How to pass template name to url template so that it is not ignored?

Good afternoon, there is such a typical urlpatterns, in which I explicitly set which template to use:

url(r'^password_reset/$',
                      auth_views.PasswordResetView.as_view(template_name='project_name/registration/password_reset_form.html'),
                      {'post_reset_redirect': 'password_reset/done/'}, name="password_reset"),

But when forming a view, it birches a typical django template,
the structure where the templates are simple project_name/temlates/project_name/registration
how to be where to look?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
Xaip, 2017-10-26
@Xaip

Give more information. Perhaps the problem is in the template, namely in extends. Or the problem is in specifying the paths to statics and media.
Why use a standard view at all? For me, it's better to use a separate view in views:

from django.contrib.auth.models import User


def password_reset(request):
    u = User.objects.get(username='john')
    u.set_password('new password')
    u.save()
    #return формируете интересующую форму

And specify in urls:
app_name = 'project_name'
urlpatterns = [
    url(r'^password_reset/$', views.password_reset, name='password_reset'),
]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question