Django: problem with Django + django-registration + jinja

So, I have a django project that uses jinja2 rendering, and I also installed django-registration to make my life easier. I ran into the following problem:

Going to the main page I am doing this with jinja. To authenticate, I have to use jinja syntax, which is user.is_authenticated (). However, in the regular django template, this check is done using user.is_authenticated. If there is () in the django regular pattern, it gives an error.

Therefore, by going to the / accounts / login / page page, the django login module does nothing special, so it redirects the URL to standard django views as follows:

from django.contrib.auth import views as auth_views

url(r'^login/$',
auth_views.login,
{'template_name': 'registration/login.html'},
name='auth_login'),

So I know for sure that I should not change the view of django.contrib.auth, but then where can I put my own view? In myapp / views.py?

And also, do I need to copy the django view insert and then change over it (in this case, just replace the render_jinja render) or is there a way to "extend" this original django view to my own slightly modified login view?

+3
source share
1 answer

Right or wrong, in the registration module I made a new view that handled the registration by copying a few lines from here and there. This is logical and seems to work fine.

0
source

Source: https://habr.com/ru/post/1777437/


All Articles