CINXE.COM

Django - Tutorial 017. Customize the login page to Django

<!DOCTYPE html><html lang="en" itemscope itemtype="http://schema.org/Article"><head><!-- Yandex.RTB --><script>window.yaContextCb=window.yaContextCb||[]</script><script src="https://yandex.ru/ads/system/context.js" async></script><!-- Yandex.RTB --><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="apple-touch-icon-precomposed" sizes="57x57" href="/static/images/favicons/apple-touch-icon-57x57.png" /><link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/images/favicons/apple-touch-icon-72x72.png" /><link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/images/favicons/apple-touch-icon-114x114.png" /><link rel="apple-touch-icon-precomposed" sizes="120x120" href="/static/images/favicons/apple-touch-icon-120x120.png" /><link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/images/favicons/apple-touch-icon-144x144.png" /><link rel="apple-touch-icon-precomposed" sizes="152x152" href="/static/images/favicons/apple-touch-icon-152x152.png" /><link title="EVILEG - Social network of programmers" rel="alternate" type="application/rss+xml" href="/en/feed/" /><link title="EVILEG - Forum" rel="alternate" type="application/rss+xml" href="/en/forum/feed/" /><title>Django - Tutorial 017. Customize the login page to Django</title><meta property="og:title" content="Django - Tutorial 017. Customize the login page to Django" /><meta property="og:type" content="website" /><meta property="og:url" content="https://evileg.com/en/post/203/" /><meta property="og:image" content="https://evileg.com/static/images/favicons/favicon.ico" /><meta property="og:site_name" content="EVILEG" /><meta name="google-site-verification" content="vVTpO8SvQTo0QU2hU-zDTBHgHzqr2CGx7ACdQHPlLes" /><meta name="yandex-verification" content="c58ddaad8c500539" /><meta name="wot-verification" content="5e851b19f7a76433f3dc"/><meta name="description" content="Django - Tutorial 017. Customize the login page to Django. In order to make the registration of the login page in the same style with the design throughout the site, you can prepare a design template and replace the url pattern to give us an view of the "/><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"><link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" ><link href="/static/css/custom.css?9" rel="stylesheet"><script src="/static/js/jquery-3.3.1.min.js"></script><script src="https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js"></script><script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script><script src="/static/js/global.js?27"></script><script type="application/ld+json">{"@context": "http://schema.org", "@type": "ItemList", "itemListElement": [{"@type": "SiteNavigationElement", "position": 1, "name": "EVILEG", "url": "/en/"}, {"@type": "SiteNavigationElement", "position": 2, "name": "Articles", "url": "/en/knowledge/"}, {"@type": "SiteNavigationElement", "position": 3, "name": "Forum", "url": "/en/forum/"}, {"@type": "SiteNavigationElement", "position": 4, "name": "Tests", "url": "/en/tests/"}, {"@type": "SiteNavigationElement", "position": 5, "name": "Share code", "url": "/en/sharecode/"}, {"@type": "SiteNavigationElement", "position": 6, "name": "Share code", "url": "/en/sharecode/create/"}, {"@type": "SiteNavigationElement", "position": 7, "name": "Write article", "url": "/en/knowledge/article/add/"}, {"@type": "SiteNavigationElement", "position": 8, "name": "Ask a question", "url": "/en/forum/create_topic/"}]}</script></head><body class="bg-light"><nav class="navbar navbar-expand-lg navbar-dark fixed-top bg-dark"><div class="container-xxl"><button class="navbar-toggler collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#mainNavbar" aria-controls="mainNavbar" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button><a class="navbar-brand ms-3 ms-lg-0" href="/en/">EVILEG</a><button class="btn btn-outline-secondary ms-auto d-block d-lg-none" type="button" data-bs-toggle="modal" data-bs-target="#menuModal" aria-controls="menuModal" title="Menu"><span class="bi bi-grid-3x3-gap-fill"></span></button><a class="btn btn-outline-secondary ms-2 d-block d-lg-none" href="/en/accounts/login/" title="Login"> Login </a><div class="navbar-collapse collapse" id="mainNavbar"><form role="search" action="/en/search/" method="get" class="mt-3 mt-lg-0"><input id="search" name="search" type="search" class="form-control" placeholder="Search..." title="Search"></form><ul class="navbar-nav ms-2 mb-2 mb-lg-0"><li class="nav-item"><a class="nav-link" href="/en/knowledge/">Articles</a></li><li class="nav-item"><a class="nav-link" href="/en/forum/">Forum</a></li><li class="nav-item"><a class="nav-link" href="/en/tests/">Tests</a></li><li class="nav-item"><a class="nav-link" href="/en/sharecode/">Share code</a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-expanded="false">EN</a><ul class="dropdown-menu"><a class="dropdown-item" href="/lang/ru/">Русский</a><a class="dropdown-item" href="/lang/uk/">Українська</a><a class="dropdown-item" href="/lang/en/">English</a><a class="dropdown-item" href="/lang/kk/">Қазақ</a><a class="dropdown-item" href="/lang/de/">Deutsch</a></ul></li></ul></div><button class="btn btn-outline-secondary ms-2 d-none d-lg-block" type="button" data-bs-toggle="modal" data-bs-target="#menuModal" aria-controls="menuModal" title="Menu"><span class="bi bi-grid-3x3-gap-fill"></span></button><a class="btn btn-outline-secondary ms-2 d-none d-lg-block" href="/en/accounts/login/" title="Login"> Login </a></div></nav><main class="container-xxl"><div class="row"><div class="col-12 col-lg overflow-hidden"><ul class="breadcrumb bg-light"><li class="breadcrumb-item"><a href="/en/"><i class="bi bi-house"><span class="d-none">EVILEG</span></i></a></li><li class="breadcrumb-item"><a href="/en/knowledge/">Articles</a></li><li class="breadcrumb-item"><a href="/en/knowledge/django/">Django</a></li><li class="breadcrumb-item active">Django - Tutorial 017. Customize the login page to Django</li></ul><script type="application/ld+json">{"@context": "http://schema.org", "@type": "BreadcrumbList", "itemListElement": [{"@type": "ListItem", "position": 1, "item": {"@type": "Thing", "@id": "/en/", "name": "EVILEG"}}, {"@type": "ListItem", "position": 2, "item": {"@type": "Thing", "@id": "/en/knowledge/", "name": "Articles"}}, {"@type": "ListItem", "position": 3, "item": {"@type": "Thing", "@id": "/en/knowledge/django/", "name": "Django"}}, {"@type": "ListItem", "position": 4, "item": {"@type": "Thing", "@id": "/en/post/203/", "name": "Django - Tutorial 017. Customize the login page to Django"}}]}</script><div ><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8160668332851230" crossorigin="anonymous"></script><!-- EVILEG ADS TOP --><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-8160668332851230" data-ad-slot="6001381692" data-ad-format="auto" data-full-width-responsive="true"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><article><div itemprop="publisher" itemscope itemtype="https://schema.org/Organization"><div itemprop="logo" itemscope itemtype="https://schema.org/ImageObject"><link itemprop="image" href="/static/images/favicons/apple-touch-icon-152x152.png"><link itemprop="url" href="/static/images/favicons/apple-touch-icon-152x152.png"><meta itemprop="width" content="152"><meta itemprop="height" content="152"></div><meta itemprop="name" content="EVILEG"><meta itemprop="address" content="EVILEG"><meta itemprop="telephone" content="-"><link itemprop="url" href="https://evileg.com"></div><link itemprop="mainEntityOfPage" itemscope href="/en/post/203/" /><meta itemprop="commentCount" content="1"><meta itemprop="articleSection" content="Django"><div itemscope itemprop="author" itemtype="https://schema.org/Person"><meta itemprop="name" content="Evgenii Legotckoi"><link itemprop="url" content="/en/users/2/"></div><meta itemprop="url" content="/en/post/203/"><meta itemprop="accessMode" content="textual"><meta itemprop="wordCount" content="912"><meta itemprop="datePublished" content="Jan. 7, 2017, 7:20 p.m."><meta itemprop="dateModified" content="April 1, 2023, 3:21 p.m."><div itemprop="interactionStatistic" itemscope itemtype="https://schema.org/InteractionCounter"><meta itemprop="interactionType" content="https://schema.org/BookmarkAction"><meta itemprop="userInteractionCount" content="0"></div><div itemprop="interactionStatistic" itemscope itemtype="https://schema.org/InteractionCounter"><meta itemprop="interactionType" content="https://schema.org/LikeAction"><meta itemprop="userInteractionCount" content="4"></div><div itemprop="interactionStatistic" itemscope itemtype="https://schema.org/InteractionCounter"><meta itemprop="interactionType" content="https://schema.org/DislikeAction"><meta itemprop="userInteractionCount" content="0"></div><meta itemprop="keywords" content="авторизация,Django,login"><div class="card mb-3"><div class="card-header d-flex py-2"><a href=/en/users/2/><img loading="lazy" alt="Evgenii Legotckoi" class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" src="/media/cache/7a/08/7a0837c6eb199ca9af1a03ea5ccbfcbf.webp"></a><div class="ms-3"><div><a href="/en/users/2/" class="text-decoration-none">Evgenii Legotckoi</a></div><small class="text-secondary">Jan. 7, 2017, 7:20 p.m.</small></div></div><div class="card-body"><h1 itemprop="headline">Django - Tutorial 017. Customize the login page to Django</h1><div><p><a href="/en/search/?search=%23%D0%B0%D0%B2%D1%82%D0%BE%D1%80%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F">авторизация</a>, <a href="/en/search/?search=%23Django">Django</a>, <a href="/en/search/?search=%23login">login</a></p></div><div itemprop="articleBody"><div class="card border mb-3"><div class="card-header">Content</div><div class="card-body"><ol class="list-unstyled mb-0"><li><span>1. </span><span><a href="#header_accounts_module_structure">accounts module structure</a></span></li><li><span>2. </span><span><a href="#header_login_widget.html">login_widget.html</a></span></li><li><span>3. </span><span><a href="#header_login.html">login.html</a></span></li><li><span>4. </span><span><a href="#header_urls.py_files">urls.py files</a></span></li><li><span>5. </span><span><a href="#header_settings.py_и_apps.py">settings.py и apps.py</a></span><ol class="list-unstyled mb-0 ml-3"><li><span>1. </span><span><a href="#header_apps.py">apps.py</a></span></li><li><span>2. </span><span><a href="#header_settings.py">settings.py</a></span></li></ol></li><li><span>6. </span><span><a href="#header_views.py">views.py</a></span></li></ol></div></div><p> In order to make the registration of the login page in the same style with the design throughout the site, you can prepare a design template and replace the url pattern to give us an view of the desired page with the desired pattern. It may also be useful for the introduction of functional locks from password guessing and more intelligent redirect the user to a page of the site after login, depending on whether the user has a status of staff or not. </p><p> To work with the user authorization propose to use a separate application/module that will be called <strong> accounts </strong> . </p><p> Authorization Form is not required to write, because you can use the standard form <strong> AuthenticationForm </strong> , you will need to use in the login page template. </p><h2><a class="anchor" id="header_accounts_module_structure"></a> accounts module structure </h2><pre><pre class="prettyprint linenums"> accounts/ templates/ accounts/ login.html login_widget.html __init__.py admin.py apps.py models.py special_func.py urls.py views.py </pre></pre><p> This module uses two templates: </p><ul><li><strong> login.html </strong> - a template for the login page </li><li><strong> login_widget.html </strong> - a template for login widget that can be placed on any page of the site, the user can log in, not only from the login page, but also from any page with the article, for example. </li></ul><p> special_func.py file contains some useful features, such as the receipt of the <a href="https://evileg.com/post/181/"> previous Url from request </a> to redirect the user back to the page where the user is logged in. </p><hr/><h2><a class="anchor" id="header_login_widget.html"></a> login_widget.html </h2><p> I remind you that I use <a href="https://evileg.com/post/6/"> django_bootstrap3 </a> on the site, so the template will be using it. </p><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8160668332851230" crossorigin="anonymous"></script><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-8160668332851230" data-ad-slot="5700035342"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><pre><pre class="prettyprint linenums"> &lt;form id="contact_form" action="{% url 'accounts:login' %}" method="post"&gt; {% load bootstrap3 %} {% csrf_token %} {% bootstrap_form login_form %} {% buttons %} &lt;div class="form-group"&gt; &lt;button type="submit" class="btn btn-primary"&gt;Login&lt;/button&gt; &lt;/div&gt; {% endbuttons %} &lt;/form&gt; </pre></pre><h2><a class="anchor" id="header_login.html"></a> login.html </h2><p> The template is added to the login widget. By the same principle, you can add the widget to any login page anywhere in the site. </p><pre><pre class="prettyprint linenums"> {% extends 'home/base.html' %} {% block content %} &lt;div class="col-md-offset-3 col-md-6 voffset-60"&gt; &lt;h1&gt;Login to site&lt;/h1&gt; {% include 'accounts/login_widget.html' %} &lt;/div&gt; {% endblock %} </pre></pre><h2><a class="anchor" id="header_urls.py_files"></a> urls.py files </h2><p> To replace the login page, and in general authorization to use the widget, you must add the following url patterns to urls.py of your project. </p><pre><pre class="prettyprint linenums"> from django.conf.urls import url, include from django.contrib import admin from accounts.views import ELoginView # View of autorization of accounts module # To intercept the login page, you must set the path to this page # befor url to admin panel and specify the view # that will now handle authentication urlpatterns = [ url(r'^admin/login/', ELoginView.as_view()), url(r'^admin/', admin.site.urls), url(r'^accounts/', include('accounts.urls')), # also add url authorization module ] </pre></pre><p><strong> urls.py </strong> accounts module file will look as follows: </p><pre><pre class="prettyprint linenums"> # -*- coding: utf-8 -*- from django.conf.urls import url from . import views app_name = 'accounts' urlpatterns = [ url(r'^login/$', views.ELoginView.as_view(), name='login'), ] </pre></pre><h2><a class="anchor" id="header_settings.py_и_apps.py"></a> settings.py и apps.py </h2><p> Do not forget to register the authorization module in the site settings. </p><h3><a class="anchor" id="header_apps.py"></a> apps.py </h3><pre><pre class="prettyprint linenums"> from django.apps import AppConfig class AccountsConfig(AppConfig): name = 'accounts' </pre></pre><h3><a class="anchor" id="header_settings.py"></a> settings.py </h3><pre><pre class="prettyprint linenums"> INSTALLED_APPS = [ 'accounts.apps.AccountsConfig', ] </pre></pre><h2><a class="anchor" id="header_views.py"></a> views.py </h2><p> And now for the view, which will process the authorization as from the login page and another page with lyuoy. </p><pre><pre class="prettyprint linenums"> # -*- coding: utf-8 -*- from urllib.parse import urlparse from django.shortcuts import redirect, render_to_response from django.contrib import auth from django.template.context_processors import csrf from django.views import View from django.contrib.auth.forms import AuthenticationForm from .special_func import get_next_url class ELoginView(View): def get(self, request):   # if the user is logged in, then do a redirect to the home page if auth.get_user(request).is_authenticated: return redirect('/') else:   # Otherwise, form a context with the authorization form   # and we return to this page context.   # It works, for url - /admin/login/ and for /accounts/login/ context = create_context_username_csrf(request) return render_to_response('accounts/login.html', context=context) def post(self, request):   # having received the authorization request form = AuthenticationForm(request, data=request.POST)   # check the correct form, that there is a user and he entered the correct password if form.is_valid():   # if successful authorizing user auth.login(request, form.get_user())   # get previous url next = urlparse(get_next_url(request)).path   # and if the user of the number of staff and went through url /admin/login/   # then redirect the user to the admin panel if next == '/admin/login/' and request.user.is_staff: return redirect('/admin/')   # otherwise do a redirect to the previous page,   # in the case of a / accounts / login / will happen is another redirect to the home page   # in the case of any other url, will return the user to the url return redirect(next)   # If not true, then the user will appear on the login page   # and see an error message context = create_context_username_csrf(request) context['login_form'] = form return render_to_response('accounts/login.html', context=context) # helper method to generate a context csrf_token # and adding a login form in this context def create_context_username_csrf(request): context = {} context.update(csrf(request)) context['login_form'] = AuthenticationForm return context </pre></pre><p> For <strong> Django </strong> I recommend <a href="http://timeweb.com/ru/?i=27415" rel="nofollow"> VDS-server of Timeweb hoster </a> . </p></div><div class="mt-3"><a href="https://timeweb.com/ru/?i=27415&amp;utm_source=evileg&amp;utm_medium=after_article&amp;utm_campaign=base" rel="nofollow" target="_blank"><div class="d-flex"><div class="me-3"><img src="/media/technical_storage/timeweb-120-90.jpg" alt="We recommend hosting TIMEWEB"></div><div><h5 class="mt-0">We recommend hosting TIMEWEB</h5> Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting. </div></div></a></div></div><div class="card-body border-top"><p><strong>Recommended articles on this topic</strong></p><ul><li><a href="/en/post/658/">Django Rest Framework - Tutorial 001. Adding Token Authentication</a></li><li><a href="/en/post/613/">Django - Tutorial 053. Adding Counters to Models in the Django Admin Panel</a></li><li><a href="/en/post/202/">Django - Tutorial 016. Displays a list of popular articles on any page of the site</a></li><li><a href="/en/post/59/">Django - Tutorial 014. Displays a list of popular articles on Django</a></li><li><a href="/en/post/54/">Django - Tutorial 013. Contact form based on Django</a></li></ul><p><strong class="me-1">By article asked</strong><a href="/en/forum/?search=article:203">1<span class="ms-1">question(s)</span></a></p><div class="form-check form-switch d-flex justify-content-between align-items-center"><input class="form-check-input me-3" type="checkbox" role="switch" disabled><label class="form-check-label mt-1">Subscribe to the discussion</label><span class="badge text-bg-primary ms-auto">2</span></div><div class="form-check form-switch d-flex justify-content-between align-items-center"><input class="form-check-input me-3" type="checkbox" role="switch" disabled><label class="form-check-label mt-1"><a href="/en/knowledge/django/">Section subscription</a></label><span class="badge text-bg-primary ms-auto">180</span></div></div><div class="m-3 p-3 bg-light rounded text-center"><p>Do you like it? Share on social networks!</p><script async src="https://yastatic.net/share2/share.js"></script><div class="ya-share2" data-curtain data-size="l" data-shape="round" data-lang="en" data-services="telegram,vkontakte,twitter,linkedin,reddit,odnoklassniki,whatsapp,skype,tumblr,lj,pocket,surfingbird"></div></div><div class="card-footer"><div class="btn btn-sm" title="Views"><i class="bi bi-eye me-1"></i>3.8K</div><a class="btn btn-sm btn-light" title="Comments" href="/en/post/203/#comments"><i class="bi bi-chat-left me-1"></i>1</a><div class="btn btn-sm btn-light" onclick="Global.nonlogin()" title="Only registered users can add to favorites"><i class="bi bi-bookmark me-1"></i>0</div><div class="btn btn-sm btn-light" onclick="Global.nonlogin()" title="Only registered users can rate"><i class="bi bi-hand-thumbs-up-fill me-1"></i>4</div><div class="btn btn-sm btn-light" onclick="Global.nonlogin()" title="Only registered users can rate"><i class="bi bi-hand-thumbs-down-fill me-1"></i>0</div></div></div></article><a class="anchor" id="comments"></a><div id="comments-feed"><a class="anchor" name="comment-2842"></a><div id="2842" class="card mb-3"><div class="card-header d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/1217/>ИМ</a><div class="ms-3"><ul class="list-inline mb-0"><li class="list-inline-item"><a rel="author" href="/en/users/1217/">Игорь Максимов</a></li><li class="list-inline-item"><a href="/en/post/203/#comment-2842" title="Link to comment">#</a></li></ul><ul class="list-inline mb-0"><li class="list-inline-item me-2"><small class="text-secondary">Nov. 22, 2024, 9:51 p.m.</small></li></ul></div></div><div class="card-body"><div class="mb-3"><p> Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильный редирект. При переходе по ссылке /test/, меня редиректит на страницу авторизации(как и должно происходить в моем случае), после авторизации меня втупую перебрасывает на главную а не на предидущую страницу. </p><pre><pre class="prettyprint linenums">[22/Nov/2024 18:44:08] "GET /en/test/ HTTP/1.1" 302 0 [22/Nov/2024 18:44:08] "GET /accounts/login/?next=/en/test/ HTTP/1.1" 302 0 [22/Nov/2024 18:44:08] "GET /en/accounts/login/?next=/en/test/ HTTP/1.1" 200 11841 [22/Nov/2024 18:44:19] "POST /en/accounts/login/?next=/en/accounts/login/ HTTP/1.1" 302 0 [22/Nov/2024 18:44:19] "GET /en/accounts/login/ HTTP/1.1" 302 0 [22/Nov/2024 18:44:19] "GET / HTTP/1.1" 302 0 [22/Nov/2024 18:44:19] "GET /en/ HTTP/1.1" 200 10495 </pre></pre></div></div><div class="card-footer"><div class="btn btn-sm btn-light" onclick="Global.nonlogin()" title="Only registered users can add to favorites"><i class="bi bi-bookmark me-1"></i>0</div><div class="btn btn-sm btn-light" onclick="Global.nonlogin()" title="Only registered users can rate"><i class="bi bi-hand-thumbs-up-fill me-1"></i>0</div><div class="btn btn-sm btn-light" onclick="Global.nonlogin()" title="Only registered users can rate"><i class="bi bi-hand-thumbs-down-fill me-1"></i>0</div></div><script type="application/ld+json">{"@context": "http://schema.org", "@type": "Comment", "author": "Игорь Максимов", "url": "/en/post/203/#comment-2842", "name": "Django - Tutorial 017. Customize the login page to Django", "headline": "Django - Tutorial 017. Customize the login page to Django", "description": "\n \n Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильный редирект. При переходе по ссылке /test/, меня редиректит на страницу авторизации(как и должно происходить в моем случае), после авторизации меня втупую перебрасывает на главную а не на предидущую страницу.\n \n [22/Nov/2024 18:44:08] \"GET /en/test/ HTTP/1.1\" 302 0\n[22/Nov/2024 18:44:08] \"GET /accounts/login/?next=/en/test/ HTTP/1.1\" 302 0\n[22/Nov/2024 18:44:08] \"GET /en/accounts/login/?next=/en/test/ HTTP/1.1\" 200 11841\n[22/Nov/2024 18:44:19] \"POST /en/accounts/login/?next=/en/accounts/login/ HTTP/1.1\" 302 0\n[22/Nov/2024 18:44:19] \"GET /en/accounts/login/ HTTP/1.1\" 302 0\n[22/Nov/2024 18:44:19] \"GET / HTTP/1.1\" 302 0\n[22/Nov/2024 18:44:19] \"GET /en/ HTTP/1.1\" 200 10495\n\n", "datePublished": "2024-11-22T16:51:05.896373+00:00", "interactionStatistic": [{"@type": "InteractionCounter", "interactionType": "BookmarkAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "LikeAction", "userInteractionCount": 0}, {"@type": "InteractionCounter", "interactionType": "DislikeAction", "userInteractionCount": 0}]}</script></div></div><div class="card card-warning m-3 "><div class="card-header bg-warning"><h3 class="card-title mb-0">Comments</h3></div><div class="card-body"> Only authorized users can post comments.<br/>Please, <a href="/en/accounts/login/">Log in</a> or <a href="/en/accounts/register/">Sign up</a></div></div></div></div><div class="col-12 col-lg-auto"><div class="sidebar sidebar-lg sticky-lg-top mb-3"><div class="list-group mb-3"><div class="list-group-item list-group-item-primary"><strong>Actions</strong></div><a None href="/en/knowledge/article/add/" class="list-group-item list-group-item-action"><span>Write article</span></a><a None href="/en/forum/create_topic/" class="list-group-item list-group-item-action"><span>Ask a question</span></a><a None href="/en/forum/create_topic/" class="list-group-item list-group-item-action"><span>Take the test</span></a><a None href="/en/sharecode/create/" class="list-group-item list-group-item-action"><span>Share code</span></a></div><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8160668332851230" crossorigin="anonymous"></script><!-- EVILEG SIDEBAR TOP --><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-8160668332851230" data-ad-slot="8743063287" data-ad-format="auto" data-full-width-responsive="true"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></div></div></div><div class="row"><div class="col-12 col-lg overflow-hidden"><ul class="list-group mb-3"><li class="list-group-item list-group-item-primary"><strong>Last passed tests</strong></li><li class="list-group-item"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/18523/>КБ</a><div class="ms-3"><div><a href="/en/users/18523/" class="text-decoration-none">Кирилл Бородин</a></div><small class="text-secondary">April 7, 2025, 11:09 a.m.</small></div></div><div class="mb-3"><div><a href="/en/tests/t/8/">C++ - Test 006. Enumerations</a></div><div><strong>Result:</strong> 70 points</div><div><span class="text-success">Test passed</span></div></div></li><li class="list-group-item"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/18523/>КБ</a><div class="ms-3"><div><a href="/en/users/18523/" class="text-decoration-none">Кирилл Бородин</a></div><small class="text-secondary">April 6, 2025, 3:29 p.m.</small></div></div><div class="mb-3"><div><a href="/en/tests/t/7/">C++ - Test 005. Structures and Classes</a></div><div><strong>Result:</strong> 66 points</div><div><span class="text-danger">Test is not passed</span></div></div></li><li class="list-group-item"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/18523/>КБ</a><div class="ms-3"><div><a href="/en/users/18523/" class="text-decoration-none">Кирилл Бородин</a></div><small class="text-secondary">April 6, 2025, 3:20 p.m.</small></div></div><div class="mb-3"><div><a href="/en/tests/t/6/">C ++ - Test 004. Pointers, Arrays and Loops</a></div><div><strong>Result:</strong> 80 points</div><div><span class="text-success">Test passed</span></div></div></li></ul><ul class="list-group mb-3"><li class="list-group-item list-group-item-primary"><strong>Last comments</strong></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/18515/>AK</a><div class="ms-3"><div><a href="/en/users/18515/" class="text-decoration-none">Arseniy Khomchenko</a></div><small class="text-secondary">April 1, 2025, 11:41 a.m.</small></div></div><div><a href="/en/post/155/#comment-2845">Qt/C++ - Lesson 051. QMediaPlayer – simple audio player</a></div><div class="text-break"> Добрый день. В данный момент работаю над проектом, где необходимо выводить звук из программы в определенное аудиоустройство (колонки, наушники, виртуальный кабель и т.д). Пишу на Qt5.12.12 поско…</div></div></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a href=/en/users/2/><img loading="lazy" alt="Evgenii Legotckoi" class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" src="/media/cache/7a/08/7a0837c6eb199ca9af1a03ea5ccbfcbf.webp"></a><div class="ms-3"><div><a href="/en/users/2/" class="text-decoration-none">Evgenii Legotckoi</a></div><small class="text-secondary">March 9, 2025, 9:02 p.m.</small></div></div><div><a href="/en/post/193/#comment-2844">QML - Lesson 020. Introduction to Android Manifest in Qt Creator</a></div><div class="text-break"> К сожалению, я этого подсказать не могу, поскольку у меня нет необходимости в обходе блокировок и т.д. Поэтому я и не задавался решением этой проблемы. Ну выглядит так, что вам действитель…</div></div></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/15549/>VP</a><div class="ms-3"><div><a href="/en/users/15549/" class="text-decoration-none">Viktor Pathfinder</a></div><small class="text-secondary">March 9, 2025, 4:14 p.m.</small></div></div><div><a href="/en/post/193/#comment-2843">QML - Lesson 020. Introduction to Android Manifest in Qt Creator</a></div><div class="text-break"> Здравствуйте! Я устанавливал Qt6 из исходников а также Qt Creator по отдельности. Все компоненты, связанные с разработкой для Android, установлены. Кроме одного... Когда пытаюсь скомпилиров…</div></div></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/1217/>ИМ</a><div class="ms-3"><div><a href="/en/users/1217/" class="text-decoration-none">Игорь Максимов</a></div><small class="text-secondary">Nov. 22, 2024, 9:51 p.m.</small></div></div><div><a href="/en/post/203/#comment-2842">Django - Tutorial 017. Customize the login page to Django</a></div><div class="text-break"> Добрый вечер Евгений! Я сделал себе авторизацию аналогичную вашей, все работает, кроме возврата к предидущей странице. Редеректит всегда на главную, хотя в логах сервера вижу запросы на правильн…</div></div></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a href=/en/users/2/><img loading="lazy" alt="Evgenii Legotckoi" class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" src="/media/cache/7a/08/7a0837c6eb199ca9af1a03ea5ccbfcbf.webp"></a><div class="ms-3"><div><a href="/en/users/2/" class="text-decoration-none">Evgenii Legotckoi</a></div><small class="text-secondary">Oct. 31, 2024, 11:37 p.m.</small></div></div><div><a href="/en/post/729/#comment-2751">Django - Lesson 064. How to write a Python Markdown extension</a></div><div class="text-break"> Добрый день. Да, можно. Либо через такие же плагины, либо с постобработкой через python библиотеку Beautiful Soup </div></div></li></ul><ul class="list-group mb-3"><li class="list-group-item list-group-item-primary"><strong>Now discuss on the forum</strong></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/18263/>f</a><div class="ms-3"><div><a href="/en/users/18263/" class="text-decoration-none">firstlunoxod</a></div><small class="text-secondary">Feb. 15, 2025, 1:46 p.m.</small></div></div><div><a href="/en/forum/topic/218/#post-9885">Рисование на QGraphicsScene при зажатой кнопке мыши</a></div><div class="text-break"> Подскажите, пожалуйста! Как данный класс можно дополнить, чтобы созданные объекты можно было перемещать мышкой по сцене? </div></div></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a href=/en/users/2417/><img loading="lazy" alt="Дмитрий" class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" src="/media/cache/7f/2a/7f2a7c6416eb74fb21e8506c0ed78532.webp"></a><div class="ms-3"><div><a href="/en/users/2417/" class="text-decoration-none">Дмитрий</a></div><small class="text-secondary">Feb. 3, 2025, 4:24 p.m.</small></div></div><div><a href="/en/forum/topic/1920/">Создание deb-пакета. Как создать ярлык на рабочем столе после установки собственного deb-пакета?</a></div><div class="text-break"> Всем привет. Сделал свой deb-пакет с программой. Всё устанавливается и работает. Ставлю по пути /usr/bin/my_application. Как для пользователя при установке пакета сразу создать ярлык на раб…</div></div></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/18202/>NW</a><div class="ms-3"><div><a href="/en/users/18202/" class="text-decoration-none">Nayo Wai</a></div><small class="text-secondary">Jan. 30, 2025, 7:22 p.m.</small></div></div><div><a href="/en/forum/topic/1919/">не запускается компьютер!!!</a></div><div class="text-break"> Не запускается компьютер (точнее работает блок , но сам монитор вообще жесть)В общем я ничего с интернета не скачивала в последнее время. На компе никаких левых пр…</div></div></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/12748/>n</a><div class="ms-3"><div><a href="/en/users/12748/" class="text-decoration-none">nkly</a></div><small class="text-secondary">Jan. 3, 2025, 12:52 p.m.</small></div></div><div><a href="/en/forum/topic/1909/#post-9884">Нужно запретить перемещение только некоторых итемов, остальные перемещать можно.</a></div><div class="text-break"> Вопрос решен. Узнать QModelIndex элемента на который мы перетаскиваем другой элемент, можно с помощью функции indexAt(event-&gt;position().toPoint()) представления QTreeViev вызываемой в переопр…</div></div></li><li class="list-group-item"><div class="py-2"><div class="d-flex py-2"><a class="bg-secondary bg-opacity-10 rounded avatar-initials avatar-48" href=/en/users/15590/>M</a><div class="ms-3"><div><a href="/en/users/15590/" class="text-decoration-none">Marsel</a></div><small class="text-secondary">Aug. 17, 2023, 12:26 a.m.</small></div></div><div><a href="/en/forum/topic/1850/#post-9711">OAuth2.0 через VK, получение email</a></div><div class="text-break"> Спасибо большое за помощь и простите за то что отнял время своей невнимательностью. </div></div></li></ul></div><div class="col-12 col-lg-auto"><div class="sidebar sidebar-lg sticky-lg-top mb-3"><div class="sidebar sidebar-lg sticky-top"><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8160668332851230" crossorigin="anonymous"></script><!-- EVILEG SIDEBAR BOTTOM --><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-8160668332851230" data-ad-slot="3079673067" data-ad-format="auto" data-full-width-responsive="true"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></div></div></div></div></main><div class="container-xxl"><footer class="py-5"><div class="row"><div class="col-6 col-md-3 mb-3"><h5>About us</h5><ul class="nav flex-column"><li class="nav-item mb-2"><a class="nav-link p-0 text-body-secondary" href="/en/pages/">About us</a></li><li class="nav-item mb-2"><a class="nav-link p-0 text-body-secondary" href="/en/pages/rules/privacy-policy/">Privacy Policy</a></li><li class="nav-item mb-2"><a class="nav-link p-0 text-body-secondary" href="/en/pages/contacts/">Contacts</a></li><li class="nav-item mb-2"><a class="nav-link p-0 text-body-secondary" href="/en/pages/donate/">Donate</a></li><li class="nav-item mb-2"><a class="nav-link p-0 text-body-secondary" href="/en/pages/for-advertisers/">For advertisers</a></li></ul></div><div class="col-6 col-md-3 mb-3"><h5>Follow us in social networks</h5><ul class="nav flex-column"><li class="nav-item mb-2"><a class="nav-link p-0 text-body-secondary" href="https://vk.com/evileg" target="_blank" rel="noindex nofollow">VKontakte</a></li><li class="nav-item mb-2"><a class="nav-link p-0 text-body-secondary" href="https://t.me/evileg_ru" target="_blank" rel="noindex nofollow">Telegram</a></li><li class="nav-item mb-2"><a class="nav-link p-0 text-body-secondary" href="https://www.reddit.com/r/Evileg/" target="_blank" rel="noindex nofollow">Reddit</a></li></ul></div><div class="col-6 mb-3"><ul class="nav flex-column"><li class="nav-item mb-2">We recommend VSD hosting <a class="nav-link p-0" href="http://timeweb.com/ru/?i=27415&utm_source=evileg&utm_medium=footer&utm_campaign=timeweb" target="_blank" rel="noindex nofollow">Timeweb</a></li></ul></div></div><div class="d-flex flex-column flex-sm-row justify-content-between py-4 my-4 border-top"><p>© 2015-2025, Evgenii Legotckoi</p><ul class="list-unstyled d-flex"><li class="ms-3"><a class="link-body-emphasis" href="https://t.me/evileg_ru" target="_blank" rel="noindex nofollow"><i class="bi bi-telegram" style="font-size: 2rem;"></i></a></li><li class="ms-3"><a class="link-body-emphasis" href="https://www.reddit.com/r/Evileg/" target="_blank" rel="noindex nofollow"><i class="bi bi-reddit" style="font-size: 2rem;"></i></a></li></ul></div></footer></div><div id="menuModal" class="modal" tabindex="-1"><div class="modal-dialog modal-dialog-scrollable"><div class="modal-content"><div class="modal-header"><h5 class="modal-title">Actions</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div><div class="modal-body m-0 p-0"><div class="list-group list-group-flush"><a None href="/en/knowledge/article/add/" class="list-group-item list-group-item-action"><span>Write article</span></a><a None href="/en/forum/create_topic/" class="list-group-item list-group-item-action"><span>Ask a question</span></a><a None href="/en/forum/create_topic/" class="list-group-item list-group-item-action"><span>Take the test</span></a><a None href="/en/sharecode/create/" class="list-group-item list-group-item-action"><span>Share code</span></a></div></div></div></div></div><script async src="/static/js/run_prettify.js"></script><!-- Yandex.Metrika counter --><script type="text/javascript" > (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date(); for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }} k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(39565770, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true }); </script><noscript><div><img src="https://mc.yandex.ru/watch/39565770" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter --><!-- Yandex.RTB R-A-218837-50 --><script> window.addEventListener("load", () => { const render = (imageId) => { window.yaContextCb.push(() => { Ya.Context.AdvManager.render({ "renderTo": imageId, "blockId": "R-A-218837-50", "type": "inImage" }) }) } const renderInImage = (images) => { if (!images.length) { return } const image = images.shift() image.id = `yandex_rtb_R-A-218837-50-${Math.random().toString(16).slice(2)}` if (image.tagName === "IMG" && !image.complete) { image.addEventListener("load", () => { render(image.id) }, { once: true }) } else { render(image.id) } renderInImage(images) } renderInImage(Array.from(document.querySelectorAll("img"))) }, { once: true }) </script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10