A simple Django app to filter objects related by language
Project description
=====
Location Maps
=====
Location é um projeto para simplificar todas as implementações de mapas no admin do django
Quick start
-----------
1. Add "location" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...
'field_translate',
]
2. Example usage::
# models.py
from django.conf import settings
class ExampleRelationModel(models.Model):
lang = models.CharField(max_length=10, blank=False, choices=settings.LANGUAGES)
title = models.CharField(max_length=255, )
class ExampleModel(models.Model):
lang = models.CharField(_('Idioma'), max_length=10, blank=False, choices=settings.LANGUAGES)
title = models.CharField(max_length=255, )
field_relation = models.ManyToManyField(ExampleRelationModel, blank=False)
# forms.py
from field_translate.widgets import ModelMultiChoiceWidget
class ExampleAdminForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ExampleAdminForm, self).__init__(*args, **kwargs)
self.fields['field_relation'].widget = ModelMultiChoiceWidget(queryset=ExampleRelationModel.objects.all())
# admin.py
class ExampleAdmin(admin.ModelAdmin):
form = ExampleAdminForm
def get_changeform_initial_data(self, request):
return {'lang': request.user.lang}
3. Start the development server and visit http://127.0.0.1:8000/admin/
to visit the example form (you'll need the Admin app enabled).
Location Maps
=====
Location é um projeto para simplificar todas as implementações de mapas no admin do django
Quick start
-----------
1. Add "location" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...
'field_translate',
]
2. Example usage::
# models.py
from django.conf import settings
class ExampleRelationModel(models.Model):
lang = models.CharField(max_length=10, blank=False, choices=settings.LANGUAGES)
title = models.CharField(max_length=255, )
class ExampleModel(models.Model):
lang = models.CharField(_('Idioma'), max_length=10, blank=False, choices=settings.LANGUAGES)
title = models.CharField(max_length=255, )
field_relation = models.ManyToManyField(ExampleRelationModel, blank=False)
# forms.py
from field_translate.widgets import ModelMultiChoiceWidget
class ExampleAdminForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(ExampleAdminForm, self).__init__(*args, **kwargs)
self.fields['field_relation'].widget = ModelMultiChoiceWidget(queryset=ExampleRelationModel.objects.all())
# admin.py
class ExampleAdmin(admin.ModelAdmin):
form = ExampleAdminForm
def get_changeform_initial_data(self, request):
return {'lang': request.user.lang}
3. Start the development server and visit http://127.0.0.1:8000/admin/
to visit the example form (you'll need the Admin app enabled).
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
Close
Hashes for django-field-translate-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed1f6aee19f6c0b3d1addd84e2754e7bc59452ff490bea0b1be9a3e51537bba4 |
|
MD5 | 039a3af8c89b39375b855519ac7629be |
|
BLAKE2b-256 | 9ba72a2aeee9e46206fc8f592aa5d96fff5863b7269d245a22c48e1b65fb6b4b |