Note that there are some explanatory texts on larger screens.

plurals
  1. POapache2/mod_wsgi/django production NoneType error for satchmo import
    text
    copied!<p>I'm trying (very hard) to deploy my Django app to apache2/mod_wsgi, however I'm coming across an error that only occurs in the production environment. I'd be very very grateful for any suggestions on what to do next. The error is:</p> <pre><code>'NoneType' object has no attribute 'objects' </code></pre> <p>The stack trace points to this function:</p> <p>/var/webapps/MYAPP/releases/current/apps/product/models.py in by_site</p> <pre><code>""" Base model used for products. Stores hierarchical categories as well as individual product level information which includes options. """ from decimal import Context, Decimal, ROUND_FLOOR from django import forms from django.conf import settings from django.contrib.sites.models import Site from django.core import urlresolvers from django.core.cache import cache from django.db import models from django.db.models import Q from django.utils.translation import get_language, ugettext, ugettext_lazy as _ from l10n.utils import moneyfmt, lookup_translation from livesettings import config_value, SettingNotSet, config_value_safe from prices import get_product_quantity_price, get_product_quantity_adjustments from product import active_product_types from product.prices import PriceAdjustmentCalc from satchmo_utils import get_flat_list from satchmo_utils.fields import CurrencyField from satchmo_utils.thumbnail.field import ImageWithThumbnailField from satchmo_utils.unique_id import slugify import config #This import is required to make sure livesettings picks up the config values import datetime import keyedcache import logging import operator import signals log = logging.getLogger('product.models') dimension_units = (('cm','cm'), ('in','in')) weight_units = (('kg','kg'), ('lb','lb')) DISCOUNT_SHIPPING_CHOICES = ( ('NONE', _('None')), ('FREE', _('Free Shipping')), ('FREECHEAP', _('Cheapest shipping option is free')), ('APPLY', _('Apply the discount above to shipping')) ) SHIP_CLASS_CHOICES = ( ('DEFAULT', _('Default')), ('YES', _('Shippable')), ('NO', _('Not Shippable')) ) STANDARD_COMPARISON_MEASURES = ( #Weight ('g', '100'), ('kg', '1'), ('mg', '100'), #Volume ('L', '1'), ('ml', '100'), #Length ('mm', '100'), ('cm', '100'), ('m', '1'), ('inches', '100'), #Electricity ('W', '1'), ('V', '1'), #Each / Pack ('other', '1'), ) def default_dimension_unit(): val = config_value_safe('PRODUCT','MEASUREMENT_SYSTEM', (None, None))[0] if val == 'metric': return 'cm' else: return 'in' def default_weight_unit(): val = config_value_safe('PRODUCT','MEASUREMENT_SYSTEM', (None, None))[0] if val == 'metric': return 'kg' else: return 'lb' class CategoryManager(models.Manager): def active(self): return self.filter(is_active=True) def by_site(self, site=None, **kwargs): """Get all categories for this site""" if not site: site = Site.objects.get_current() &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; Line causing error... apparently site = site.id return self.active().filter(site__id__exact = site, **kwargs) def get_by_site(self, site=None, **kwargs): if not site: site = Site.objects.get_current() return self.active().get(site = site, **kwargs) def root_categories(self, site=None, **kwargs): """Get all root categories.""" if not site: site = Site.objects.get_current() return self.active().filter(parent__isnull=True, site=site, **kwargs) def search_by_site(self, keyword, site=None, include_children=False): """Search for categories by keyword. Note, this does not return a queryset.""" if not site: site = Site.objects.get_current() cats = self.active().filter( Q(name__icontains=keyword) | Q(meta__icontains=keyword) | Q(description__icontains=keyword), site=site) if include_children: # get all the children of the categories found cats = [cat.get_active_children(include_self=True) for cat in cats] # sort properly if cats: fastsort = [(c.ordering, c.name, c) for c in get_flat_list(cats)] fastsort.sort() # extract the cat list cats = zip(*fastsort)[2] return cats </code></pre> <p>This is being thrown in a satchimo module, 'product'. It has been copied and customised in MYAPP/apps. It is INSTALLED in settings.py as 'apps.product'. </p> <p>My modwsgi file is located in MYAPP/deploy/:</p> <pre><code>import os import sys # redirect sys.stdout to sys.stderr for bad libraries like geopy that uses # print statements for optional import exceptions. sys.stdout = sys.stderr from os.path import abspath, dirname, join from site import addsitedir sys.path.insert(0, '/var/webapps/MYAPP/releases/current/apps') sys.path.insert(0, '/var/webapps/MYAPP/releases/current') sys.path.insert(0, abspath(join(dirname(__file__), "..", ".."))) from django.conf import settings os.environ["DJANGO_SETTINGS_MODULE"] = "current.settings" sys.path.insert(0, join(settings.PINAX_ROOT, "apps")) sys.path.insert(0, join(settings.PROJECT_ROOT, "apps")) from django.core.handlers.wsgi import WSGIHandler application = WSGIHandler() </code></pre> <p>Other info</p> <p>Django Version: 1.3.1 Python Version: 2.7.1 Python Path: </p> <pre><code>['/var/webapps/MYAPP/releases/current/apps', '/var/webapps/MYAPP/releases/current/env/lib/python2.7/site-packages/pinax/apps', '/var/webapps/MYAPP/releases', '/var/webapps/MYAPP/releases/current', '/var/webapps/MYAPP/releases/current/apps', '/var/webapps/MYAPP/releases/current/env/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg', '/var/webapps/MYAPP/releases/current/env/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg', '/var/webapps/MYAPP/releases/current/env/lib/python2.7/site-packages', '/var/webapps/MYAPPreleases/current/env/lib/python2.7/site-packages/PIL', '/usr/local/lib/python2.7/dist-packages/virtualenv-1.6.4-py2.7.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7'] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload