A simple Django app to filter objects related by language
Project description
=====
Field Translate
=====
Field Translate
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).
Field Translate
=====
Field Translate
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
Built Distributions
Close
Hashes for django-field-translate-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaf77a161da700c4586310ef18133fc968fa8d4c3ddf599909ee7f879ba6cd6e |
|
MD5 | 58766ac7b7993e14dc52b2a31cc2cb9b |
|
BLAKE2b-256 | 389c3fc0b225975bd368bbc1d1f8750d85110ff4e08ccea0682be5edad077953 |
Close
Hashes for django_field_translate-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea88f7293cec118e535f95f4132b4dbfad8974f273f74fc57a7c8ad5e2e8db07 |
|
MD5 | 29b16f2a5548814d40244cc363767476 |
|
BLAKE2b-256 | b84392675c34dc3f8f5117c182c9533e5ee119aeda1fd990323130a090770a77 |
Close
Hashes for django_field_translate-0.1.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43cada45c7f46d0e2fd7f1da73cbd13242b3c8887645ba63b7626d7010029a11 |
|
MD5 | c79209c36aa79cd3ce29d794003c2d6d |
|
BLAKE2b-256 | d7c51c17de021ab02c11487267b55deb7d1f4f435cded2eddd8aee2394914801 |