Skip to main content

Costa Rican Geografic distribution for model admin in Django.

Project description

https://travis-ci.org/solvo/crdist.svg

Costa Rican Geografic distribution for model admin in Django

Installation

Install crdist in your python environment

1- Download and install package:

$ pip install crdist

Through Github:

$ pip install git+https://github.com/solvo/crdist.git

Put crdist in your INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'crdist',
    )

Run migration

$ python manage.py migrate

Usage

In your models create a Foreign relation to District in your models.py file.

from crdist.models import District
class Test(models.Model):
    name = models.CharField(max_length=64)
    location = models.ForeignKey(District)

We provide a form widget specially for choose Province, Canton and District in the same widget. eg.

from crdist.widgets import DistrictSelect
from crdist.models import District

class CRForm(forms.Form):
    district = forms.ModelChoiceField(queryset=District.objects.all(),
                                  widget=DistrictSelect)

It’s also ok use with admin interface, you can add some code in your admin.py file.

class TestAdminForm(forms.ModelForm):
    class Meta:
        model = Test
        fields = '__all__'
        widgets = {
          'district': DistrictSelect(attrs={"class": "form-control"}),
        }


class TestAdmin(admin.ModelAdmin):
    form = TestAdminForm

admin.site.register(Test, TestAdmin)

We also support multiple relations in the same model, so you can display several widgets in the same page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crdist-0.1.3.tar.gz (24.4 kB view details)

Uploaded Source

File details

Details for the file crdist-0.1.3.tar.gz.

File metadata

  • Download URL: crdist-0.1.3.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for crdist-0.1.3.tar.gz
Algorithm Hash digest
SHA256 a1f787bbf0064508000e1339472a92c0d1c61ce8afa579d9092145b42310945d
MD5 7e7d81229e9f4ad3e6010f3cb5b539c1
BLAKE2b-256 f0806e0bb2bd22cc770c3d8bc1c542d2858822dc434a9f16aaf31f58ad63ac72

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page