Anoop K George
Anoop K George

Reputation: 1755

contenttypes framework in Django

I am reading Django documentation (https://docs.djangoproject.com/en/3.0/ref/contrib/contenttypes/#module-django.contrib.contenttypes).

I did not understand content type app, the Django docs describe it as below

Django includes a contenttypes application that can track all of the models installed in your Django-powered project, providing a high-level, generic interface for working with your models.

Can someone explain this from beginner perspective ?

I have experience in developing websites in Django but never touched in this app.

Upvotes: 1

Views: 65

Answers (2)

fannik
fannik

Reputation: 1153

Example: you want to make user-related logging, something like an audit module in user profile. You have dozen of models that could be logged. User, Order, Task, Product, etc. So your main model will be something like AuditEntity. How to make it general for all possible current (and future models) that could be logged here? Which type of field do you need? The answer is Django contenttypes. If you want - try to implement such a model's structure to understand how it works.

Upvotes: 2

Daniele Compagnoni
Daniele Compagnoni

Reputation: 11

I think that what is trying to tell you is that you can have different content (in blocks, as it is organized in "blocks" and it is very "module friendly", I hope to give the idea), this content is made up of different things, especially models, let's just say that they are like big classes of things needed in your application (don't judge this expression, I know it is not professional but is the more beginner friendly I can write now), hope this makes more clear!

Upvotes: 1

Related Questions