Whats the frequency of the letter e in:
Q: Редирект на страницу после авторизации Здравствуйте. Как отдать страницу после авторизации, чтобы она не была доступна по прямой ссылке? Сейчас, если ввести адрес напрямую, то страница открывается.
urls.py:
url(r^$, UserFormView.as_view(), name=Login),
url(r^home/$, home, name=Главная),

views.py:
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, render_to_response
from django.views.generic.edit import View
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth import (
authenticate,
login,
)

from .forms import UserLoginForm

class UserFormView(View):
    form = UserLoginForm
    template = form.html

    def get(self, request):
        form = self.form(None)
        return render(request, self.template, {form: form})

    def post(self, request):
        form = self.form(request.POST)

        if form.is_valid():
            username = form.cleaned_data[username]
            password = form.cleaned_data[password]

            user = authenticate(username=username, password=password)

            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponseRedirect(/home/)
        return HttpResponse(<h1>Неверный логин или пароль</h1>)


@login_required
def home(request):
    return render_to_response((work_bot.html, {user:      
    request.user}))

forms.py:
class UserLoginForm(forms.ModelForm):
username = forms.CharField(widget=forms.TextInput(attrs= .   
{placeholder: Имя пользователя}))
password = forms.CharField(widget=forms.PasswordInput(attrs=
{placeholder: Пароль}))

class Meta:
    model = UserModel
    fields = [username, password]

Спасибо! И всех с прошедшим Новым Годом! ;)

A: Прописал в SETTINGS:
LOGIN_URL = login
LOGOUT_URL = logout
LOGIN_REDIRECT_URL = /work_bot/

Во views:
@login_required
def home(request):
    print(request.user.username)
    return render_to_response((work_bot.html, {user:     
    request.user.username}))

urls:
from django.contrib.auth.views import login

urlpatterns = [
url(r^work_bot/, home, name=Главная),
url(r^login/, login, {template_name: form.html}, name=login),
]

Все работает.

user
In that passage, there are 159 occurrences of the letter "e."
assistant