Answer the question
In order to leave comments, you need to log in
Why is the button not displayed in the template?
Hello!
There are two data models: Project (Project) and Purpose (Assignment).
models.py:
class Purpose(models.Model):
code = models.UUIDField(_('Code'), primary_key=True, default=uuid.uuid4, editable=False)
project = models.ForeignKey(Project, on_delete=models.CASCADE)
text = models.TextField(_('Text'))
comments = models.ManyToManyField("Comment")
def project_detail(request, project_code):
*some code*
purpose_is_not_exist = Purpose.objects.exclude(project=project_code).exists()
*some code*
{% if purpose_is_not_exist %}
<button id="purpose-add-button"></button>
{% endif %}
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