Questions tagged [django-hvad]

django-hvad provides a high level API to maintain multilingual content in your database using the Django ORM.

django-hvad provides a high level API to maintain multilingual content in your database using the Django ORM.

37 questions
8
votes
1 answer

Model not found in migration (apps.get_model raises LookupError)

I have the following migration (logic removed for simplicity): def migrate_existing_discounts(apps, _): ModelA = apps.get_model('myapp', 'ModelA') ModelB = apps.get_model('myapp', 'ModelB') class Migration(migrations.Migration): …
dnaranjo
  • 3,373
  • 2
  • 22
  • 38
5
votes
2 answers

django-hvad - how should I set a translated field value while saving a model instance?

Background: I use django-hvad and have a TranslatableModel. In its TranslatedFields I have a slug attribute which should be automatically created using the title attribute while saving the model. Problem: It is difficult to set the value of one of…
Philipp Zedler
  • 1,520
  • 1
  • 13
  • 32
5
votes
2 answers

Django admin field validation to return error not raise exception in application

I have a Django model where it has an upload field for images, am trying to validate the image field to check image size before storing and return elegant error message for the user to correct. I tried to use the following code but it did not…
Mo J. Mughrabi
  • 5,969
  • 14
  • 68
  • 130
4
votes
3 answers

Django Admin Custom Widget for ForeignKey

It sounds like a trivial question, but it seems not so easy to answer: How would you display a ForeignKey field as a Checkbox in Django Admin and save the currently logged in user whenever this user checks the checkbox in Admin? Example: class…
Matthias Scholz
  • 915
  • 1
  • 9
  • 23
4
votes
2 answers

Translatable Manytomany fields in admin generate many queries

I am using django-parler (a derivative of django-hvad) for translations. In admin when displaying Foreignkey fields with manytomany relationship, django runs a single query for each: So when there are 300 services there would be as many queries. I…
Danial Tz
  • 1,544
  • 1
  • 12
  • 19
3
votes
0 answers

Django ORM: Copying a translation field from one model to another issues an error

I have the following model: class AModel(TranslatableModel): ...... other fields definitions ...... translations = TranslatedFields( name=models.CharField(max_length=100, blank=False, default=''), description=models.CharField(max_length=500,…
3
votes
1 answer

Django-hvad translate model of django-rest-framework

I'm trying to implement django-hvad on a django app but I'm getting an error when I'm trying to launch python manage.py runserver : File "/Users/Philippe/Documents/DjangoApp/env/lib/python3.6/site-packages/hvad/manager.py", line 265, in _clone …
Philippe
  • 819
  • 2
  • 10
  • 28
3
votes
0 answers

Manage multiple languages with django-hvad in one formset

I am using django-hvad to edit objects in different languages. I got a form (for the object) and a formset (for the objects attributes in different languages) as described in the documentation. The formset is shown in a tab per language which are…
Marius
  • 820
  • 9
  • 27
3
votes
1 answer

pip, PIL and Pillow

I ran the following command to install project dependencies into virtualenv novacek: (novacek) $ pip install -r reqs.txt reqs.txt looks like…
clime
  • 7,872
  • 8
  • 52
  • 80
2
votes
1 answer

Django HVAD and ForeignKey

I have simple app with: class NamedModel(TranslatableModel): code = models.CharField(max_length=120) translations = TranslatedFields( name=models.CharField(max_length=256), description=models.TextField() ) class…
Jeroj82
  • 341
  • 2
  • 11
2
votes
1 answer

How to get default language if requested translation unavailable

I'm using django-hvad for model translation, and not all of the models will have translations. I want the default to be en-us. If a request is made for a particular language, the response should be in that language if the model has that translation…
Kyle Falconer
  • 7,586
  • 5
  • 44
  • 63
2
votes
1 answer

Want to translate Django User model first_name and last_name - django 1.5

I want to translate my from django.contrib.auth.models import User Model's first_name and last_name. I am aware of Custom User Model in Django. But is there any better way of translating using django Hvad For reference i am attaching my Model…
2
votes
0 answers

Why does prefetch_related() raise AttributeError?

I have a model with a many-to-many relationship with a second model. When I try to use prefetch_related I get an AttributeError. The models could be summarised as: class AcademicSubject(TranslatableModel): translations = TranslatedFields( …
Hamish Downer
  • 15,325
  • 14
  • 82
  • 80
2
votes
1 answer

Django-hvad TranslatableAdmin with manager error

I'm trying to do this works admin.py class TapasInline(TranslatableStackedInline): model = Tapa can_delete = True extra = 0 verbose_name = 'Tapas' verbose_name_plural = 'Tapas' fields = ('name','description','photo',…
2
votes
0 answers

Using a TranslatableModel in a form ModelChoiceField

I've got a model which represents statuses for various languages so I'm using the django-hvad TranslatableModel base class. When used in a form the event_status field choices from the TranslatableModel are 1, 2 etc so Status.__unicode__ must be…
markwalker_
  • 9,401
  • 7
  • 51
  • 86
1
2 3