This is in Django 2.0 , python 3.6.5
I have an app called posts, and I changed models.py to a folder structure, i.e., create a directory models and move the file models.py insid. Also config __ init__.py file, as explained next. The project runs ok, but my test suite fails.
In my settings, installed apps i have the app as:
'myproject.apps.posts.apps.PostsConfig'My app config (posts/apps.py)
from django.apps import AppConfig
class PostsConfig(AppConfig):
name = 'posts'
verbose_name = 'posts' I have move posts/models.py to a directory structure. So I have
posts/models/models.py
posts/models/proxymodels.py
posts/models/__init__.pyinside models/__ init__.py I do import my models as explained in doc
from .models import Job
from .proxys import ActiveJobThe project works well, but when trying to run tests:
python manage.py testI have this error:
RuntimeError: Model class tektank.apps.posts.models.models.Job doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.The model is a normal one, with fields, nothing extrange. The thing is that if I declare in the meta
class Meta:
app_label = 'posts'I got the following error:
RuntimeError: Conflicting 'job' models in application 'posts': <class 'posts.models.models.Job'> and <class 'tektank.apps.posts.models.models.Job'>.Note: If I use pytest, I run the command:
pytestIt runs OK