2

at local when i accessed localhost:8000/admin, it worked....!!! but when i access https://realmento.herokuapp.com/admin/login/?next=/admin/ , i get message DoesNotExist at /admin/login/ Site matching query does not exist. i have deployed my project to heroku... this is my setting.py :

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os


location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', x)
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/



# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = ['*']
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'index',
    'category',
    'products',
    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    # ... include the providers you want to enable:
    'allauth.socialaccount.providers.bitly',
    'allauth.socialaccount.providers.dropbox',
    'allauth.socialaccount.providers.github',
    'allauth.socialaccount.providers.google',
    'allauth.socialaccount.providers.facebook',
)

MIDDLEWARE_CLASSES = (
    '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',
    'solid_i18n.middleware.SolidLocaleMiddleware', 
)
SITE_ID = 1
SITE_ID = 2
AUTHENTICATION_BACKENDS = (
    "django.contrib.auth.backends.ModelBackend",
    "allauth.account.auth_backends.AuthenticationBackend",
)

TEMPLATE_CONTEXT_PROCESSORS = (

    "django.core.context_processors.request",
    "allauth.account.context_processors.account",
    "allauth.socialaccount.context_processors.socialaccount",
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.i18n",
    'realmento.context_processors.solid_i18n',


)

 # default language, it will be used, if django can't recognize user's language
LANGUAGE_CODE = 'en'

# supported languages
LANGUAGES = (
    ('en', 'English'),
    ('ko', 'Korean'),

)
USE_I18N = True

LOCALE_PATHS = (
    location('locale'),
)
CACHES = {
    'default': {
        'BACKEND':'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION':'127.0.0.1:8000',
    }
}

###############################################################
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)
TEMPLATE_DIRS = (
os.path.join(BASE_DIR,'templates'), os.path.join(BASE_DIR,'templates', 'allauth'))
#################################################################
ROOT_URLCONF = 'realmento.urls'

WSGI_APPLICATION = 'realmento.wsgi.application'

# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

TIME_ZONE = 'UTC'

USE_L10N = True

USE_TZ = True

ADMINS = (('HOANGTHINH', 'rongbay054@gmail.com'), )
EMAIL_SUBJECT_PREFIX = "[Translation] "
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'hoangthinh2641995@gmail.com'
EMAIL_HOST_PASSWORD = '*************'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

LOGIN_REDIRECT_URL = '/realmento/intro'
LOGOUT_URL = "/accounts/login/"
SOLID_I18N_USE_REDIRECTS = False
SOLID_I18N_HANDLE_DEFAULT_PREFIX = False
SOLID_I18N_DEFAULT_PREFIX_REDIRECT = False

# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'realmento',
        'USER': 'postgres',
        'PASSWORD': 'root',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}
# DATABASE_URL=postgres:///postgres:root@localhost/realmento

DATABASES['default'] =  dj_database_url.config(default = 'postgres://postgres:root@localhost/realmento')
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

So what's the problem? Thanks a lot for your help!

PV8
  • 5,799
  • 7
  • 43
  • 87
jack lucky
  • 39
  • 2
  • 8

3 Answers3

4

Remove 'django.contrib.sites' from your settings file.

It worked for me.

prashant
  • 2,808
  • 5
  • 26
  • 41
  • 3
    A real explanation *why* this should work would be better than "works for me". That could also just be a coincidence. – GhostCat Sep 28 '17 at 09:22
  • https://stackoverflow.com/questions/19250048/why-does-removing-django-contrib-sites-from-installed-apps-fix-the-doesnotexi – Jihoon Baek Feb 28 '18 at 02:45
0

That's becaue /admin/login/ is not there, try opening

https://realmento.herokuapp.com/admin/ only.

or try opening

localhost:8000/admin/login/?next=/admin/

and see if it opens or not.

Bit68
  • 1,446
  • 10
  • 25
  • i accessed https://realmento.herokuapp.com/admin/ then it redirect to https://realmento.herokuapp.com/admin/login/?next=/admin/ . when i access localhost:8000/admin/login/?next=/admin/ it worked!!! – jack lucky Oct 01 '15 at 09:08
  • 1
    try changing the /admin url to something else, maybe the /admin is a predefined url for heroku. Do that an tell me what happens. – Bit68 Oct 01 '15 at 09:10
  • https://realmento.herokuapp.com/check ... it doesn't work.... i get message :Site matching query does not exist. – jack lucky Oct 01 '15 at 09:17
  • remove the sites middleware and let me know. – Bit68 Oct 01 '15 at 09:36
  • i don't understand your mean...!! why do you want to me remove the sites middware!? ... – jack lucky Oct 01 '15 at 09:41
  • 3
    'django.contrib.sites', remove this line from the installed apps – Bit68 Oct 01 '15 at 09:44
  • but when i use heroku run python manage.py syncdb statement , i get message error: CommandError: System check identified some issues: ERRORS: socialaccount.SocialApp.sites: (fields.E300) Field defines a relation with model 'Site', which is either not installed, or is abstract. – jack lucky Oct 01 '15 at 10:28
  • 1
    I use mysql or mysqlite. So nope :D – Bit68 Oct 01 '15 at 10:35
0

Did you run python manage.py collectstatic This will copy all files from your static folders into the STATIC_ROOT directory.

santosh
  • 3,947
  • 3
  • 21
  • 32