Form widget for text inputs with external link. version2
This widget is answer for this question: http://stackoverflow.com/questions/946243/form-widget-for-text-inputs-with-external-link-wanted
- django
- forms
- form
- widgets
- widget
This widget is answer for this question: http://stackoverflow.com/questions/946243/form-widget-for-text-inputs-with-external-link-wanted
This Field, Widget and the three lines of code in the form's clean method allow an easy (and hopefully general) way to add simple, unchangable text to a form. Example use: class OnlyTextForm(forms.ModelForm): points = StaticField(label=_('Points')) reviewer = StaticField(label=_('Reviewer')) def clean(self): for name, field in self.fields.items(): if isinstance(field, StaticField): self.cleaned_data.update({name: self.initial[name]}) return self.cleaned_data
A custom form field than validates html hex color fields
This is an extended version of the FormWizard which allows display of multiple forms per step and allows usage of ModelForms with initial objects
VAT field with a field to select the country and a free field for the code
Alex Gaynor presented this idiom at EuroDjangoCon 2009.
This is a custom field for multiple emails separated by comma. Original code was replaced by code from Django documentation: http://docs.djangoproject.com/en/dev/ref/forms/validation/ (MultiEmailField) so i'm not the author of the code, but just put it here to replace an outdated solution. Uses code from mksoft comment http://www.djangosnippets.org/snippets/1093/
I sometimes find that larger forms need data associated with them, but it's a bit of a pain to retype it each time when I'm debugging. The DebugForm base class lets you specify sets of testing data that will be inserted into your form if your project is in debug mode, randomly chosen from the DEBUG_DATA dict.
This is an extended version of django wizard with the ability to go back and execute any step directly. To define next step to execute use the form field with the name "wizard_next_step". Don't forget to specify in your form the wizard_max_step field, so the knows the step number with the highest number, where the user was. An other improvement is the variable "wizard_data". It's a QueryDict with data from all wizard forms. It can be used to retrieve values from the field values of the forms from other steps. It could be helpfully for the latest step, where the user should see an overview of his input.
ACNField - Australian Company Number Form Field ABNField - Australian Business Number Form Field Any feedback / Improvements Appreciated.
Using this small helper, you can instanciate your forms in an even DRYer way: form = MyForm(**form_kwargs(request)) if form.is_valid(): #...
The following code takes two related models and creates one user interface to for create and update operations that handles them both. It enables the creation or update of instances from both models in one shot, without having to create very complex forms. As I could not find examples for creation of related objects together, I thought this might be useful for someone.
Use this in your form if you want to accept input in microseconds. In a ModelForm you can override the field like this: def __init__(self, *arg, **kwargs): super(MyForm, self).__init__(*arg, **kwargs) self.fields['date'] = DateTimeWithUsecsField() *Update* May 26 2009 - Updated to address a couple issues with this approach. See http://code.djangoproject.com/ticket/9459
A Form and ModelForm which provides the ability to specify certain fields as readonly, meaning that they will display their value as text wrapped with a <span> tag. The user is unable to edit them, and they are protected from POST data insertion attacks. The recommended usage is to place a NewMeta inner class on the form, with a readonly attribute which is a list or tuple of fields, similar to the fields and exclude attributes on the Meta inner class. class MyForm(ReadonlyForm): foo = forms.TextField() bar = forms.TextField() class NewMeta: readonly = ('foo',) Use these forms as you would a standard form in your templates.
For disabling autocomplete and security purpose, this snippet defines a CharField with a randomness name for each request of the form. This is useful for turning off autocomplete for credit card input in all browsers, without breaking the xhtml validation. * [https://wiki.mozilla.org/The_autocomplete_attribute_and_web_documents_using_XHTML#Security](https://wiki.mozilla.org/The_autocomplete_attribute_and_web_documents_using_XHTML#Security) * [http://en.wikipedia.org/wiki/Cryptographic_nonce](http://en.wikipedia.org/wiki/Cryptographic_nonce)
141 snippets posted so far.