I have a situation where I need to check if a form has m2m relation before saving it in views.py as I am using the same views.py for different models.
Example:
#models.py
class BaseClass(models.Model):
# Some generic stuff.
class SomeClass(BaseClass):
# This class doesnt have any many2many relations
class SomeOtherClass(BaseClass):
# This class has many2many relations
#views.py
def do_some_stuff(request):
# Instantiate a form
# Save it in a normal way
form.save()
# Now, in here while saving I need to check if the form has any
# m2m relations so I can use the save_m2m() function after form.save()
I just need an extra check in there to be on the safer side. Is there any way around this? Thanks in advance