I install my application in "project/apps/myapp" folder. Both apps and myapp folders have init.py files(Without any of them there is module missing error). Now I've the error:
Exception Type: RuntimeError at /
Exception Value: Conflicting 'person' models in application 'resume': <class
'apps.resume.models.Person'> and <class 'resume.models.Person'>.
Django import the same model with two different pathes. How can I fix it?
Full error log:
Traceback:
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
98. resolver_match = resolver.resolve(request.path_info)
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
343. for pattern in self.url_patterns:
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
372. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
366. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py" in import_module
37. __import__(name)
File "/home/voxa/django/FortyTwoTestTask/fortytwo_test_task/urls.py" in <module>
4. from resume import views
File "/home/voxa/django/FortyTwoTestTask/apps/resume/views.py" in <module>
4. from resume.models import Person
File "/home/voxa/django/FortyTwoTestTask/apps/resume/models.py" in <module>
3. class Person(models.Model):
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/db/models/base.py" in __new__
285. new_class._meta.apps.register_model(new_class._meta.app_label, new_class)
File "/home/voxa/.virtualenvs/42-test/local/lib/python2.7/site-packages/django/apps/registry.py" in register_model
213. (model_name, app_label, app_models[model_name], model))
Exception Type: RuntimeError at /
Exception Value: Conflicting 'person' models in application 'resume': <class 'apps.resume.models.Person'> and <class 'resume.models.Person'>.
Instead of importing the all project then the app then the module inside the app just import the app which is inside the project then the module.
Instead of
from webproject.app import model
Use
from app import model
or
from app.models import Staffs
I think this bug report (turns out it's a feature) is related to your problem.
For me the problem was resolved by importing from resume.models
only, rather than apps.resume.models
. So search for "from apps."
in your project and replace it.
(For me, removing __init__.py
or changing the PYTHONPATH
caused other problems, I imagine that's common.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With