I tried to start a app so that I can create a Login for my blog but I came by this error.
So I thought to post a question in stack over flow. I hope yu can take some time to answer my question.
This is the trace back error,
Traceback (most recent call last):
File "C:\Users\Selvi\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Users\Selvi\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "C:\simpleblog\virt\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\simpleblog\virt\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\simpleblog\virt\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = checks.run_checks(
File "C:\simpleblog\virt\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\simpleblog\virt\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\simpleblog\virt\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\simpleblog\virt\lib\site-packages\django\urls\resolvers.py", line 408, in check
for pattern in self.url_patterns:
File "C:\simpleblog\virt\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\simpleblog\virt\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\simpleblog\virt\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\simpleblog\virt\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Selvi\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\simpleblog\ablog\ablog\urls.py", line 8, in <module>
path('members/', include('members.urls')),
File "C:\simpleblog\virt\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Selvi\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'members.urls'
Here is the url for members
from django.urls import path
from .views import UserRegisterView
urlpatterns = [
path('register/', UserRegisterView.as_view()name='register'),
]
Here is the urls for ablog
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('myblog.urls')),
path('members/', include('django.contrib.auth.urls')),
path('members/', include('members.urls')),
]
Here is my views.py
from django.shortcuts import render
from django.views import generic
from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
class UserRegisterView(generic.CreateView):
form_class = UserCreationForm
template_name = 'registration/register.html'
success_url = reverse_lazy('login')
How do I solve this error.
At first Correct your urlpatterns:(you forgot , )
path('register/', UserRegisterView.as_view(),name='register'),
also make sure for migrations
I got the same problem and I was missing the urls.py file in my app.
Add urls.py file in members app.
Related
I am taking a course where this error does not occur
my error is cod is:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bo
otstrap_inner
self.run()
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\auto
reload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\manag
ement\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\manag
ement\base.py", line 392, in check
all_issues = self._run_checks(
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\manag
ement\base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\check
s\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\check
s\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\check
s\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resol
vers.py", line 407, in check
for pattern in self.url_patterns:
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\func
tional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resol
vers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\func
tional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resol
vers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 12
7, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\KursDjango\skcms\skcms\urls.py", line 22, in <module>
url(r'article/',include('articles.urls'))
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\conf.
py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 12
7, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\KursDjango\skcms\articles\urls.py", line 4, in <module>
url(r'^show_all/$', 'articles.views.articles'),
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\urls\
__init__.py", line 13, in url
return re_path(regex, view, kwargs, name)
File "C:\Users\wuoel\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\conf.
py", line 73, in _path
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
urls.py
from django.conf.urls import include, url from django.urls import
include
urlpatterns =('',
url(r'article/',include('articles.urls')) )
articles/urls.py
from django.conf.urls import *
urlpatterns =('',
url(r'^show_all/$', 'articles.views.articles'),
url(r'^(?P\d+)/$', 'articles.views.article'), )
It looks like you are passing the string representation of the name to include() rather than the actual articles.urls variable. Instead, it should look something like this:
from articles import urls as article_urls
...
urlpatterns =[
url(r'article/',include(article_urls, namespace='article'))
]
the problem is explained in this way:
skcms/urls.py
from django.urls import include, path
urlpatterns =[
path('article/',include('articles.urls')),
]
articles/urls.py
from django.urls import path
from . import views
urlpatterns =[
path('', views.articles, name='articles'),
path('', views.article, name='article'),
]
I am a total newbie to python Django and would like to know why are views not being created.
here's my urls.py which is under myproject.
from django.contrib import admin
from django.urls import path,include
from django.conf.urls import url
admin.autodiscover()
urlpatterns = ['',
path('admin/', admin.site.urls),
url('myapp/', include('myapp.url'))
]
here's my view.py which is in myapp folder
from django.shortcuts import render
# Create your views here.
def hello(request):
return render(request,"myapp/templates/hello.html", {})
here's my url.py in myapp folder
from django.conf.urls import include, url
urlpatterns = ['', url('hello/', 'views.hello', name='hello'),]
and here's the complete traceback
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/core/management/base.py", line 395, in check
include_deployment_checks=include_deployment_checks,
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/core/management/base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/urls/resolvers.py", line 407, in check
for pattern in self.url_patterns:
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/urls/resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/urls/resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/mayureshkadam/PycharmProjects/Learning-Django/myproject/myproject/urls.py", line 23, in <module>
url('myapp/', include('myapp.url'))
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/mayureshkadam/PycharmProjects/Learning-Django/myproject/myapp/url.py", line 3, in <module>
urlpatterns = ['', url('hello/', 'views.hello', name='hello'),]
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/conf/urls/__init__.py", line 13, in url
return re_path(regex, view, kwargs, name)
File "/home/mayureshkadam/Learning-Django/lib/python3.7/site-packages/django/urls/conf.py", line 73, in _path
raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
i've read a few tutorials and the code is being referred from https://www.tutorialspoint.com/django/django_url_mapping.htm but not sure why i am getting an error.
Just replace the url with path:
# main urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('myapp/', include('myapp.url'))
]
# app urls.py
from django.urls import path
from .view import hello
urlpatterns = [
path('hello/', hello, name='hello'),
]
As you can see in documetation, path has been introduced(from Django>=2.0), so you don't have to use url here. The tutorial you are following is for older versions, so it is using url with regex to generate URLs.
I am using an older version of django.After i run my code i get this error -"AttributeError: module 'django.contrib.auth.views' has no attribute 'LoginView'".I should get error if I use login instead of LoginView. Even after using login I get the same attribute error.
this is my urls.py-
from django.conf.urls import url
from django.contrib.auth import views as auth_views
from . import views
app_name = 'accounts'
urlpatterns = [
url(r"login/$",auth_views.LoginView.as_view(template_name="accounts/login.html"),name='login'),
url(r"logout/$", auth_views.LogoutView.as_view(), name="logout"),
url(r"signup/$", views.SignUp.as_view(), name="signup"),
]
this is my app's urls.py-
from django.conf.urls import url,include
from django.contrib import admin
from .import views
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$',views.HomePage.as_view(),name='home'),
url(r'^accounts/',include('accounts.urls',namespace='accounts')),
url(r'^accounts',include('django.contrib.auth.urls')),
url(r'^test/$',views.TestPage.as_view(),name='test'),
url(r'^thanks/$',views.ThanksPage.as_view(),name='thanks')
]
and views.py-
from django.shortcuts import render
from django.contrib.auth import login, logout
from django.core.urlresolvers import reverse_lazy
from django.views.generic import CreateView
from . import forms
class SignUp(CreateView):
form_class = forms.UserCreateForm
success_url = reverse_lazy("login")
template_name = "accounts/signup.html"
I got this result after making migrations.My app's name is accounts:-
(myDjangoEnv) C:\Users\saini computers\Desktop\simple_social_clone\simplesocial>python manage.py makemigrations accounts
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\management\base.py", line 342, in execute
self.check()
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\management\base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\management\base.py", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\utils\functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\urls\resolvers.py", line 313, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\utils\functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\urls\resolvers.py", line 306, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
Git
GitHub
Initialize a new project directory with a Git repository
Create repository
simplesocial\accounts\views.py14:1(13, 372)
LFUTF-8PythonGitHubGit (0)
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\saini computers\Desktop\simple_social_clone\simplesocial\simplesocial\urls.py", line 23, in <module>
url(r'^accounts/',include('accounts.urls',namespace='accounts')),
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\conf\urls\__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\saini computers\Anaconda3\envs\myDjangoEnv\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\saini computers\Desktop\simple_social_clone\simplesocial\accounts\urls.py", line 8, in <module>
url(r"login/$", auth_views.LoginView.as_view(template_name="accounts/login.html"),name='login'),
AttributeError: module 'django.contrib.auth.views' has no attribute 'LoginView'
LoginView was added in Django 1.11. If the import fails, you must be using an older version of Django.
Django 1.11 LTS is the oldest supported version of Django, so you really should upgrade, ideally to the latest version 2.2.
It is always a good idea to say which version you are using. Anyway, the class "LoginView" was implemented in Django 1.11 (https://docs.djangoproject.com/en/1.11/topics/auth/default/#django.contrib.auth.views.LoginView)
If your version is compatible with that, try to change the url part to something like:
path('accounts/login/',auth_views.LoginView.as_view(template_name='myapp/login.html'))
Hope it helps
Trying to build a full text search view in Django, but getting this error message when I try to run the server:
No module named 'django.contrib.postgres.search
I did just switch my db from sqlite to postgres, so not sure if there is some sort of error that happened in that move
here is my full stack trace
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x06B2D1E0>
Traceback (most recent call last):
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py", line 685, in reraise
raise value.with_traceback(tb)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 115, in populate
app_config.ready()
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\debug_toolbar\apps.py", line 15, in ready
dt_settings.patch_all()
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\debug_toolbar\settings.py", line 243, in patch_all
patch_root_urlconf()
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\debug_toolbar\settings.py", line 231, in patch_root_urlconf
reverse('djdt:render_panel')
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\urlresolvers.py", line 568, in reverse
app_list = resolver.app_dict[ns]
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\urlresolvers.py", line 360, in app_dict
self._populate()
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\urlresolvers.py", line 293, in _populate
for pattern in reversed(self.url_patterns):
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\crstu\Desktop\JSPROJ\dealmazing\dealmazing\urls.py", line 29, in <module>
url(r"^deals/", include("deals.urls", app_name="deals", namespace="deals")),
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\conf\urls\__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\crstu\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\crstu\Desktop\JSPROJ\dealmazing\deals\urls.py", line 3, in <module>
from .views import *
File "C:\Users\crstu\Desktop\JSPROJ\dealmazing\deals\views.py", line 2, in <module>
from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector
I've triple checked how i'm importing the module in my views file here but appears ok:
from django.shortcuts import render, redirect
from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector
from django.contrib import messages
from django.http import Http404
from django.contrib.auth.decorators import login_required
from django.views.generic import ListView
from accounts.models import User
from .models import *
import datetime
class DealListView(ListView):
model = Deal
context_object_name = 'deal_list'
queryset = Deal.objects.all()
template_name = 'deal_list.html'
class DealSearchListView(ListView):
"""
Display a Deal List page filtered by search query
"""
model = Deal
paginate_by = 10
def get_queryset(self):
qs = Deal.objects.all()
keywords = self.request.GET.get('q')
if keywords:
query = SearchQuery(keywords)
title_vector = SearchVector('title', weight='A')
content_vector = SearchVector('description', weight='B')
vectors = title_vector + content_vector
qs = qs.annotate(search=vectors).filter(search=query)
qs = qs.annotate(rank=SearchRank(vectors, query)).order_by('-rank')
return qs
and my urls:
from django.conf.urls import url, include
from django.contrib import admin
from .views import *
from dealmazing.views import *
from django.conf import settings
app_name = "deals"
urlpatterns = [
url(r'^$', DealListView.as_view(), name='deals'),
url(r'^(?P<slug>[\w-]+)/$', deal_by_detail, name='deal_detail'),
url(r'^category/(?P<category>\w+)/$', deals_by_category, name='category'),
url(r'^search/(?P<qs>\w+)/$', DealSearchListView.as_vieW(), name='search_results'),
I can't find where is bug. It's my begining with django. If somebody helping me i will grateful.
urls.py :
from django.conf.urls import url, patterns, include
from django.contrib import admin
from superlista.lists import views
urlpatterns = [
# url(r'^admin/', admin.site.urls),
url(r'^$', views.home_page, name='home'),
]
views.py :
from django.shortcuts import render
# Create your views here.
def home_page():
pass
python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03917468>
Traceback (most recent call last):
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\commands\runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\management\base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\checks\urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\utils\functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\vnbox\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\vnbox\PycharmProjects\kurs_h\superlista\superlista\urls.py", line 19, in <module>
from superlista.lists import views
ImportError: No module named 'superlista.lists'
I can't find where is bug. It's my begining with django. If somebody helping me i will grateful.
Judging by your screenshot of your folder structure, the outer superlista is the project root, and the installed apps are superlista and lists.
If you have correctly defined the INSTALLED_APPS setting, your import should be:
from lists import views