Answer the question
In order to leave comments, you need to log in
How to differentiate access rights in Django?
Added a new user (except for the superuser), created a group, added to this group the rights to view only + 1 model to change. Added this group to the created user. As far as I understand, now this user has only these rights. There is an authorization view:
def userlogin(request):
form = LoginForm()
if request.method == 'POST':
logout(request)
username = request.POST.get('u')
password = request.POST.get('p')
print(username+' '+password)
now_user = authenticate(username=username, password=password)
if now_user is not None:
if now_user.is_active:
login(request, now_user)
print('пользователь успешно залогинелся')
return redirect('index')
return render(request, 'mainapp/login.html', {'form': form})
…
from django.contrib.auth.decorators import login_required
…
@login_required
def edit_question(request, element, element_id):
Answer the question
In order to leave comments, you need to log in
You need to explicitly check https://docs.djangoproject.com/en/2.1/ref/contrib/... when changing the model
I agree with Vitaly Khomenko , and I'll just add to "in the browser it should be displayed in UTF-8" that is, you should add a meta tag<meta charset="utf-8">
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question