No module named blog.urls - django

Recently found a django's blog
Install to own computer later
Run up appear this kind of mistake, how to solve?
No module named blog.urlsRequest Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.2.4
Exception Type: ImportError
Exception Value: No module named blog.urls
Exception Location: C:\Python25\Lib\site-packages\django\utils\importlib.py in import_module, line 35
Python Executable: C:\Python25\python.exe
Python Version: 2.5.1
Python Path: ['E:\\source\\DjangoBlog\\DjangoBlog', 'C:\\Python25\\lib\\site-packages\\setuptools-0.6c7-py2.5.egg', 'C:\\Python25\\lib\\site-packages\\simplejson-2.0.9-py2.5.egg', 'E:\\source\\DjangoBlog\\DjangoBlog\\src', 'C:\\Python25', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\lib-tk', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\\site-packages', 'C:\\WINDOWS\\system32\\python25.zip', 'D:\\ecliipse\\eclipse-java-helios-SR1-win32\\eclipse\\plugins\\org.python.pydev_1.6.3.2010100513\\PySrc', 'C:\\Python25\\lib\\site-packages\\PIL']
Server time: Fri, 25 Feb 2011 15:36:58 +0800

According to Python Path E:\source\DjangoBlog\DjangoBlog - DjangoBlog is directory where your project placed? Is where blog directory inside? if not try rename project directory to 'blog'

Related

cannot import name 'url' from 'django.conf.urls' (/app/.heroku/python/lib/python3.9/site-packages/django/conf/urls/__init__.py)

ImportError at /
cannot import name 'url' from 'django.conf.urls' (/app/.heroku/python/lib/python3.9/site-packages/django/conf/urls/__init__.py)
Request Method: GET
Request URL: https://aas-system.herokuapp.com/
Django Version: 4.0.1
Exception Type: ImportError
Exception Value:
cannot import name 'url' from 'django.conf.urls' (/app/.heroku/python/lib/python3.9/site-packages/django/conf/urls/__init__.py)
Exception Location: /app/.heroku/python/lib/python3.9/site-packages/webpush/urls.py, line 1, in <module>
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.9.10
Python Path:
['/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python39.zip',
'/app/.heroku/python/lib/python3.9',
'/app/.heroku/python/lib/python3.9/lib-dynload',
'/app/.heroku/python/lib/python3.9/site-packages'
]
Server time: Tue, 01 Feb 2022 07:52:34 +0000
If you are using Django 4.0 and higher then django.conf.urls.url() is removed.
You can use re_path[Django-doc] in case of url, which also use regex as url.
from django.urls import path, re_path
urlpatterns = [
re_path(r'^$', views.your_view_name),
]
It looks like you are using Django 4. In this version, url from django.conf.url no longer works.
https://docs.djangoproject.com/en/3.2/ref/urls/#url
So you have two options.
Use something below Django 3.2. I suspect that what you are doing on your local version. FYI, using pip freeze > requirements.txt in your local environment is a good way to save your configuration and it can simplify the installation in other env.
Or update your code. You should then try re_pathin order to do so
https://docs.djangoproject.com/en/4.0/ref/urls/#re-path

Django Can't find my template

I've found many questions like this but no one have solved this mine.
When I visit the url
http://localhost:8000/catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
that is handled by this urls.py path:
path('book/<uuid:pk>/renew/', views.renew_book_librarian, name='renew-book-librarian'),
than my view in the end returns this:
I have a view that returns this:
return render(request,'catalog/book_renew_librarian.html', {'form': form, 'bookinst':book_inst})
But I get the template error:
TemplateDoesNotExist at /catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
catalog/book_renew_librarian.html
Request Method: GET
Request URL: http://localhost:8000/catalog/book/88a26558-d636-44c8-8831-242d98fa6d80/renew/
Django Version: 2.0.3
Exception Type: TemplateDoesNotExist
Exception Value:
catalog/book_renew_librarian.html
Exception Location: C:\Users\Araujo\AppData\Local\Programs\Python\Python36\lib\site-packages\django\template\loader.py in get_template, line 19
Python Executable: C:\Users\Araujo\AppData\Local\Programs\Python\Python36\python.exe
Python Version: 3.6.4
Python Path:
['C:\\Users\\Araujo\\Desktop\\first_django\\locallibrary',
'C:\\Users\\Araujo\\AppData\\Local\\Programs\\Python\\Python36\\python36.zip',
'C:\\Users\\Araujo\\AppData\\Local\\Programs\\Python\\Python36\\DLLs',
'C:\\Users\\Araujo\\AppData\\Local\\Programs\\Python\\Python36\\lib',
'C:\\Users\\Araujo\\AppData\\Local\\Programs\\Python\\Python36',
'C:\\Users\\Araujo\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages']
Server time: Wed, 14 Mar 2018 19:19:10 +0000
But I have the template in the
\catalog\templates\book_renew_librarian.html
How to solve it?
Your directory structure for the path you specified should be :
ProjectFolder
-projectfolder
-catalog
-templates
-catalog
book_renew_librarian.html
-manage.py

