Simple Django App for location tree
Project description
Simple application for location field as TreeForeignKey (see django-mptt) with form field.
Usage
# settings.py
INSTALLED_APPS += (‘mptt’, ‘locationstree’)
# models.py
- class Place(models.Model):
location = TreeForeignKey(‘locationstree.Location’)
# forms.py
- class PlaceForm(models.Model):
location = JustLeafsLocationField(queryset=Location.objects.all())
Context Processor
There is a context processor that sets Locations.objects.all() to context with the variable name by default locations.
# settings.py
CONTEXT_PROCESSORS += (‘locationstree.context_processors.locations’,)
The variable name is configurable via settings variable.
# settings.py
LOCATIONSTREE_CONTEXT_VARIABLE_NAME = ‘lugares_comunes’
It uses cache with the key name locationstree.locations and a TTL of 1 week configurable via settings variable.
# settings.py
LOCATIONSTREE_CACHE_TTL = 60 * 60 * 24 # 1 day
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for django-locationstree-0.0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 083a861c273a441d59c1a430497ebe1f9dd25901c6d8f25cede1c2aeff7e973e |
|
MD5 | 365db9de2feb16fde64075006586f619 |
|
BLAKE2b-256 | 233856ba3223dac04a5a8e0e1e416a054fae3e166aefa1e7e4e405a19e06885a |