Answer the question
In order to leave comments, you need to log in
How to display editing for ManyToManyFiled model in admin panel?
I'm making a tagging system for the site now.
There are two models (Article and Tag).
class Article(models.Model):
article_categore = models.CharField(max_length=200, default=1, choices=Article_CHOICES, help_text="Категория статья - для фильтра", verbose_name="Категория статьи")
article_body = models.TextField(help_text="Полное описание текста", verbose_name="Тело статьи")
#Таг для статьи
class Tag(models.Model):
name = models.CharField(max_length = 25, default=1)
main = models.ManyToManyField(Article, related_name='tags')
class TagType(admin.TabularInline):
model = Tag
max_num = 3
admin.site.register(Tag, TagType)
class ArticleType(admin.ModelAdmin):
model = Article
fields = ['article_categore', 'article_body']
nlines = [
TagType,
]
admin.site.register(Article, ArticleType)
Answer the question
In order to leave comments, you need to log in
In short, I've been digging all day. Bottom line:
1) This thing is not officially supported by Django.
2) There are various frauds with bringing two models into a third one (intermediary) for tuning, but there is also some kind of sodomy there.
3) There are speculative API-based solutions that do shuttle races and prescribe and create models. But it also does not inspire confidence.
Generally!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question