Getting rid of empty models.py in django testsuite

£可爱£侵袭症+ 提交于 2019-12-23 07:44:08

问题


I have two pure service apps, that act as servant to my core models. Hence, they do not have any own models.

While the testsuite for the first service runs fine, the second throws the following error:

django.core.exceptions.ImproperlyConfigured: 
App with label location is missing a models.py module. 

If I add an empty models.py, the suite runs fine.

I can't spot a difference in terms of architecture / structure between the apps. But I want to get rid of the empty, unneeded models.py.

How would I do that?


回答1:


Update: What you ask is now possible. With Django 1.7 you no longer need a models.py file. -release notes

Previously: Django testing requires every app to have a models.py file. It's okay to leave it empty (or with a helpful comment!). Ticket discussion on the matter of apps without models. Direct from the code (added in 1.4/still in 1.5):

the test runner won't currently load a test module with no models.py file




回答2:


As far as I know, it is necessary to include a 'models.py' module on every Django application to make it run properly



来源:https://stackoverflow.com/questions/15202424/getting-rid-of-empty-models-py-in-django-testsuite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!