Answer the question
In order to leave comments, you need to log in
How to make a form visible only to a user from a certain group in Django?
How to make a form visible only to a user from a certain group in Django?
here is the form template on the site:
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Создать мерчь</title>
{% load staticfiles %}
<link rel="stylesheet" href="/static/login.css" type="text/css"/>
</head>
<body>
<div style='' class="container">
<div class="row justify-content-center">
<div id='block'>
<h1 class="text-center">Создать мерчь</h1>
{% block content %}
<div class="card">
<div class="card-body">
<h4 class="card-title"></h4>
<form action='' method="post" enctype="multipart/form-data">
{% csrf_token %}
{% for field in form %}
<p>
{{ field.label_tag }}<br>
{{ field }}
{% if field.help_text %}
<small style="display: none">{{ field.help_text }}</small>
{% endif %}
{% for error in field.errors %}
<p style="color: red">{{ error }}</p>
{% endfor %}
</p>
{% endfor %}
<button type="submit" class="btn btn-primary btn-block">Создать мерчь</button>
</form>
</div>
</div>
{% endblock %}
</div>
</div>
</div>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question