Code


Version 10 (modified by anonymous, 2 years ago) (diff)

--

FormField

Manipulators create a "field" attribute that is used to describe the entries in an html form. Each field class takes a list of arguments in its initializer.

The first argument to all field initializers is the field_name. This is the name that is attached to the field's input.

Generic Widgets

  • TextField
    • field_name, length=30, maxlength=None, is_required=False, validator_list=[], member_name=None
    • <input type="text">
  • PasswordField
    • field_name, length=30, maxlength=None, is_required=False, validator_list=[], member_name=None
    • <input type="password">
  • LargeTextField
    • field_name, rows=10, cols=40, is_required=False, validator_list=[], maxlength=None
    • <textarea>
  • HiddenField
    • <input type="hidden">
  • CheckboxField
    • field_name, checked_by_default=False
    • <input type="checkbox">
  • SelectField
    • field_name, choices=[], size=1, is_required=False, validator_list=[], member_name=None
    • <select>
  • NullSelectField
    • This SelectField converts blank fields to None
    • field_name, choices=[], size=1, is_required=False, validator_list=[], member_name=None
    • <select><option></select>
  • RadioSelectField
    • Returns a special object, RadioFieldRenderer, that is iterable and has a default str() rendered output.
    • field_name, choices=[], ul_class="", is_required=False, validator_list=[], member_name=None
    • <ul><li><input type="radio"></li> ... </ul>
  • NullBooleanField
    • This SelectField provides "Yes", "No" and "Unknown", mapping results to True, False or None
    • field_name, is_required=False, validator_list=[]
    • <select>
  • CheckboxSelectMultipleField
    • This has an identical interface to SelectMultipleField, except the rendered widget is different.
    • field_name, choices=[], size=1, is_required=False, validator_list=[], member_name=None
    • <select><option></select>

File Uploads

  • FileUploadField
    • field_name, is_required=False, validator_list=[]
    • <input type="file">
  • ImageUploadField
    • A FileUploadField that raises CriticalValidationError if the uploaded file isn't an image.
    • field_name, is_required=False, validator_list=[]
    • <input type="file">

Numbers

  • IntegerField
    • field_name, length=10, maxlength=None, is_required=False, validator_list=[], member_name=None
    • <input type="text">
  • SmallIntegerField
    • field_name, length=5, maxlength=5, is_required=False, validator_list=[], member_name=None
    • <input type="text">
  • PositiveIntegerField
    • field_name, length=10, maxlength=None, is_required=False, validator_list=[], member_name=None
    • <input type="text">
  • PositiveSmallIntegerField
    • field_name, length=5, maxlength=5, is_required=False, validator_list=[], member_name=None
    • <input type="text">
  • FloatField
    • field_name, max_digits, decimal_places, is_required=False, validator_list=[]
    • <input type="text">

Dates and Times

  • DatetimeField
    • A FormField that automatically converts its data to a datetime.datetime object. The data should be in the format YYYY-MM-DD HH:MM:SS.
    • field_name, length=30, maxlength=None, is_required=False, validator_list=[]
    • <input type="text">
  • DateField
    • A FormField that automatically converts its data to a datetime.date object. The data should be in the format YYYY-MM-DD.
    • <input type="text">
  • TimeField
    • A FormField that automatically converts its data to a datetime.time object. The data should be in the format HH:MM:SS or HH:MM:SS.mmmmmm.
    • field_name, is_required=False, validator_list=[]
    • <input type="text">

Internet

  • EmailField
    • A convenience FormField for validating e-mail addresses
    • field_name, length=50, maxlength=75, is_required=False, validator_list=[]
    • <input type="text">
  • URLField
    • A convenience FormField for validating URLs
    • self, field_name, length=50, is_required=False, validator_list=[]
    • <input type="text">
  • IPAddressField
    • field_name, length=15, maxlength=15, is_required=False, validator_list=[]
    • <input type="text">

Miscellaneous

  • FilePathField
    • A SelectField whose choices are the files in a given directory.
    • field_name, path, match=None, recursive=False, is_required=False, validator_list=[]
    • <select><option /> ... </select>
  • PhoneNumberField
    • A convenience FormField for validating phone numbers (e.g. '630-555-1234')
    • field_name, is_required=False, validator_list=[]
    • <input type="text">
  • USStateField
    • A convenience FormField for validating U.S. states (e.g. 'IL')
    • field_name, is_required=False, validator_list=[]
    • <input type="text">
  • CommaSeparatedIntegerField
    • A convenience FormField for validating comma-separated integer fields
    • field_name, maxlength=None, is_required=False, validator_list=[]
    • <input type="text">
  • RawIdAdminField
    • field_name, maxlength=None, is_required=False, validator_list=[]
    • <input type="text">
  • XMLLargeTextField
    • field_name, schema_path, rows=10, cols=40, is_required=False, validator_list=[], maxlength=None
    • <textarea>

Model fields Common option

  • null = False
  • blank = False
  • choices = list_of_tuples
  • db_column = "column_name"
  • db_index = False
  • db_tablespace = "tablespace_name"
  • default = value_or_func
  • editable = True
  • help_text = "text"
  • primary_key = False
  • unique = False
  • unique_for_date = "date_field"
  • unique_for_month = "date_field"
  • unique_for_year = "date_field"

Form fields common options

  • required = True
  • label = "Field name"
  • initial = {}
  • widget = Widget
  • help_text = "text"
  • error_messages = {}

Relational model fields

  • ForeignKey(model)
    • related_name = "model_set"
    • limit_choices_to = query_kwargs
    • to_field = "key_field"

  • ManyToManyField(model)
    • related_name = "model_set"
    • limit_choices_to = query_kwargs
    • through = "IntermediateModel"
    • symmetrical = True
  • OneToOneField(model)
    • parent_link = "field"
  • GenericForeignKey("content_type_field", "object_id_field")

Form error_messages keys

  • required
  • max_length
  • min_length
  • invalid
  • invalid_choice
  • max_value
  • min_value
  • max_digits
  • max_decimal_places
  • max_whole_digits
  • missing
  • empty
  • invalid_image
  • invalid_list
  • invalid_link

Model fields

  • DateField
    • auto_now = False
    • auto_now_add = False
  • DateTimeField
    • auto_now = False
    • auto_now_add = False
  • TimeField
    • auto_now = False
    • auto_now_add = False
  • EmailField
    • max_length = 75
  • FileField
    • upload_to = "uploads/"
    • max_length = 100
    • storage = FileSystemStorage