Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » 404 error in admin interface with mod_python and >=django-1.1 [RSS Feed]

#1 June 11, 2010 14:06:00

Jan M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

404 error in admin interface with mod_python and >=django-1.1


Hi,

I am serving my django project with mod_python and ran into a problem
regarding the admin interface (django.contrib.admin). If DEBUG = False
is set in settings.py the admin interface generates 404 error messages
when clicking on any of my models, for example to add a new entry. The
django shipped models work without any problems. If I set DEBUG = True
everything works fine as expected. It is odd that the models show up
in the interface but clicking them generates 404 errors.
The problem occurs with django-1.1.2 and django-1.2.1, django-1.0.*
works fine.
I tested this on debian and ubuntu with different projects. To hunt
the problem down I tested with mod_wsgi, which has the same problem.

Here is my apache configuration with mod_python:

<VirtualHost *:80>
ServerAdmin webmas...@localhost
DocumentRoot /home/jan/tmp/my_project
Options Indexes FollowSymLinks

<Location />
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath " +
sys.path"
SetEnv DJANGO_SETTINGS_MODULE my_project.settings
PythonOption django.root /mynew
PythonDebug On
</Location>
<Location "/static/">
SetHandler None
</Location>
<Location "/media">
SetHandler None
</Location>
</VirtualHost>

Here is my settings.py configuration file:

DEBUG = False
TEMPLATE_DEBUG = DEBUG

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
ROOT_URLCONF = 'my_project.urls'
TEMPLATE_DIRS = (
'/home/jan/tmp/my_project/templates'
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'my_project.my_app',
)

My urls.py url configuration file looks like this:

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/', include(admin.site.urls)),
)

And my model my_app/models.py looks as follows:

from django.db import models
from django.contrib import admin

class Blubb(models.Model):
x = models.IntegerField()

admin.site.register(Blubb)

Any ideas what could be wrong?

Kind regards,

Jan

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 June 11, 2010 14:31:12

Karen T.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

404 error in admin interface with mod_python and >=django-1.1


On Fri, Jun 11, 2010 at 4:49 AM, Jan Meier <j...@codejunky.org> wrote:

> And my model my_app/models.py looks as follows:
>
> from django.db import models
> from django.contrib import admin
>
> class Blubb(models.Model):
> x = models.IntegerField()
>
> admin.site.register(Blubb)
>
> Any ideas what could be wrong?
>


Yes, you've got your admin registrations in your models.py file. models.py
won't necessarily be loaded early in a production environment with
DEBUG=False, so these registration calls are not running before you start
using admin. Move admin registrations to an admin.py file and call
admin.autodiscover() in your urls.py file (seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf)
and the problem will go away.

Karen
--http://tracey.org/kmt/--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 June 11, 2010 15:28:25

Jan M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

404 error in admin interface with mod_python and >=django-1.1


On 11 Jun., 15:30, Karen Tracey <kmtra...@gmail.com> wrote:
> Yes, you've got your admin registrations in your models.py file. models.py
> won't necessarily be loaded early in a production environment with
> DEBUG=False, so these registration calls are not running before you start
> using admin. Move admin registrations to an admin.py file and call
> admin.autodiscover() in your urls.py file
> (seehttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-admin...)
> and the problem will go away.

Thank you very much, that solved my problem. :-)

Regards,
Jan

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » 404 error in admin interface with mod_python and >=django-1.1 [RSS Feed]

Board footer

Moderator control

Enjoy the 13th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support