Django
3
Вклад в тег
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')
{% 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 %}
url(r'auth/$', views.auth, name='auth'),
is_rule1 = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)