Answer the question
In order to leave comments, you need to log in
How to change the status of the model using the button?
There is a model with two statuses
class Post(models.Model):
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
title = models.CharField(_('Покупатель'), max_length=50)
slug = models.SlugField(unique=True, null=True, blank=True)
status = models.CharField(max_length=10,
choices=STATUS_CHOICES,
default='published')
class DetailPageView(View):
def get(self, request, pk):
post = Post.objects.get(id=pk)
return render(request, 'updocks/adddoc/detail.html', {'post': post})
{% block content %}
<h1>{{ post.title }}</h1>
{{ post.body|linebreaks }}
{% endblock %}
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