djangosnippets.org: Latest snippets tagged with 'oldforms'https://djangosnippets.org/tags/oldforms/2008-06-17T03:32:53.820493-05:00Disable fields in oldforms admin using jQuery
2008-06-17T03:32:53.820493-05:00schraalhttps://djangosnippets.org/snippets/810/<p>This snippet shows how to disable fields in a edit page in the oldforms admin using jquery. </p>
<p>The idea is to add the javascript to the edit page using the <code>js</code> attribute of the model's <code>Admin</code> class. In this case jQuery and a custom javascript file are added.</p>
<p>The javascript …</p>
Freely redistributableSelect multiple using a manytomany checkbox
2007-11-22T08:17:50.101206-06:00fivethreeohttps://djangosnippets.org/snippets/480/<p>Usage:</p>
<pre><code>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)
</code></pre>
Freely redistributableuse oldforms validators in newforms forms
2007-04-09T12:03:22.056560-05:00garywilsonhttps://djangosnippets.org/snippets/165/<p>Using the <code>run_oldforms_validators</code> function, you can run oldforms validators in your newforms <code>clean_XXX</code> methods.</p>
<p>Usage example:</p>
<pre><code>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', …</code></pre>
Freely redistributable