R
R
Ramplin2017-10-25 15:35:55
Django
Ramplin, 2017-10-25 15:35:55

How to make authorization and registration for an online store?

Hello!
I can’t do authorization and registration for the user, I re-read a bunch of docks, reviewed a lot of video lessons, copy-pasted from other projects, and nothing can be done, one mess in my head.
You just need to be able to log in, go to your personal account and register.
(Django 1.11.5)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vante_scribaxxi, 2017-10-25
@vante_scribaxxi

Try this

X
Xaip, 2017-10-25
@Xaip

That's the question! Pretty broad topic.
I did everything according to the documentation - https://djbook.ru/rel1.9/topics/auth/default.html
In the View:

from django.contrib.auth.models import Permission, User
from django.contrib import auth
def index(request):
    product_all = Product.objects.all()[:12]
    # сессия пользователя
    user = request.user
    set = {
        'product_all' : product_all,
        'user' : user

    }
    try:
        return render(request, 'shop/index.html', set)
    except(KeyError, Product.DoesNotExist):
        return render(request, 'shop/404.html')

In template:
{% block auth %}
<div class="log_in">

{% if user.is_anonymous %}
<form action="{% url 'shop:auth' %}" method="post">
    {% csrf_token %}
    <input type="text" name="login" placeholder="e-mail" />
    <input type="password" name="password" placeholder="password" />
    <input type="submit" value="Submit" />
</form>
{% else %}
    <a href="{% url 'auth:profile' %}">Profile</a>
{% endif %}
</div>
{% endblock %}

In urls: A Profile is generally a separate application

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question