Login

Tag "many"

Snippet List

ManyToManyFieldWithDefault

Extension to the normal ManyToManyField to support default values. Build for the following use case: publish_on = ManyToManyFieldWithDefault(Site, verbose_name=_('publish on'), default=Site.objects.get_current) Where with a plain ManyToManyField the default site will not be selected. The ManyToManyFieldWithDefault fixes this by automatically selecting the default value if no other selections are given. When the field also have null=True and Blank=True it will not select the default !

  • field
  • sites
  • manytomanyfield
  • many
  • default
Read More

1 snippet posted so far.