CodeLookupField
This is a custom form-field designed to make those optional "enter a discount code" fields a little easier to deal with. You create one like this: code = CodeLookupField(model=MyModel, field_name='slug', max_length=20) And then when you validate your form, cleaned_data['code'] will be the actual object if anything was retrieved, or None if the user entered a bad piece of data.
- forms
- field