Thursday, October 28, 2010

Re: Using localflavor with admin?

On Thu, Oct 28, 2010 at 12:23 AM, Victor Hooi <victorhooi@gmail.com> wrote:
> Hi,
>
> Is there any way to combine the localflavor module (http://
> docs.djangoproject.com/en/dev/ref/contrib/localflavor/) with Django's
> in-built admin module?
>
> For example, I'd like to create a model with say, a Postcode and phone-
> number field, and have these validated in the admin, as per the rules
> setup in localflavor?

Hi Victor,

You just need to use the the model fields to achieve this. So for
example, if I was going to do a US Phone Number field I would do:

from django.db import models
from django.contrib.localflavor.us.models import PhoneNumberField

class Test(models.Model):
phone = PhoneNumberField()

You'd obviously need to reference the exact field you're looking for,
but then it just automagically works in the admin.

--
Frank Wiles
Revolution Systems | http://www.revsys.com/
frank@revsys.com   | (800) 647-6298

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment