I
I
Ilya2014-08-19 19:01:20
Django
Ilya, 2014-08-19 19:01:20

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')

I'm trying to connect the PostAdmin model:
This is how the model is connected, but MarkdownModelAdmin does not work
admin.site.register(MarkdownModelAdmin)
admin.site.register(Post,PostAdmin)
admin.site.register(Category)

And if so, then PostAdmin is not connected
admin.site.register(Post,MarkdownModelAdmin)
admin.site.register(PostAdmin)
admin.site.register(Category)

How to connect all these 4 models correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2014-08-19
@nuBacuk

class PostAdmin(MarkdownModelAdmin):
    # ...

admin.site.register(Post, PostAdmin)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question