Login

Tag "oldforms"

Snippet List

Disable fields in oldforms admin using jQuery

This snippet shows how to disable fields in a edit page in the oldforms admin using jquery. The idea is to add the javascript to the edit page using the `js` attribute of the model's `Admin` class. In this case jQuery and a custom javascript file are added. The javascript sets the `disabled` attribute of the `name` field to `true` as soon as the document is ready.

  • admin
  • jquery
  • oldforms
  • disable
Read More

Select multiple using a manytomany checkbox

Usage: from yourapp.fields import CheckBoxManyToMany from django.db import models class Weekday(models.Model): name = models.CharField() def __unicode__(self): return self.name class EventWithWeekday(models.Model): weekdays = CheckBoxManyToMany(Weekday)

  • checkbox
  • multiple
  • oldforms
  • select
Read More

use oldforms validators in newforms forms

Using the `run_oldforms_validators` function, you can run oldforms validators in your newforms `clean_XXX` methods. Usage example: class PasswordForm(forms.Form): password = forms.CharField(widget=forms.PasswordInput()) def clean_password(self): validator_list = [ isStrongPassword, isValidLength, SomeValidators( num_required=3, validator_list=[hasLower, hasUpper, hasNumeric, hasSpecial], error_message="Password must contain at least 3 of: lowercase, uppercase, numeric, and/or special characters." ) ] run_oldforms_validators('password', self, validator_list) return self.clean_data['password'] Above, `isStrongPassword`, `isValidLength`, etc. are oldforms validators. If you are interested in seeing the implementation of `isStrongPassword`, please see my [Using CrackLib to require stronger passwords](http://gdub.wordpress.com/2006/08/26/using-cracklib-to-require-stronger-passwords/) blog post.

  • newforms
  • validators
  • oldforms
Read More

3 snippets posted so far.