'site' module not found when deploying to Heroku

早过忘川 提交于 2020-01-14 10:16:10

问题


I'm trying to deploy a django app to Heroku, but I keep getting the error

ImportError: no module named site

I'm using a custom buildpack from https://github.com/jiaaro/heroku-buildpack-django

This doesn't seem to be the problem and neither does anything with pip or my virtualenv setup I think the error is originating in my main urls.py file. This file is set up just like below:

from django.conf.urls import patterns, include, url
from django.contrib import admin
from CentsLess import settings

admin.autodiscover()

urlpatterns = patterns('',
    # BASICS #
    url(r'^admin/', include(admin.site.urls)), 
. . . 

Some help learning how to better interpret the error log from Heroku or what may be wrong in urls.py would be very appreciated. It all works fine on my local setup, even with gunicorn and such.


回答1:


SITE_ID = 1
INSTALLED_APPS = (
    ...
    'django.contrib.sites',
    ...
}

make sure you add in your database (table "django_site") a site with the same id as SITE_ID.




回答2:


Do you have a full error log? You're getting that error because somewhere you're trying to do an 'import site' and python can't find 'site'. Could be anywhere, in views/urls/etc - try doing a text search for 'import site' in your project directory and see if anything turns up.

http://docs.python.org/library/exceptions.html#exceptions.ImportError



来源:https://stackoverflow.com/questions/11596710/site-module-not-found-when-deploying-to-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!