Login

Tag "formfield_factory"

Snippet List

Add validation for 'unique' and 'unique_together' constraints to newforms created dynamically via form_for_model or form_for_instance

This snippet provides a form_for_model and form_for_instance function which create newforms that respect the unique and unique_together constraints defined in the model. One thing about the coding style in this code snippet: Classes are capitalized even if they're passed as arguments. Thus "Model" is a model class while "model" is a model instance.

  • newforms
  • form_for_model
  • form_for_instance
  • unique_together
  • unique
  • formfield_factory
Read More

1 snippet posted so far.