<div class="download">
<form action="/Download/" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p}}
<div class="button_2">
<button type="submit">Добавить</button>
</div>
</form>
</div>
def d(request):
if request.method == 'POST':
form = DownloadForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return HttpResponseRedirect('/main/')
else:
return render(request, 'downloader.html', {'form': form})
else:
form = DownloadForm()
return render(request, 'downloader.html', {'form': form})
There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors.
def menu(request):
return {'menu': MenuItems.objects.all()}
TEMPLATES = [
{
...
'OPTIONS': {
'context_processors': [
...
'mysite.context_processors.menu',
],
...
}
}
]
div {
display: flex;
align-content: stretch;
}
<div class="slider">
<div class="img curry" style="display: block">1</div>
<div class="img" style="display: none">2</div>
<div class="img" style="display: none">3</div>
<div class="img" style="display: none">4</div>
<div class="img" style="display: none">5</div>
<div class="img" style="display: none">6</div>
</div>
.img[style],
.img.curry {
display: block;
}