Answer the question
In order to leave comments, you need to log in
How to register a django model?
Hello, there are 3 models.
class Category(models.Model):
name = models.CharField(max_length=100)
slug = models.SlugField(max_length=50, verbose_name=u"url")
def __unicode__(self):
return self.name
class Post(models.Model):
title = models.CharField(max_length=150, null=True, verbose_name=u"Название")
content = models.TextField(verbose_name=u"Текст")
category = models.ForeignKey(Category, verbose_name=u"Категория")
slug = models.SlugField(max_length=50, verbose_name=u"url")
class PostAdmin(admin.ModelAdmin):
list_display = ("title", "category")
search_fields = ('title', 'category')
admin.site.register(MarkdownModelAdmin)
admin.site.register(Post,PostAdmin)
admin.site.register(Category)
admin.site.register(Post,MarkdownModelAdmin)
admin.site.register(PostAdmin)
admin.site.register(Category)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question