Giter Site home page Giter Site logo

django / django-localflavor Goto Github PK

View Code? Open in Web Editor NEW
799.0 799.0 287.0 11.83 MB

Country-specific Django helpers, formerly of contrib fame

Home Page: https://django-localflavor.readthedocs.io/

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

django-localflavor's Introduction

Django

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out.

All documentation is in the "docs" directory and online at https://docs.djangoproject.com/en/stable/. If you're just getting started, here's how we recommend you read the docs:

  • First, read docs/intro/install.txt for instructions on installing Django.
  • Next, work through the tutorials in order (docs/intro/tutorial01.txt, docs/intro/tutorial02.txt, etc.).
  • If you want to set up an actual deployment server, read docs/howto/deployment/index.txt for instructions.
  • You'll probably want to read through the topical guides (in docs/topics) next; from there you can jump to the HOWTOs (in docs/howto) for specific problems, and check out the reference (docs/ref) for gory details.
  • See docs/README for instructions on building an HTML version of the docs.

Docs are updated rigorously. If you find any problems in the docs, or think they should be clarified in any way, please take 30 seconds to fill out a ticket here: https://code.djangoproject.com/newticket

To get more help:

To contribute to Django:

To run Django's test suite:

Supporting the Development of Django

Django's development depends on your contributions.

If you depend on Django, remember to support the Django Software Foundation: https://www.djangoproject.com/fundraising/

django-localflavor's People

Contributors

avelino avatar benkonrath avatar burhan avatar camillobruni avatar charettes avatar claudep avatar dhirajt avatar diskun avatar hirokiky avatar intgr avatar jezdez avatar jieter avatar kendas avatar mothsart avatar mxsasha avatar nagisa avatar pauloxnet avatar raphaelm avatar sandeepn06 avatar silviomoreto avatar slafs avatar spapas avatar strongriley avatar submarcos avatar theju avatar timgraham avatar treyhunner avatar vladimirnani avatar xrmx avatar yakky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-localflavor's Issues

Documentation build is failing?

I tried changing and building the documentation for localflavor, but it keeps failing with complicated errors. It seems that readthedocs builds are failing with the same error, and have been for a long time. Here's the build output: https://readthedocs.org/builds/django-localflavor/1915723/

The errors are:

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
During handling of the above exception, another exception occurred:
[...]
django.core.exceptions.AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.

Perhaps in the long run, doc builds should be added to Travis-CI so new pull requests don't break it any more?

First running of tox will be fail.

The first running tox will be fail, when installing pacakes.
Please try removing .tox/ dir and re-run tox, now.

You can watch a errror like this:

ERROR: could not install deps [Django==1.5.1, -r/Users/hirokiky/dev/django-localflavor/django-localflavor/tests/requirements.txt]

This means the Django's installation is specified from two points:

  • deps = Django==1.5.1 (in tox.ini directory)
  • Django (in tests/requirements.txt)

