I'm making a web app for post blogs.And I added categories field to identify the category of that blog.But the problem is I can add categories in only when I on admin page.But I want to have that add category button in fronend as well.
example: when I click categories field it shows up current categories in database but I want to add add button to that drop down menu of category.
.this is picture of my add post page
model.py
class PostForm(forms.ModelForm):
category = forms.ModelChoiceField(queryset=category.objects.all().order_by('name'))
class Meta:
model = Post
fields = ('title', 'category','author', 'content', 'image','status')
template
{% if user.is_authenticated %}
<h1>Add Post...</h1>
<br/><br/>
<div class="form-group">
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{ form.media }}
{{ form|crispy}}
<br>
<button class="btn btn-secondary btn-lg">Post</button>
</form>