Where to define custom data handling for a m2m field in django

Let's say for example I want the many to many 'tags' modelfield to be inputted as a space-separated list, were an unrecognized name be submitted it should also be created in the 'Tag' model. I'm aware this could be written either at:

  • View level
  • Form level
  • FormField level
  • ModelField level

I want to adhere to the DRY principle as tightly as possible.

For the time being I have defined it at ModelForm level but my setup is not very flexible. I would have to write new forms for every variation in each part of the website I place this formfield in.

Back to Top