Skip to main content

A form field to create a related model sub-form

Project description

ModelMultiValueField provides the ability to create sub-forms for foreign models without having to worry about writing the ModelMultiValueField subclasses.

Quick start

  1. Add “modelmultivalue” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'modelmultivalue',
    ]
    
  2. Add the ModelMultiValueField to a model form

    1. All django version:

      from django import forms
      from modelmultivalue import ModelMultiValueField
      
      class ExampleModelForm(forms.ModelForm):
          class Meta:
              model = Example
              fields = '__all__'
      
          ForeignKeyField = ModelMultiValueField(model=ForeignKey
      
    2. for Django>=1.9:

      from django import forms
      from modelmultivalue import ModelMultiValueField
      
      class ExampleModelForm(forms.ModelForm):
          class Meta:
              model = Example
              fields = '__all__'
              field_classes={
                  'ForeignKeyField': ModelMultiValueField
              }
      

Project details


Release history Release notifications

This version
History Node

0.21

History Node

0.20

History Node

0.11

History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-modelmultivalue-0.21.tar.gz (6.0 kB) Copy SHA256 hash SHA256 Source None Jul 15, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page