I want to enter to administration application of my site.
on request: http://mysite.ru/admin/ - i get an error:
ImportError at /admin/
No module named admin.site.urls
Request Method: GET
Request URL: http://mysite.ru/admin/
Django Version: 1.2.1
Exception Type: ImportError
Exception Value:
No module named admin.site.urls
Exception Location: /usr/lib/python2.4/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /usr/bin/python
Python Version: 2.4.3
Python Path: ['/home/z/sites', '/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg', '/usr/lib/python2.4/site-packages/MySQL_python-1.2.3-py2.4-linux-i686.egg', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/opt/CollabNet_Subversion/lib/svn-python', '/usr/lib/python2.4/site-packages/gtk-2.0']
Server time: Fri, 2 Jul 2010 02:19:12 -0500
Admin module i connected as it described here:
http://docs.djangoproject.com/en/1.2/intro/tutorial02/
What the problem?
You probably forgot to uncomment one of the lines in the settings.py:
For example:
Add "django.contrib.admin" to your
INSTALLED_APPS setting. Run python
manage.py syncdb. Since you have added
a new application to INSTALLED_APPS,
the database tables need to be
updated.
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin', #<---- !!!!! Uncomment
'mysite.polls'
)
And in your urls.py: (Although it looks like you've done this step already)
# Uncomment the next two lines to enable the admin:
from django.contrib import admin #<---- !!!!! Uncomment
admin.autodiscover() #<---- !!!!! Uncomment
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)), #<---- !!!!! Uncomment
)
Related
I am not able to launch my website. It is showing the bellow error when running it iPlanetHoster.
ModuleNotFoundError at /home/massvnrc/myproject/myproject/myapp/templates/index.html
No module named '/myapp'
Request Method: GET
Request URL: ***/home/massvnrc/myproject/myproject/myapp/templates/index.html
Django Version: 1.9.13
Exception Type: ModuleNotFoundError
Exception Value:
No module named '/myapp'
Exception Location: /home/massvnrc/virtualenv/myproject/3.7/lib64/python3.7/importlib/__init__.py in import_module, line 127
Python Executable: /home/massvnrc/virtualenv/myproject/3.7/bin/python3.7_bin
Python Version: 3.7.3
Python Path:
['/home/massvnrc/myproject',
'/opt/passenger-5.3.7-9.el7.cloudlinux/src/helper-scripts',
'/home/massvnrc/virtualenv/myproject/3.7/lib64/python37.zip',
'/home/massvnrc/virtualenv/myproject/3.7/lib64/python3.7',
'/home/massvnrc/virtualenv/myproject/3.7/lib64/python3.7/lib-dynload',
'/opt/alt/python37/lib64/python3.7',
'/opt/alt/python37/lib/python3.7',
'/home/massvnrc/virtualenv/myproject/3.7/lib/python3.7/site-packages']
Server time: Thu, 23 Jan 2020 18:03:11 +0000
Here are some pictures that are showing where my files are located.
enter image description here
Can somebody tell me why I am getting this erro
You deployed the website with debug mode turned on - never do this, at least without restricting access.
Anyway, because of this I was able to see your urls.py:
from django.contrib import admin
from django.conf.urls import url, include
# from .import views
from django.contrib.auth import views as auth_views
urlpatterns = [
url('admin/', admin.site.urls),
url('', include('/myapp.urls')), ...
]
And installed apps from settings:
INSTALLED_APPS
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
I do not see myapp registered in settings. You need to add it.
Next is that include('/myapp.urls') should be changes to include('myapp.urls')
I'm getting the following error message:
ImportError at /youtube_submit
No module named util.process
Request Method: GET
Request URL: http://myapp.com:8000/youtube_submit?videoid=vSlF8EFo8QA
Django Version: 1.4.1
Exception Type: ImportError
Exception Value:
No module named util.process
Exception Location: /Users/filipeximenes/Projects/trainee/trainee/views/youtube_submit.py in <module>, line 6
Python Executable: /Users/filipeximenes/Projects/trainee/venv/bin/python
Python Version: 2.7.3
Python Path:
['/Users/filipeximenes/Projects/trainee',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/Users/filipeximenes/Projects/trainee/venv/lib/python27.zip',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/plat-darwin',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/plat-mac',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/lib-tk',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/lib-old',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/lib-dynload',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/filipeximenes/Projects/trainee/venv/lib/python2.7/site-packages']
This is my requirements file:
Django==1.4.1
South==0.7.6
amqplib==1.0.2
anyjson==0.3.3
billiard==2.7.3.12
celery==3.0.9
distribute==0.6.27
dj-database-url==0.2.1
django-celery==3.0.9
facebook-sdk==0.3.2
gdata==2.0.17
gunicorn==0.14.6
kombu==2.4.5
psycopg2==2.4.5
python-dateutil==1.5
python-openid==2.2.5
wsgiref==0.1.2
I'm running the app locally, and I do have __init__.py files in all my modules.
And the app is installed:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'main',
'trainee',
'company',
'videos',
'south',
)
I have other apps working perfectly, the only one that is giving me pain is the videosone.
Any ideas on whats the problem?
EDIT:
youtube submit imports:
from videos.util.process import verify_video
process.py imports:
from videos.util.youtube import YoutubeUtil
youtube.py imports:
import gdata.youtube.service
import urlparse
from videos.util.verifier import Verifier
verifier.py doesn't import anything
EDIT:
I created another app and copied all files to it.
I magically started working.
In /youtube_submit view of videos application you have imported something like this,
from util.process import *
And since ther's no such module or the folder process has no __init__.py file, you get this error
I created another app and copied all files to it. Somehow it's working now.
I switched a 1.1.1 Django project to 1.3.1. Upon calling admin.autodiscover() in urls.py, an exception is raised from sites.py in the admin framework stating:
ImproperlyConfigured at /
Put 'django.contrib.contenttypes' in your INSTALLED_APPS setting in order
to use the admin application
In settings.py, I have:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'my.app'
)
Things I checked:
The contenttypes framework is indeed in my INSTALLED_APPS setting.
I have not repeated my INSTALLED_APPS declaration anywhere else
The contenttypes entry in INSTALLED_APPS is listed before the admin entry.
Running django-admin.py shell and importing "django.contrib.contenttypes" works.
If I go to the offending lines in the admin (Django-1.3.1/django/contrib/admin/sites.py in check_dependencies, line 164), I see:
if not ContentType._meta.installed:
raise ImproperlyConfigured(...)
If I comment out the check, I can run my project and the admin works. I'm not sure how the _meta.installed property is supposed to be set on model types, so I am at a loss for what to do next.
I should also note that this same Django 1.3.1 installation is working with other projects using similar settings files.
Any hints or resources would be appreciated! Thanks!
django.contrib.contenttypes includes two models, ContentType and ContentTypeManager. My guess is that you haven't run manage.py syncdb after adding django.contrib.contenttypes to your INSTALLED_APPS.
This would make the if not ContentType._meta.installed check understandable: the ContentType model isn't available in the database yet.
I am following along on this tutorial, after I add the templates and put the pattern in urls.py, I go the website I get a template not loaded page.
This is my template dirs section from settings.py:
TEMPLATE_DIRS = (
"/home/django-projects/base/templates/",
)
the base folder hierarchy is this:
blog<dir>
dbs<dir>
__init__.py
manage.py
settings.py
templates<dir>
urls.py
urls.py looks like this:
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('base.blog.views',
(r"", "main"),
# Example:
# (r'^base/', include('base.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
In templates I have a folder called blog, and it contains the two html files from the tutorial. I am just not sure what setting I am missing to display the proper templates. I will be happy to post anything else you would need to see. I am sure it is something trivial, I just can't seem to figure out what it is. Thanks for your help.
EDIT
So I was playing around with it, and I realized I couldn't get to admin. So I uncoupled the urls for the blog part away from the main. The urls.py on the top level looks like this:
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'blog/', include('blog.urls')),
# Example:
# (r'^base/', include('base.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
And in the blog folder urls.py looks like this:
from django.conf.urls.defaults import *
urlpatterns = patterns('base.blog.views',
(r'^$', 'main'),
)
Now I can get to admin, but still get a template load error when I try to get to the blog.
TemplateDoesNotExist at /blog/
blog/list.html
Request Method: GET
Request URL: http://192.168.1.124:9999/blog/
Django Version: 1.2.3
Exception Type: TemplateDoesNotExist
Exception Value:
blog/list.html
Exception Location: /usr/local/lib/python2.6/dist-packages/Django-1.2.3-py2.6.egg/django/template/loader.py in find_template, line 138
Python Executable: /usr/bin/python
Python Version: 2.6.6
Python Path: ['/home/kevin/django-projects/base', '/usr/local/lib/python2.6/dist-packages/setuptools-0.6c11-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/BeautifulSoup-3.1.0.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/Django-1.2.3-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0']
Server time: Tue, 2 Nov 2010 11:59:13 -0500
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
Should the last line of the "main" view contain "blog/list.html" instead of "list.html"?
Try replacing that line with the following:
return render_to_response("blog/list.html", dict(posts=posts, user=request.user))
Do the same thing with the "post" view.
Basically, Django is going to look under each of the configured template directories in settings.py and if you specify "list.html" it better be in the root of of of those directories. Since you put the "list.html" in the "blog" sub-directory and not where you told it to look, Django can't find it.
First, you have a missing leading / in your template directory:
TEMPLATE_DIRS = (
"/home/django-projects/base/templates/",
)
I've just installed django on my mac os x snow leopard and got some issues with it.
I just made a very simple project that only contains a simple app.
The app contains just one model and it's a task. When running syncdb the table for tasks is created without any problems and I'm requested to create new user. Everything works fine and I can log in and so on but my app is not showing up.
Here is some code from my project.
settings.py
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'work.todo',
)
todo/admin.py
from work.todo import Task
from django.contrib import admin
admin.site.register(Task)
urls.py
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^work/', include('work.foo.urls')),
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
todo/models.py
from django.db import models
class Task(models.Model):
text = models.CharField(max_length=200)
done = models.BooleanField()
Maybe it's worth to mention that there is a __init__.py in both work and the work/todo folder.
Cheers,
nandarya
In todo/admin.py:
from work.todo.models import Task
from django.contrib import admin
admin.site.register(Task)
You forgot models in your import statement :)