Ticket #10087: models.py.diff

File models.py.diff, 1.5 KB (added by Lior Gradstein, 16 years ago)

french models.py for django.contrib.localflavor

  • django/contrib/localflavor/fr/models.py

     
     1from django.conf import settings
     2from django.db.models.fields import Field
     3
     4class FRZipCodeField(Field):
     5    def get_internal_type(self):
     6        return "FRZipCodeField"
     7       
     8    def db_type(self):
     9        if settings.DATABASE_ENGINE == 'oracle':
     10            return 'CHAR(10)'
     11        else:
     12            return 'varchar(10)'
     13   
     14    def formfield(self, **kwargs):
     15        from django.contrib.localflavor.fr.forms import FRZipCodeField
     16        defaults = {'widget': FRZipCodeField}
     17        defaults.update(kwargs)
     18        return super(FRZipCodeField, self).formfield(**defaults)
     19
     20class PhoneNumberField(Field):
     21    def get_internal_type(self):
     22        return "PhoneNumberField"
     23
     24    def db_type(self):
     25        if settings.DATABASE_ENGINE == 'oracle':
     26            return 'VARCHAR2(20)'
     27        else:
     28            return 'varchar(20)'
     29
     30    def formfield(self, **kwargs):
     31        from django.contrib.localflavor.fr.forms import FRPhoneNumberField
     32        defaults = {'form_class': FRPhoneNumberField}
     33        defaults.update(kwargs)
     34        return super(PhoneNumberField, self).formfield(**defaults)
     35
Back to Top