i have 3 languages in my site
but when i call all parts in the index, it is not going to translate in the SHQIP language
Please who knows how to call in current lang
i am calling like this {{ parts.category }} it returns base language
parts = AutoPartsEntry.objects.all().filter(is_active=True)[:4] # this calls all Auto Parts in the list
cat = AutoCategory.objects.translate(translation.get_language()) # this calls all Translations category in the list
class AutoPartsEntry(models.Model):
user = models.ForeignKey(MyUser, on_delete=models.CASCADE)
category = models.ForeignKey(AutoCategory, on_delete=models.CASCADE)
brand = models.ForeignKey(CarBrands, on_delete=models.CASCADE)
model = models.ForeignKey(CarModels, on_delete=models.CASCADE)
submodel = models.CharField(max_length=255, blank=True)
description = models.TextField(blank=True)
state = models.CharField(max_length=200)
year = models.ForeignKey(CarYears, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
agreement = models.BooleanField(default=False)
price = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=255)
address = models.CharField(max_length=255)
phone = models.CharField(max_length=255)
is_active = models.BooleanField(default=False)class AutoCategory(Translatable):
value = models.CharField(
verbose_name='Category',
max_length=200,
)
class TranslatableMeta:
fields = ['value']
def __str__(self): # __unicode__ on Python 2
return self.value
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e3102911-166d-409a-81f3-4e222da69453%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment