Using localflavor with admin?
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? Cheers, Victor -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using localflavor with admin?
On Thu, Oct 28, 2010 at 12:23 AM, Victor Hooi 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/ fr...@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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using localflavor with admin?
heya, Hmm, I'm actually trying this Australian localisation. However, the weird thing is, there's a US models.py: http://code.djangoproject.com/browser/django/trunk/django/contrib/localflavor/us/models.py But there's no such models.py for other countries. E.g., for Australia: http://code.djangoproject.com/browser/django/trunk/django/contrib/localflavor/au Is there a particular reason for this? Or any way of achieving the same effect? Cheers, Victor On Oct 29, 5:48 am, Frank Wiles wrote: > On Thu, Oct 28, 2010 at 12:23 AM, Victor Hooi 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/ > fr...@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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Using localflavor with admin?
heya, Thanks for your answer - I posted a reply (doesn't seem to work for non-US), however, it doesn't seem to have appeared on the web-version of Groups, so I thought I'd email you directly, just in case you missed it and happened to know. Thanks, Victor Hmm, I'm actually trying this Australian localisation. However, the weird thing is, there's a US models.py: http://code.djangoproject.com/browser/django/trunk/django/contrib/localflavor/us/models.py But there's no such models.py for other countries. E.g., for Australia: http://code.djangoproject.com/browser/django/trunk/django/contrib/localflavor/au Is there a particular reason for this? Or any way of achieving the same effect? On Oct 29, 5:48 am, Frank Wiles wrote: > On Thu, Oct 28, 2010 at 12:23 AM, Victor Hooi 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/ > fr...@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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.