Giter Club home page Giter Club logo

django-cep's Introduction

Python versions supported Travis PyPi

django-cep

This application enables Django powered websites to have autofilled address fields in forms based on brazilian CEP field.

Installation

To install django-cep simply run:

pip install django-cep

Configuration

We need to hook django-cep into our project.

Put cep into your INSTALLED_APPS at settings module:

INSTALLED_APPS = (
   ...
   'cep',
)

Bind the cep urls.py into your main urls.py with something like:

url(r'^cep/', include('cep.urls')),

Usage

Currently the only syntax supported is setting the IDs of the address fields in the widget of the CEP field. For other ways to set this up, see the NEXT-STEPS file.

  1. Import the django-cep widget CEPInput in your forms.py:

    from cep.widgets import CEPInput
  2. Set your CEP field for using the CEPInput, with the correct address fields ID, for example:

    my_cep_field = ChangeToMyCEPFieldModelName(label=u"CEP",
                            help_text="Format: XXXXX-XXX",
                            widget=CEPInput(address={
                                                     'street': 'id_street_field',
                                                     'district': 'id_district_field', 
                                                     'city': 'id_city_field',
                                                     'state': 'id_state_field'
                                                     }))

That stands for a street field ID equals id_street_field, district field ID equals id_district_field, city field ID equals id_city_field and a state field ID equals id_state_field.

Also note that the JavaScript used in this app requires JQuery to run properly.

It is highly recommended that you use Django Localflavor's BRStateChoiceField for the State field, to make it render the correct brazilian state from the list.

django-cep's People

Contributors

gutorc92 avatar nandel avatar suzukijessica avatar

Watchers

 avatar  avatar

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.