Im begineer on django. Im try create multilanguage blog.
I use django 2.1.2 and Python 3.7.1
Now, i can easily translate urls, keywords, etc use to "gettext_lazy
" and working awesome...
But i can't find any way or plugin for translate my posts models.
I try install django-modeltranslation but i cant use. I think this plugin is incompatible with my django version... Because i take _clone() got an unexpected keyword argument '_rewrite'
error all time.
I have no idea how to solve it.
What is solution best way for translate for my posts?
I want see my Articles in admin like this; https://image.ibb.co/kiuFFA/Screenshot-16.jpg
setting.py lang like settings like this;
from django.utils.translation import gettext_lazy as _
LANGUAGE_CODE = 'en'
LANGUAGES = (
('de', _('Deutsch')),
('en', _('English')),
)
MULTILINGUAL_LANGUAGES = (
"en",
"de",
)
my base urls.py like this;
from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import gettext_lazy as _
urlpatterns = [
path('i18n/', include('django.conf.urls.i18n')),
]
urlpatterns += i18n_patterns(
path(_('admin/'), admin.site.urls, name="admin"),
path(_('about/'), views.about, name="about"),
path(_('contact/'), include("contact_form.recaptcha_urls")),
path('', include("article.urls")),
path(_('user/'), include("user.urls")),
path('', views.index, name="index"),
prefix_default_language=True,
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
my model.py like this;
class Article(models.Model):
author = models.ForeignKey("auth.User",on_delete = models.CASCADE, verbose_name="Author")
title = models.CharField(max_length = 120, verbose_name="Title")
category = models.ForeignKey('Category', on_delete = models.CASCADE, null=True, blank=True)
content = RichTextField(verbose_name="Content")
created_date = models.DateTimeField(auto_now_add=True, verbose_name="Created Date")
image = models.ImageField(blank=True, null=True, verbose_name="Add image (.jpg .png)")
slug = models.SlugField(unique=True, max_length = 130)
def __str__(self):
return self.title
and my admin.py like this;
@admin.register(Article)
class ArticleAdmin(admin.ModelAdmin):
list_display = ["title", "category", "created_date", "author"]
list_display_links = ["title", "author", "created_date"]
search_fields = ["title","content"]
list_filter = ["created_date","author"]
prepopulated_fields = {"slug":('title',)}
Thank you very much in advance.