A
A
Andrey2015-01-29 09:13:06
Django
Andrey, 2015-01-29 09:13:06

What is the correct way to name models in Django?

Hello!
How to properly name models pulled by ForgienKey

Category
Tag
Post

Or
PostCategory
PostTag
Post

?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yeletsky, 2015-01-29
@Tiendil

Name after the name of the application for which the models are defined, as it carries additional semantics. Therefore, if only tags of the same type are expected in the application, then it is not necessary to specify what they refer to. If tags are expected for different entities (which, for tags, is strange), then it must already be specified.
Most likely you will have something like

from forum import models as forum_models

do_smth_wiht(forum_models.Post)
do_smth_wiht(forum_models.Tag)

If a

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question