=========
.. image:: https://travis-ci.org/solvo/crdist.svg
:target: https://travis-ci.org/solvo/crdist
Costa Rican Geografic distribution for model admin in Django.
Now django 1.11 compatible.
.. note::
The data is in Spanish.
All source code is in English and of course it is spanish translated.
Installation
-------------
Install crdist in your python environment
1- Download and install package:
.. code:: bash
$ pip install crdist
Through Github:
.. code:: bash
$ pip install git+https://github.com/solvo/crdist.git
Put crdist in your INSTALLED_APPS
.. code:: python
INSTALLED_APPS = (
...
'crdist',
)
Include crdist in your urls.py
.. code:: python
from django.conf.urls import url, include
urlpatterns = [
url(r'^crdist/', include("crdist.urls")),
]
Run migration
.. code:: bash
$ python manage.py migrate
Usage
---------
In your models create a Foreign relation to District in your *models.py* file.
.. code:: python
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.
.. code:: python
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.
.. code:: python
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.
Javascrit triggers
-------------------------
- load_canton { "dist": 'div_district_' + name, "canton": 'div_canton_' + name }
- load_district { "dist": 'div_district_' + name }
.. code:: javascript
document.addEventListener("load_canton", function(e) {
console.log(document.cantoncrdist.dist);
console.log(document.cantoncrdist.canton); // id of divs
});
Metadata
Release files for crdist 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| crdist-0.1.7.tar.gz | 26.2 kB | Without provenance | Details for crdist-0.1.7.tar.gz |
Release files / crdist-0.1.7.tar.gz
| Download URL | crdist-0.1.7.tar.gz |
|---|---|
| Size | 26.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d7d2ca9f4d8461232a8824f687f2b0042cced1dbf7ec4c146a72f3a3dcbd9679
|
|
BLAKE2b-256 checksum How to use checksums |
d11a55170dcd8cdec96a768e29d461cc46ee8dad6357760f64961cfe77ba22a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.5
|
Security for crdist 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.