I have a simple admin django project and there I created another application called webadmin. Project structure is as follow:
tstprj
manage.py
tstprj
settings.py
urls.py
wsgi.py
init.py
webadmin
admin.py
urls.py
views.py
models.py
init.py
I have a separate wsgi file that I reference from apache conf:
# tstprj.wsgi
import os
import sys
sys.path.insert(0, '/var/www/tstprj')
os.environ['DJANGO_SETTINGS_MODULE'] = 'tstprj.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
and apache's virtual host - tstprj.conf:
<VirtualHost *:80>
WSGIScriptAlias / /home/pm/dev/tstprj.wsgi
ServerName <<my_ip_address>>
Alias /static /var/www/tstprj/static/
<Directory /var/www/tstprj/>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I get the error ImportError at / No module named urls.
The traceback:
Environment:
Request Method: GET
Request URL: http://<<my_ip_address>>/
Django Version: 1.6
Python Version: 2.7.3
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'webadmin')
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 "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
101. resolver_match = resolver.resolve(request.path_info)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in resolve
318. for pattern in self.url_patterns:
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in url_patterns
346. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in urlconf_module
341. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
40. __import__(name)
File "/var/www/tstprj/tstprj/urls.py" in
11. url(r'^admin/webadmin', include('webadmin.urls')),
File "/usr/local/lib/python2.7/dist-packages/django/conf/urls/__init__.py" in include
26. urlconf_module = import_module(urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in import_module
40. __import__(name)
Exception Type: ImportError at /
Exception Value: No module named urls
And, of course, tstprj.urls:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^admin/webadmin', include('webadmin.urls')),
url(r'^admin/', include(admin.site.urls)),
)
EDIT:
webadmin.urls
from django.conf.urls import *
from webadmin.views import *
urlpatterns = patterns('',
url(r'^/playlist/(?P<plid>(\d+))/song/add/$', addSong, name="addsong"),
url(r'^/playlist/(?P<plid>(\d+))/song/(?P<sgid>(\d+))/delete/$', deleteSong),
url(r'^/playlist/(?P<plid>(\d+))/up/$', moveUpSong),
url(r'^/playlist/(?P<plid>(\d+))/down/$', moveDownSong),
url(r'^/playlist/(?P<plid>(\d+))/top/$', moveTopSong),
url(r'^/playlist/(?P<plid>(\d+))/bottom/$', moveBottomSong),
url(r'^/playlist/(?P<plid>(\d+))/position/$', moveToPositionSong),
url(r'^/playlist/(?P<plid>(\d+))/deleteSelected/$', deleteSelectedSongs),
url(r'^/user/(?P<uid>(\d+))/deleteSelected/$', deleteSelectedStations),
url(r'^/user/(?P<uid>(\d+))/station/(?P<sid>(\d+))/playlist/deleteSelected/$', deleteSelectedPlaylists),
url(r'^/user/(?P<uid>(\d+))/station/(?P<sid>(\d+))/playlist/(?P<plid>(\d+))/delete/$', deletePlaylist),
url(r'^/user/(?P<uid>(\d+))/station/(?P<sid>(\d+))/playlist/add/$', addPlaylist, name="addplaylist"),
url(r'^/user/(?P<uid>(\d+))/playlist/all/$', playlist_list, name="playlist_list"),
url(r'^/user/(?P<uid>(\d+))/station/add/$', addStation, name="addStation"),
url(r'^/user/(?P<uid>(\d+))/station/(?P<sid>(\d+))/$', viewStation, name="viewStation"),
url(r'^/user/(?P<uid>(\d+))/station/(?P<sid>(\d+))/delete/$', deleteStation, name="deleteStation"),
)
What is the matter?
I'm not sure, but your apache configuration may be incomplete. I'm unsure the python version it calls is the one you want.
I normally set the python path, like this:
WSGIDaemonProcess process_name processes=2 threads=12 python-path=/home/pm/dev:home/pm/.../lib/python2.7
WSGIProcessGroup process_name
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIScriptAlias / /home/pm/dev/tstprj.wsgi
The first line ensures that Python uses the libraries installed in "home/pm/.../lib/python2.7", and is able to reach "/home/pm/dev".
I'm unsure this answers this question, but maybe you can try it.
Of course you don't want this answer anymore! but:
Add project and App dirs to sys.path in wsgi.py of your project and it may find all of the modules in your project
import sys
sys.path.append('<Project_Directory>')
sys.path.append('<Project_Directory>/AppName')
Related
i am using Django version 1.7 for an application,
everything was running good in my developpement PC (i was runnin it using manage.py runserver command.
now i am trying to move it to a production server.
in the production server, everything is still good when running the server using the manage.pycommand.
but accessing the application remotely (via apache2 & mod_wsgi), i get an RemovedInDjango19Warning Exception.
after looking for a solution all i could find is how to ignore theses warnings for manage.py which don't work for me and i don't know how to disable this warnings from wsgi ?
Traceback:
Environment:
Request Method: GET
Request URL: http://192.168.0.17/
Django Version: 1.7.1
Python Version: 3.4.3
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'rest_framework',
'rest_framework_nested',
'django_gravatar',
'authentication',
'djcelery',
'job',
'seed',
'proxies',
'emails')
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 "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py" in get_response
98. resolver_match = resolver.resolve(request.path_info)
File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py" in resolve
343. for pattern in self.url_patterns:
File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py" in url_patterns
372. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py" in urlconf_module
366. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python3.4/importlib/__init__.py" in import_module
109. return _bootstrap._gcd_import(name[level:], package, level)
File "/var/www/cvc.ma/CapValue/urls.py" in <module>
6. url(r'^api/v1/auth/', include('authentication.urls')),
File "/usr/local/lib/python3.4/dist-packages/django/conf/urls/__init__.py" in include
28. urlconf_module = import_module(urlconf_module)
File "/usr/lib/python3.4/importlib/__init__.py" in import_module
109. return _bootstrap._gcd_import(name[level:], package, level)
File "/var/www/cvc.ma/authentication/urls.py" in <module>
2. from authentication.views import LoginView, LogoutView
File "/var/www/cvc.ma/authentication/views.py" in <module>
4. from rest_framework import permissions, viewsets, status, views
File "/usr/local/lib/python3.4/dist-packages/rest_framework/viewsets.py" in <module>
24. from rest_framework import views, generics, mixins
File "/usr/local/lib/python3.4/dist-packages/rest_framework/views.py" in <module>
11. from rest_framework.request import Request
File "/usr/local/lib/python3.4/dist-packages/rest_framework/request.py" in <module>
20. from rest_framework.settings import api_settings
File "/usr/local/lib/python3.4/dist-packages/rest_framework/settings.py" in <module>
22. from django.utils import importlib, six
File "/usr/local/lib/python3.4/dist-packages/django/utils/importlib.py" in <module>
10. RemovedInDjango19Warning, stacklevel=2)
Exception Type: RemovedInDjango19Warning at /
Exception Value: django.utils.importlib will be removed in Django 1.9.
It's happening because the django.utils.importlib module is removed in Django 1.9, in favor of the importlib in the standard library. Django Rest Framework still uses it.
You can disable the warning by following the instructions on the accepted answer of this question -- How to suppress the deprecation warnings in Django?
Finally, i ended up upgrading to Django1.9 and fixed the migration bugs.
If you just want to silence the warning in mod_wsgi, you may add a configuration directive such as:
WSGIPythonWarnings ignore::DeprecationWarning::
See this blog entry, the release notes (point 15) and the original issue.
In essence, mod_wsgi had no equivalent to the -W control option, so a directive was added. The default must have been kept at "log everything" to be consistent across different wsgi apps.
I am doing the tango with django tutorial. I am up to chapter 5 on working with models and I am setting up the admin website. I get this strange error:
ImportError: cannot import name get_permission_codename
This seems to go away when I remove the
admin.autodiscover()
from my project/urls.py. But I am concerned that I will need this down the road.
Here is the Traceback I get when I run the development server:
Environment:
Request Method: GET Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.5.4 Python Version: 2.7.3 Installed Applications:
('django.contrib.auth', 'django.contrib.contenttypes',
'django.contrib.sessions', 'django.contrib.sites',
'django.contrib.messages', 'django.contrib.staticfiles',
'django.contrib.admin', 'rango') Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback: File
"/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
in get_response
103. resolver_match = resolver.resolve(request.path_info) File
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
in resolve
319. for pattern in self.url_patterns: File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
in url_patterns
347. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File
"/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
in urlconf_module
342. self._urlconf_module = import_module(self.urlconf_name) File
"/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in
import_module
35. import(name) File "/home/gpanterov/MyProjects/django/tango_with_django_project/tango_with_django_project/urls.py"
in
6. admin.autodiscover() File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/init.py"
in autodiscover
29. import_module('%s.admin' % app) File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py" in
import_module
35. import(name) File "/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/admin.py"
in
5. from django.contrib.admin.checks import InlineModelAdminChecks File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/checks.py"
in
6. from django.contrib.admin.utils import get_fields_from_path, NotRelationField, flatten File
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/utils.py"
in
6. from django.contrib.auth import get_permission_codename
Exception Type: ImportError at /admin/ Exception Value: cannot import
name get_permission_codename
When I remove the admin.autodiscover() line, the development server runs and I am able to get to the admin panel, but when I log in with the superuser password I created earlier, I get the message "You don't have permission to edit anything." and I don't see any of the categories I created.
I got this error when downgrading django from latest version (1.8) to an old version (1.4) for testing.
The problem here is that git doesn't delete .pyc files when switching branches (because they are .gitignore'ed) and python only regenerates them when the corresponding .py file is newer than the .pyc file (see this question for details).
The solution is to delete all *.pyc files in django/contrib/admin and django/contrib/contenttypes directories.
cannot import name get_permission_codename
Make sure u have not install all the version of django in your system.
if there then remove all and install fresh django
I try to execute django (1.4) tutorial admin on windows. But there is not access to css and javascript.
I set in setty.py:
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = 'C:/Python27/Lib/site-packages/django/contrib/admin/'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
My urils:
from django.conf.urls import patterns, include, url
Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
It still doesn't work. Could you please tell how to solve this issue and what's the best way to solve it?
My proect is in c:\django-projects\mysite.
When I execute admin http://127.0.0.1:8000/admin/polls/poll/1/ I can see error of development server:
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 68, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, i
n __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 58, in get_response
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", l
ine 51, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line
41, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\views\static.py", line 57, in serve
mimetype, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 294, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 355, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 259, in read_windows_registry
for ctype in enum_types(mimedb):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal
Here is from settings.py:
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',
'polls'
)
In firebug I get 500 http return code for css and js files and path seems strange to me.
For example:
http://127.0.0.1:8000/static/admin/css/base.css
I tried to added in settings.py:
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'C:/Python27/Lib/site-packages/django/contrib/admin/static/admin', //here css and js and img folders for for admin
)
And changing urls.py to this one:
from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += staticfiles_urlpatterns()
But it still doesn't work.
Django documenation say here: https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/#serving-the-admin-files that: "The admin files live in (django/contrib/admin/static/admin) of the Django distribution.". But it still doesn't wok.
I was following Apress - Practical Django Project by James Bennet and I got this nasty error out of the blue. Could you help me?
Here it goes:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.2.5
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.flatpages',
'cms.search',
'coltrane',
'tagging']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
91. request.path_info)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
215. for pattern in self.url_patterns:
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_url_patterns
244. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_urlconf_module
239. self._urlconf_module = import_module(self.urlconf_name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/utils/importlib.py" in import_module
35. __import__(name)
File "/Users/danielcorreia/Sites/test_Django/cms/../cms/urls.py" in <module>
21. (r'', include('django.contrib.flatpages.urls')),
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/conf/urls/defaults.py" in patterns
24. t = url(prefix=prefix, *t)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/conf/urls/defaults.py" in url
41. return RegexURLPattern(regex, view, kwargs, name)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in __init__
89. self.regex = re.compile(regex, re.UNICODE)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py" in compile
188. return _compile(pattern, flags)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py" in _compile
241. raise error, v # invalid expression
Exception Type: error at /
Exception Value: bad character in group name
Oh! I'm a newbie to Django. Please be gentle :)
Here's the 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'^cms/', include('cms.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)),
(r'tiny_mce/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': '/Users/danielcorreia/Sites/tinymce/jscripts/tiny_mce' }),
(r'^search/$', 'cms.search.views.search'),
(r'^weblog/$', 'coltrane.views.entries_index'),
(r'^weblog/(?P<year\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),
(r'', include('django.contrib.flatpages.urls')),
)
(r'^weblog/(?P<year\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),
Change to:
(r'^weblog/(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(P?<slug>[-\w]+)/$', 'coltrane.views.entry_detail'),
Note the closing angle bracket for the year group.
I just moved a django project to a deployment server from my dev server, and I'm having some issues deploying it. My apache config is as follows:
<Location "/">
Order allow,deny
Allow from all
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE project.settings
PythonDebug On
PythonPath "['/home/django/'] + sys.path"
</Location>
Django does work, since it renders the Django debug views, but I get the following error:
ImportError at /
No module named app.urls
And here is all the information Django gives me:
Request Method: GET
Request URL: http://myserver.com/
Django Version: 1.1.1
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.admindocs',
'project.app']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')
Traceback:
File "/usr/lib64/python2.6/site-packages/django/core/handlers/base.py" in get_response
83. request.path_info)
File "/usr/lib64/python2.6/site-packages/django/core/urlresolvers.py" in resolve
218. sub_match = pattern.resolve(new_path)
File "/usr/lib64/python2.6/site-packages/django/core/urlresolvers.py" in resolve
216. for pattern in self.url_patterns:
File "/usr/lib64/python2.6/site-packages/django/core/urlresolvers.py" in _get_url_patterns
245. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib64/python2.6/site-packages/django/core/urlresolvers.py" in _get_urlconf_module
240. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib64/python2.6/site-packages/django/utils/importlib.py" in import_module
35. __import__(name)
Exception Type: ImportError at /
Exception Value: No module named app.urls
Any ideas as to why I get an import error?
Add the project directory to sys.path.
My guess is that if you simply change your url configuration to reference "project.app.urls" instead of "app.urls", your problem will be fixed.
It seems that you've listed "project.app" in INSTALLED_APPS in your project's settings.py file, but you've referenced "app.urls" in your urls.py. You need to standardize and either always reference "app", and change your PythonPath to include the project directory, or always reference "project.app".
I would recommend to use virtualenv along with mod_python. Some instructions here: http://mydjangoblog.com/2009/03/30/django-mod_python-and-virtualenv/
It has the advantage of solving all your path problems, but also to allow to install extra modules (or even other versions of django) very easily.