(But, Installation from github/...zip (like https://github.com/django/django/archive/stable/1.6.x.zip) will not raise any errors.)

My environment:

  • pip: 1.3.1
  • tox: 1.5.0

Now, I try running the tox after removing a line Django in requirements.txt (It's just for testing docs.)

ROIBANField no longer needed because a generic IBAN field now exists

I just wanted to point out the the ROIBANField isn't really needed anymore now that there's a generic IBANField which validates all countries. You can find the django app here:

https://github.com/benkonrath/django-iban

I'm not sure if you want to deprecate that field or some how indicate that the generic field can be used. I'm filing this issue more to document that using django-iban is probably a better way forward for IBANs.

South introspection rules

Changing from django.localflavor to this package results in South complaining about custom fields. (django.localflavor fields are whitelisted in South, these aren't.)

Models Need Deconstruct Methods?

I'm just upgrading to Django 1.7 and I'm learning about the deconstruct methods that are required on custom fields.

I use the US localflavor and I'm quite surprised that deconstruct methods haven't been added? Looking further, it seems there's no deconstruct method for any flavor.

Is there a deliberate reason for this? If not, I'll write a quick PR to add these to US, but I don't have time to do it for all the locales.

Thanks.

US State vs US Postal Code

class USStateField(CharField):
    description = _("U.S. state (two uppercase letters)")

class USPostalCodeField(CharField):
    description = ("U.S. postal code (two uppercase letters)")
    kwargs['maxlength'] = 2

Shouldn't the postal code field contain digits? Seems like it was accidentally copied from the State field.

using USStateField form field with USStateSelect form widget

Hi,

Is there a form field that can be used with the USStateSelect widget?

The USStateSelect form widget uses the STATE_CHOICES list whereas the USStateField form field uses the STATES_NORMALIZED which does not contain all of the possible values displayed by the widget.
For example, "Armed Forces Americas" (value="AA") is in the dropdown list but will always trigger an error because it is unknown by the form field.

Thanks

ImportError: cannot import name truncate_words on django 1.8

I am using django 1.8 and my code is as below.

from django.db import models
from localflavor.pk.models import PKStateField

class Location(models.Model):
    city = models.CharField(max_length=64)
    state = PKStateField(default="PK-IS", blank=True)

and I am getting this error -
ImportError: cannot import name truncate_words

Tests fail with Django 1.6

py26-1.5: commands succeeded
ERROR: py26-1.6: commands failed
py27-1.5: commands succeeded
ERROR: py27-1.6: commands failed
py32-1.5: commands succeeded
ERROR: py32-1.6: commands failed
py33-1.5: commands succeeded
ERROR: py33-1.6: commands failed

The error:

from django.db.backends.utils import typecast_timestamp
ImportError: No module named 'django.db.backends.utils'

localflavor-it: wrong error string in ITSocialSecurityNumberField

The original error string in it/forms.py is "Enter a valid Social Security number." that is literally translated in the Italian language file.

While this is good for the same string in another context (e.g. the Mexican forms.py) it has the wrong meaning if used in Italian applications; the error string should be something like "Enter a valid Fiscal Code" or "Inserisci un Codice Fiscale valido".

The string "Inserisci un numero di Assistenza Sociale valido" cannot be understood by Italian non English-speaking people.

tox broken

When running tox I get:

Double requirement given: Django (from -r /home/trey/repos/django/django-localflavor/tests/requirements.txt (line 9)) (already in Django==1.5.1, name='Django')

This problem is resolved by removing Django from tests/requirements.txt

VAT numbers

Hi,
Is it the right place to add VAT Number Fields, Forms and Validators for each countries ?

Add change log

I propose that we add a CHANGES.rst file to record changes between versions. This would allow users to see when a release was made and the differences between the releases.

I usually forget to populate my CHANGES.rst files after merging each pull request so I tend to run git cherry -v 1.0 (where 1.0 is the last version tag) to see the changes since the last release.

Example: https://github.com/carljm/django-model-utils/blob/master/CHANGES.rst

South support

Any plans to add support for South. I just tried creating a schema migration on a model that had a PhoneNumberField and it failed because it was missing the south introspection rules.

Localization of date formats

I am a bit puzzled by the missing localization of date formates, e.g.
10th September 2014 (en)
10. September 2014 (de)
2014年09月10日 (zh)

Is this covered by Django core? Or should this be contributed?

USStateField fails on armed forces "state"

When using the form field class USStateField with the USStateSelect widget, the list of states includes ARMED_FORCES_STATES (Armed Forces Americas, Europe, Pacific) but the clean method fails validation because those states are not in STATES_NORMALIZED.

local-flavor NL: add model fields, renaming, testing, deprecating.

As mentioned in this PR comment I'm about to do some work on the Dutch local-flavor fields. While working on reorganizing and adding the model fields and tests, a couple of questions rise:

  • Since everyone is now required to use IBAN, there is no use for NLBankAccountNumber* anymore. I suggest removing(or at least deprecating) it.
  • The term 'Sofinummer' is succeeded in common use by the term 'Burger Service Nummer', I suggest renaming SoFi to BSN. (There is an edge case)
  • It seems to be common to call model fields FooField and form fields FooFormField. This is not pattern used for the current fields. Should we rename the form fields?

cc @benkonrath

Wrong french translation for XXXX zip code

The following translation in fr is wrong:

#: at/forms.py:25 ch/forms.py:29 no/forms.py:24
msgid "Enter a zip code in the format XXXX."
msgstr "Saisissez un code postal norvégien au format XXXX."

It is specific to the novergian zip code whilst the same translation string is used for austrian and swiss zip codes. Stripping "norvégien" should do the trick.

Cannot override Canadian invalid postal code error message

I tried to override the error message for an invalid Canadian postal code using:

CAPostalCodeField(
    error_messages={'invalid': 'Enter a postal code in the format A0A 0A0.'}
)

That does not work. However, this code to override the error message for an invalid US zip code does:

USZipCodeField(
    error_messages={'invalid': 'Enter a Zip code in the format 00000 or 00000-0000.'}
)

Problem seems to be in localflavor/ca/forms.py: raise ValidationError(self.default_error_messages['invalid'])

versus this in localflavor/us/forms.py: raise ValidationError(self.error_messages['invalid'])

Note that the same problem is likely in several places in localflavor/mx/forms.py and localflavor/si/forms.py where self.default_error_messages is also used.

Problem running tests

It would be nice to have some documentation on how to run tests (either they do not exist, or I'm unable to find it).

After some digging, I figured out that running invoke test is the way to go (correct me if I'm wrong).

Anyway, when trying to run invoke test --lang=dk, I get the following output:

Traceback (most recent call last):
  File "/home/valberg/.virtualenvs/localflavortest/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
    self._setup(name)
  File "/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/django/conf/__init__.py", line 134, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'tests.settings' (Is it on sys.path?): No module named tests.settings

I'm running it in a virtualenv (using virtualenvwrapper) with the following packages (pip freeze):

Django==1.5.4
argparse==1.2.1
coverage==3.6
distribute==0.6.34
django-discover-runner==1.0
flake8==2.0
invoke==0.4.0
mccabe==0.2.1
pep8==1.4.6
pyflakes==0.7.3
six==1.3.0
wsgiref==0.1.2

My sys.path is as follows (printed from tasks.py):

[
    '/home/valberg/Documents/code/public/django-localflavor',
    '/home/valberg/.virtualenvs/localflavortest/bin',
    '/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg',
    '/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
    '/home/valberg/.virtualenvs/localflavortest/lib/python2.7',
    '/home/valberg/.virtualenvs/localflavortest/lib/python2.7/plat-x86_64-linux-gnu',
    '/home/valberg/.virtualenvs/localflavortest/lib/python2.7/lib-tk',
    '/home/valberg/.virtualenvs/localflavortest/lib/python2.7/lib-old',
    '/home/valberg/.virtualenvs/localflavortest/lib/python2.7/lib-dynload',
    '/usr/lib/python2.7',
    '/usr/lib/python2.7/plat-x86_64-linux-gnu',
    '/usr/lib/python2.7/lib-tk',
    '/home/valberg/.virtualenvs/localflavortest/local/lib/python2.7/site-packages',
    '/home/valberg/Documents/code/public/django-localflavor'
]

Any ideas?

CIF validator for es

In Spain we have bussiness with J letter on CIF, the type of bussiness is SCP (example http://www.tresmanagers.com/aviso-legal/).

For full functionally of CIF validator, you have to insert J in in es/forms.py, self.cif_types.

I tested in my local web (in development) and function ok.

BRPhoneNumberField not working

I don't know if it's some conflict with my code. For me the input is always invalid even when i use the format xx-xxxx-xxxx on the form. I solved it cleaning the '-' minus myself, like this:

class CustomerAddressForm(forms.ModelForm):
contact_phone = BRPhoneNumberField(help_text='XX-XXXX-XXXX ou XX-XXXXX-XXXX ou só os digitos')
(...)
def clean_contact_phone(self):
self.cleaned_data['contact_phone'] = self.cleaned_data['contact_phone'].replace("-", "")
return self.cleaned_data['contact_phone']

After writing this method, it worked. Is this normal, can you reproduce the situation?

Fixed label for form fields objects

Since django.contrib.localflavor move to localflavor,
a problem is occuring.

Every FR (france) FormField object have its label fixed in the init method

example: localflavor/fr/forms.py - line 28

def __init__(self, max_length=5, min_length=5, *args, **kwargs):
    kwargs['label'] = _('Zip code')

Must be:

def __init__(self, max_length=5, min_length=5, *args, **kwargs):
    kwargs['label'] = kwargs.get('label', _('Zip code'))

It permits to specify custom labels for many occurence of a field in the same form.

(Ex: 'Phone 1', 'Phone 2', 'Phone 3' labels for three FRPhoneNumberField, unlike 'Phone Number', 'Phone Number', 'Phone Number')

Every FormField in FR locale package is concerned

Proposal: Interface for using country submodules generically

The use case is having a country selector and then based upon the country that is selected displaying a select input field for the regions for that country. I am doing this for a client currently so this gist is hardcoded a bit for their needs (not options expansion for the field, etc.) but wouldn't take much to make this more generally usable.

I recognize that it would be hard to make this pattern cover ALL uses the different locale specific constants/objects, but if this approach I am taking would be generally useful for inclusion in this package, i would be happy to work on something for a proper PR.

https://gist.github.com/paltman/7551838

Any feedback/thoughts?

ZipCodeField should ignore whitespace

Zip entered as " XXXXX" or "XXXXX " is marked as invalid. This happens before form.clean so something like

def clean(self):
... snip ...
      for key, value in cleaned_data.items():
            if isinstance(value, basestring):
                cleaned_data[key] = value.strip()
... snip ...

in the form's clean method doesn't help.

-- edit --
forgot to mention this is for the US ZipCodeField. Not sure if spaces are important in other zip codes

Add field for US VIN

17 characters, without I, O and Q, capitalize automatically including lookups.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.