i have two projects in django i can not open admin site for my second project,but i can open for my first project,can any one help me

AttributeError at /admin/
'WSGIRequest' object has no attribute 'user'
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 2.0.2
Exception Type: AttributeError
Exception Value:
'WSGIRequest' object has no attribute 'user'
Exception Location: C:\Users\vaaz\Desktop\venv\lib\site-packages\django\contrib\admin\sites.py in has_permission, line 186
Python Executable: C:\Users\vaaz\Desktop\venv\Scripts\python.exe
Python Version: 3.4.3
Python Path:
['C:\Users\vaaz\website1',
'C:\Windows\system32\python34.zip',
'C:\Users\vaaz\Desktop\venv\DLLs',
'C:\Users\vaaz\Desktop\venv\lib',
'C:\Users\vaaz\Desktop\venv\Scripts',
'C:\Python34\Lib',
'C:\Python34\DLLs',
'C:\Users\vaaz\Desktop\venv',
'C:\Users\vaaz\Desktop\venv\lib\site-packages']
Server time: Mon, 12 Mar 2018 10:21:49 +0000
This looks similar to this post
with your limited error description I can only suggest a few things that were mentioned in the above post:
Older Django versions use MIDDLEWARE_CLASSES = (...) in the settings.py rather than MIDDLEWARE = (...) try changing that variable.
If you are using virtualenv be sure to activate it before trying to runserver
If you created your app in a different version of Django and then installed it on another version it might give you errors.

Django: Error while installing "Django Registration Redux"

I am trying to install "Django Registration Redux".
I followed every step in the official website to install.
When I am installing django.contrib.sites, the admin doesn't work, and when I comment this the admin starts working but registration does not work in either way.
It gives the error as:
DoesNotExist at /accounts/login/
Site matching query does not exist.
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/login/
Django Version: 1.9
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.
Exception Location: c:\Python27\lib\site-packages\django\db\models\query.py in get, line 387
Python Executable: c:\Python27\python.exe
Python Version: 2.7.11
Python Path:
['E:\\myproject\\mysite',
'C:\\Windows\\SYSTEM32\\python27.zip',
'c:\\Python27\\DLLs',
'c:\\Python27\\lib',
'c:\\Python27\\lib\\plat-win',
'c:\\Python27\\lib\\lib-tk',
'c:\\Python27',
'c:\\Python27\\lib\\site-packages']
Server time: Tue, 24 May 2016 13:26:56 +0000
It sounds like you haven't followed the instructions to enable the sites framework.
After adding django.contrib.sites to INSTALLED_APPS, you need to set SITE_ID = 1 in your settings, then run the migrate command.

Error in testing part of my django poll app

I get the following error in my django poll app. I do not understand what it states, can anyone suggest me what to do? Any solution to this?
NameError at / name 'model' is not defined
Request Method: GET Request URL: http://127.0.0.1:8000/
Django Version: 1.8.6
Exception Type: NameError
Exception Value: name 'model' is not defined
Exception Location: c:\Anaconda-installation\mysite\polls\views.py in ResultView, line 26
Python Executable: C:\Anaconda-installation\python.exe
Python Version: 2.7.10
Python Path: ['c:\\Anaconda-installation\\mysite',
'C:\\Anaconda-installation\\python27.zip',
'C:\\Anaconda-installation\\DLLs',
'C:\\Anaconda-installation\\lib',
'C:\\Anaconda-installation\\lib\\plat-win',
'C:\\Anaconda-installation\\lib\\lib-tk',
'C:\\Anaconda-installation',
'c:\\anaconda-installation\\lib\\site-packages\\sphinx-1.3.1-py2.7.egg',
'c:\\anaconda-installation\\lib\\site-packages\\setuptools-17.1.1-py2.7.egg',
'C:\\Anaconda-installation\\lib\\site-packages',
'C:\\Anaconda-installation\\lib\\site-packages\\cryptography-0.9.1-py2.7-win-amd64.egg',
'C:\\Anaconda-installation\\lib\\site-packages\\win32',
'C:\\Anaconda-installation\\lib\\site-packages\\win32\\lib',
'C:\\Anaconda-installation\\lib\\site-packages\\Pythonwin']
Server time: Tue, 8 Dec 2015 04:49:21 +0000