Django model naming convention

前端 未结 4 831
轻奢々
轻奢々 2021-02-02 09:45

What is the preferred naming convention for Django model classes?

4条回答
  •  别那么骄傲
    2021-02-02 10:35

    As far as I know, the idea is that the class name should be singular and should use SentenceCase with no spaces. So you'd have names like:

    Person
    TelephoneNumber
    

    Then the Django admin tool knows how to pluralise them. Doesn't work so nicely for names like:

    Category
    

    which gets pluralised as Categorys, but there we go...

    Apart from that, just give it a name that means something to you and succinctly sums up what the class is meant to represent.

    Ben

提交回复
热议问题