Skip to content

Commit

Permalink
Added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
qoda committed Feb 7, 2017
1 parent 41ef3bf commit dd91fa4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,23 @@ Models
- required: boolean value to indicate if the field is required
- disabled: boolean value to disable field (readonly)
- choices: a set of ``FieldChoice`` objects
- model_choices: a generic foreign key to a model which defines the choices for the formfield
- additional_validators: a set of custom defined field validators

Model Choices
~~~~~~~~~~~~~

To define a custom model for field choices the model will need to have an items related name which points to an enum items model containing key and value fields. ::

from django.db import models

class Enum(models.Model):
title = models.CharField(max_length=100)

class EnumItem(models.Model):
enum = models.ForeignKey(Enum, related_name="items")
value = models.CharField(max_length=100)
label = models.CharField(max_length=100)

Actions
~~~~~~~
Expand Down

0 comments on commit dd91fa4

Please sign in to comment.