Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making django.contrib.sites optional as it should not be necessary for this reusable app #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions django_config_gen/management/defaults.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
#Copyright (C) 2010, 2011 Seán Hayes
# Copyright (C) 2010, 2011 Seán Hayes
#
#Licensed under a BSD 3-Clause License. See LICENSE file.
# Licensed under a BSD 3-Clause License. See LICENSE file.

import __main__
import os
from django.contrib.sites.models import Site

from django.db import transaction

import __main__


PROJECT_ROOT = os.path.abspath(os.path.dirname(__main__.__file__))
LOG_DIR = os.path.join(PROJECT_ROOT, 'logs')
Expand All @@ -19,13 +20,13 @@
CONTEXT_PROCESSORS = []


# Error is thrown when running "./manage.py syncdb" for the first time and this app is installed.
try:
from django.contrib.sites.models import Site
HOST = Site.objects.get_current().domain.split(':')[0]
except:
# try/except to avoid "django.db.transaction.TransactionManagementError: This code isn't under transaction management"
try:
transaction.rollback()
except:
pass
HOST = 'localhost'