flake8-django icon indicating copy to clipboard operation
flake8-django copied to clipboard

Adding a checker for model styles

Open franciscouzo opened this issue 2 years ago • 2 comments

https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#model-style

Specifically the following part:

The order of model inner classes and standard methods should be as follows (noting that these are not all required):

  • All database fields
  • Custom manager attributes
  • class Meta
  • def __str__()
  • def save()
  • def get_absolute_url()
  • Any custom methods

I'm interested in writing this checker, but I wanted first to confirm if there would be interest in getting it merged.

franciscouzo avatar Feb 18 '23 04:02 franciscouzo

Isn't that DJ12?

MHLut avatar Mar 09 '23 12:03 MHLut

Found the problem, on the pyproject.toml file it should be "DJ = …", instead of "DJ0 = …", that's why it wasn't running.

It would also be nice if it could detect if you’re inheriting from another class.

On Thu, 9 Mar 2023 at 13:31 Marijke Luttekes @.***> wrote:

Isn't that DJ12 https://github.com/rocioar/flake8-django/wiki/%5BDJ12%5D-Order-of-Model's-inner-classes,-methods,-and-fields-does-not-follow-the-Django-Style-Guide ?

— Reply to this email directly, view it on GitHub https://github.com/rocioar/flake8-django/issues/107#issuecomment-1461961722, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJK2L46K4UWJ5KNCZDFAFLW3HETNANCNFSM6AAAAAAVADWSVY . You are receiving this because you authored the thread.Message ID: @.***>

franciscouzo avatar Mar 10 '23 03:03 franciscouzo