1👍
✅
One thing that you can do is to make a simple form for the tag, just like what you did but remove the Meta information and update the post method to just add the tag in the company. Something like below:
# forms.py
class TagForm(forms.Form):
tag = forms.CharField(label='Tag', max_length=100)
# views.py
class CompanyDetails(generic.DetailView):
...
# This was my attempt to work it into the View...
def post(self, request, *args, **kwargs):
company = self.get_object()
form = TagForm(request.POST)
if form.is_valid():
company.tags.add(form.cleaned_data['tag'])
return self.render_to_response(self.get_context_data())
Source:stackexchange.com