I am working in Django 1.8 and Python 3.5
I have 3 apps -> mainpage,login,signup and the directory is given in the picture
I am trying to import mainpage/models.py in login/forms.py But when I do it it give If there is anything else you people want me to post tell me what do I do in the comments ?
See Image
and yes
Please I have read this already but not working.Thanks in advance
TRACEBACK
Environment:
Request Method: GET
Request URL: http://localhost:8000/login
Django Version: 1.8
Python Version: 3.5.4
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mainpage',
'signup',
'login',
'rest_framework',
'corsheaders')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\base.py" in get_response
108. response = middleware_method(request)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\middleware\common.py" in process_request
74. if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in is_valid_path
647. resolve(path, urlconf)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
522. return get_resolver(urlconf).resolve(path)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
368. sub_match = pattern.resolve(new_path)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
240. return ResolverMatch(self.callback, args, kwargs, self.name)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in callback
247. self._callback = get_callable(self._callback_str)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in get_callable
106. mod = import_module(mod_name)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py" in import_module
126. return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\views.py" in <module>
2. from .forms import UserLoginForm
File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\forms.py" in <module>
2. from MajorProject.src.signup.models import allusers1
Exception Type: ImportError at /login
Exception Value: No module named 'MajorProject'
EDIT
According to #Alasdair's answer the error that is coming is this
ImportError at /login
No module named 'src.signup'
Environment:
Request Method: GET
Request URL: http://localhost:8000/login
Django Version: 1.8
Python Version: 3.5.4
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mainpage',
'signup',
'login',
'rest_framework',
'corsheaders')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\handlers\base.py" in get_response
108. response = middleware_method(request)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\middleware\common.py" in process_request
74. if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in is_valid_path
647. resolve(path, urlconf)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
522. return get_resolver(urlconf).resolve(path)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
368. sub_match = pattern.resolve(new_path)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in resolve
240. return ResolverMatch(self.callback, args, kwargs, self.name)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in callback
247. self._callback = get_callable(self._callback_str)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\site-packages\django\core\urlresolvers.py" in get_callable
106. mod = import_module(mod_name)
File "C:\Users\vaibhav2\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py" in import_module
126. return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\views.py" in <module>
2. from .forms import UserLoginForm
File "C:\Users\vaibhav2\PycharmProjects\MajorProject\src\login\forms.py" in <module>
3. from src.signup.models import allusers1
Exception Type: ImportError at /login
Exception Value: No module named 'src.signup'
signup is in the project directory (the one that contains manage.py). Therefore the import should be simply:
from signup.models import allusers1
Related
My project name is practice and my application name is testapp. This is my project structure:
django/bin/practice
\practice
-practice folder
-__init__.py
-settings.py
-urls.py
-wsgi.py
-testapp folder
-migrations folder
-templates folder
-index.html
-__init__.py
-admin.py
-models.py
-tests.py
-views.py
-manage.py
I have included my application name in INSTALLED_APPS in settings.py but I am still getting this error:
ImportError: no module named testapp in django
this is the error page
<pre>Environment:
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.8.5
Python Version: 2.7.8
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'testapp')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
119. resolver_match = resolver.resolve(request.path_info)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in resolve
365. for pattern in self.url_patterns:
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in url_patterns
401. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in urlconf_module
395. self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\lib\importlib\__init__.py" in import_module
37. __import__(name)
File "C:\Python27\Lib\site-packages\django\bin\practice\practice\urls.py" in <module>
22. url(r'^practice/', include(testapp.views.home))
Exception Type: NameError at /
Exception Value: name 'testapp' is not defined</pre>
Very specific stuff. I'm running a Bitnami Django stack cloud VM on Amazon. On two different "regular" machines, I could install requests by running sudo pip install requests, but it seems that Bitname uses it's own specific structure, and something is going wrong when installing requests that way. It can also be related to issue #2028, but it was fixed long time ago.
I have the following traceback:
Environment:
Request Method: GET
Request URL: http://54.94.226.137/
Django Version: 1.7.7
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'vz_base',
'vz_api',
'vz_admin',
'vz_user')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
98. resolver_match = resolver.resolve(request.path_info)
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
343. for pattern in self.url_patterns:
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
372. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/opt/bitnami/python/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
366. self._urlconf_module = import_module(self.urlconf_name)
File "/opt/bitnami/python/lib/python2.7/importlib/__init__.py" in import_module
37. __import__(name)
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/ProjetoVigZul/urls.py" in <module>
5. from vz_api import urls as api_urls
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/urls.py" in <module>
8. from vz_api import views
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/views.py" in <module>
14. from vz_api.dguard import DGuardManager, DGuardIntegrationException
File "/opt/bitnami/apps/django/django_projects/ProjetoVigZul/vz_api/dguard.py" in <module>
5. import requests, json
File "/opt/bitnami/python/lib/python2.7/site-packages/requests/__init__.py" in <module>
58. from . import utils
File "/opt/bitnami/python/lib/python2.7/site-packages/requests/utils.py" in <module>
25. from . import certs
Exception Type: ImportError at /
Exception Value: cannot import name certs
Website is live at http://54.94.226.137/, if anyone is interested.
sudo pip install --upgrade requests
solved that for me
I recently updated a project that was working with Django rest framework 2.4.2 to the newly 3.1 version but now I'm getting a:
'module' object has no attribute 'HStoreField'
That happens to all the endpoints including the "/"
Any suggestions?
my Django version is 1.8 and python 2.7.6
Traceback:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8.dev20140910173004
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest',
'rest_framework',
'geoposition',
'rest_framework_swagger',
'PIL',
'rest_framework.authtoken',
'corsheaders')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/Users/marcus/PycharmProjects/django-framework/django-trunk/django/core/handlers/base.py" in get_response
112. resolver_match = resolver.resolve(request.path_info)
File "/Users/marcus/PycharmProjects/django-framework/django-trunk/django/core/urlresolvers.py" in resolve
362. for pattern in self.url_patterns:
File "/Users/marcus/PycharmProjects/django-framework/django-trunk/django/core/urlresolvers.py" in url_patterns
398. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/marcus/PycharmProjects/django-framework/django-trunk/django/core/urlresolvers.py" in urlconf_module
392. self._urlconf_module = import_module(self.urlconf_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py" in import_module
37. __import__(name)
File "/Users/marcus/Google Drive/Spring2015/AppContest/MyApplication/Backend/Backend/urls.py" in <module>
3. from rest_framework import routers
File "/Library/Python/2.7/site-packages/rest_framework/routers.py" in <module>
23. from rest_framework import views
File "/Library/Python/2.7/site-packages/rest_framework/views.py" in <module>
91. class APIView(View):
File "/Library/Python/2.7/site-packages/rest_framework/views.py" in APIView
94. renderer_classes = api_settings.DEFAULT_RENDERER_CLASSES
File "/Library/Python/2.7/site-packages/rest_framework/settings.py" in __getattr__
206. val = perform_import(val, attr)
File "/Library/Python/2.7/site-packages/rest_framework/settings.py" in perform_import
158. return [import_from_string(item, setting_name) for item in val]
File "/Library/Python/2.7/site-packages/rest_framework/settings.py" in import_from_string
170. module = importlib.import_module(module_path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py" in import_module
37. __import__(name)
File "/Library/Python/2.7/site-packages/rest_framework/renderers.py" in <module>
20. from rest_framework import exceptions, serializers, status, VERSION
File "/Library/Python/2.7/site-packages/rest_framework/serializers.py" in <module>
1354. ModelSerializer.serializer_field_mapping[postgres_fields.HStoreField] = CharMappingField
Exception Type: AttributeError at /
Exception Value: 'module' object has no attribute 'HStoreField'
Installing the latest release candidate of Django 1.8 should fix the issue.
You are running 1.8.dev20140910173004, which already has support for some Postgres fields, but not for HStoreField yet. Django REST framework only checks for the django.contrib.postgres and then assumes that HStoreField is available too. For your version of Django that is not the case.
If pip install -u doesn't get you the latest version, try removing and reinstalling Django.
I'm getting this error:
No module named six
But if go to python and try:
import six
It works.
This is my full traceback:
Environment:
Request Method: GET
Request URL: http://queromaiseducacao.com.br/
Django Version: 1.6.5
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'simulado',
'south',
'multichoice',
'django.contrib.admin',
'social_auth')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/home/filipefr2/webapps/quiz/lib/python2.7/django/core/handlers/base.py" in get_response
99. resolver_match = resolver.resolve(request.path_info)
File "/home/filipefr2/webapps/quiz/lib/python2.7/django/core/urlresolvers.py" in resolve
339. sub_match = pattern.resolve(new_path)
File "/home/filipefr2/webapps/quiz/lib/python2.7/django/core/urlresolvers.py" in resolve
223. return ResolverMatch(self.callback, args, kwargs, self.name)
File "/home/filipefr2/webapps/quiz/lib/python2.7/django/core/urlresolvers.py" in callback
230. self._callback = get_callable(self._callback_str)
File "/home/filipefr2/webapps/quiz/lib/python2.7/django/utils/functional.py" in wrapper
32. result = func(*args)
File "/home/filipefr2/webapps/quiz/lib/python2.7/django/core/urlresolvers.py" in get_callable
97. mod = import_module(mod_name)
File "/home/filipefr2/webapps/quiz/lib/python2.7/django/utils/importlib.py" in import_module
40. __import__(name)
File "/home/filipefr2/webapps/quiz/quiz/simulado/views.py" in <module>
17. from pagseguro import Payment
File "/home/filipefr2/lib/python2.7/pagseguro/__init__.py" in <module>
2. from pagseguro.api.v2.payment import Payment as PaymentV2
File "/home/filipefr2/lib/python2.7/pagseguro/api/v2/payment.py" in <module>
10. import dateutil.parser
File "/home/filipefr2/lib/python2.7/dateutil/parser.py" in <module>
24. from six import text_type, binary_type, integer_types
Exception Type: ImportError at /
Exception Value: No module named six
There is this library that I would like to get familiar with called django-schedule, there is a project sample they say is up and running, the thing is it's not currently updated to django 1.4 but there is a fork with a pull request that updates it https://github.com/Natim/django-schedule
But when running it i get an error that i think is this
(r'^schedule/', include('schedule.urls')),
I installed the with setup.py what do you think i have to do to get this up and running?
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.admindocs',
'schedule')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
Traceback:
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/handlers/base.py" in get_response
89. response = middleware_method(request)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/middleware/locale.py" in process_request
21. check_path = self.is_language_prefix_patterns_used()
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/middleware/locale.py" in is_language_prefix_patterns_used
54. for url_pattern in get_resolver(None).url_patterns:
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/urlresolvers.py" in url_patterns
328. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/urlresolvers.py" in urlconf_module
323. self._urlconf_module = import_module(self.urlconf_name)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.py" in import_module
35. __import__(name)
File "/home/brian/code/django-schedule/project_sample/../project_sample/urls.py" in <module>
10. (r'^schedule/', include('schedule.urls')),
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/conf/urls/__init__.py" in include
24. urlconf_module = import_module(urlconf_module)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/utils/importlib.py" in import_module
35. __import__(name)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/django_schedule-0.5b-py2.7.egg/schedule/urls.py" in <module>
4. from schedule.feeds import UpcomingEventsFeed
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/django_schedule-0.5b-py2.7.egg/schedule/feeds/__init__.py" in <module>
2. from django.contrib.syndication.feeds import FeedDoesNotExist
Exception Type: ImportError at /
Exception Value: No module named feeds
I'm looking at the same problem. I think the issue is that this is deprecated:
from django.contrib.syndication.feeds import FeedDoesNotExist
And should be replaced with:
from django.contrib.syndication.views import FeedDoesNotExist
This got me past the error you report.