import this
или
from .models import this
1, если проект больше чем 1 модуль
Absolute or Relative imports? The ruling for absolute or relative imports is as follows: When importing files within a domain, you must use relative imports. When importing other domains in the same project, you must use absolute imports. When importing domains in tests, you should use absolute imports. When importing third-party packages you should use absolute imports. TL;DR - relative imports inside a domain, absolute for everything else! With this ruling domains are easy to package and move around. When it comes time to move it into it's own project; tidying up imports will be one less thing you have to do. (source: https://github.com/phalt/django-api-domains/blob/master/docs/styleguide.md#absolute-or-relative-imports)
Обсуждают сегодня