Best Practice for blog app with both News and Articles [closed]

Recently I started working on a news app which has both news and articles. I'm looking for best approach for my app's model.

I can create Post model then News and Article model inherit from it by using Abstract inherit,

or I can have News and Article model with duplicated fields ( bad idea )

or maybe I can use django polymorphism

Maybe I'm wrong and I should specify only a field in my post model to declare that post is news or article.

I would recommend using a single Post model with a type field, unless News and Articles have significantly different data structures or behaviors.

The key question is whether News and Articles are actually different entities or simply two categories of the same content entity.

If they share most of their fields and behavior (title, slug, content, author, publication date, status, etc.), a single model is usually the simplest and most maintainable approach.

If they eventually develop type-specific fields, you can still keep a shared Post model and introduce separate detail models such as NewsDetails and ArticleDetails, linked to Post through a OneToOneField. This gives you the flexibility of separate data structures without necessarily introducing Django's multi-table inheritance.

Вернуться на верх