У меня есть приложение, которое работает абсолютно нормально, когда запускается как ./manage.py runserver (или даже runserver_plus), но когда я развертываю его в экземпляре apache2 + wsgi, оно ломается. Первая модель, которую он пытается импортировать (UserProfile), похоже, импортировала запрошенные модули как NoneType.
Итак, такая модель (это не точный код, это не то, что я могу вставить на общедоступный сайт прямо сейчас):
from django.db import models
from django.contrib.auth.models import User
from BlogEngine.categorisation.models import Category
from django.db.models.signals import post_save
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import ugettext as _
import logging
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
category = models.ManyToManyField(Category, blank=True, related_name="category")
def __unicode__(self):
return "Profile for %s" % user.username
def update_categories(self):
"""Updates the categories list"""
pull_more = self.category_selection_max - self.category.count()
if pull_more == 0:
return self.category_selection
logging.debug("Drawing %s categories" % draw)
categories = Category.objects.filter(
is_live=True
).order_by("?")[:pull_more]
## More code under here ##
Возвращает:
Объект 'NoneType' не имеет атрибута 'debug'
в строке logging.debug («Рисование% s категорий»% draw)
Комментируя это, мы получаем
Объект 'NoneType' не имеет атрибута 'objects'
в строке ниже, и так далее. Все определенно импортируется, и он отлично работает на сервере dev.
Мой файл WSGI:
import sys
import site
import os
vepath = '/home/aquarion/newsite/django/virtualenv/lib/python2.6/site-packages'
#prev_sys_path = list(sys.path)
## add the site-packages of our virtualenv as a site dir
site.addsitedir(vepath)
## add the app's directory to the PYTHONPATH
sys.path.append('/home/aquarion/newsite/django/')
# import from down here to pull in possible virtualenv django install
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'BlogEngine.settings'
application = WSGIHandler()
Есть идеи?