-1

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'
dddar
  • 27
  • 2
  • 9
  • Please don't post screenshots of code. Copy and paste the import that isn't working. Screenshots are ok for showing directory structure, but text is even better. For windows see [this question](https://stackoverflow.com/questions/9518646/tree-view-of-a-directory-folder-in-windows). – Alasdair Feb 20 '18 at 17:14
  • src contains everything so it is the main directory – dddar Feb 20 '18 at 17:22

1 Answers1

1

signup is in the project directory (the one that contains manage.py). Therefore the import should be simply:

from signup.models import allusers1
Alasdair
  • 298,606
  • 55
  • 578
  • 516