Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7776981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:01:09+00:00 2026-06-01T18:01:09+00:00

When I set settings.DEBUG=False, I lose access to my apps in the dashboard except

  • 0

When I set settings.DEBUG=False, I lose access to my apps in the dashboard except auth and sites. It work fine with settings.DEBUG=True.

# Django settings for blog project.
import sys
PROJECT_PATH=r'/home/www/blog'
if not PROJECT_PATH in sys.path:
    sys.path.insert(0,PROJECT_PATH)


DEBUG =False

TEMPLATE_DEBUG =False 

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '/home/www/blog/database.db',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Asia/Shanghai'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'zh-cn'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = '/home/www/blog/media/'

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = '/home/www/blog/staticDir/'

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    '/home/www/blog/static/',
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)


# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'blog.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'blog.wsgi.application'

TEMPLATE_DIRS = (
    '/home/www/blog/templates',
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)


INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'article',
    'guestbook',
    'multimedia',
    'archive',
    'about',
)

# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}

here is an app named article:

# coding:utf-8
from markdown import markdown
import datetime

from django.db import models

from django.contrib import admin

VIEWABLE_STATUS = [2,]

class ViewableManager(models.Manager):
    """
        改写 Model.objects 的 get_query_set 方法
        objects 不能接触状态为不可见的 Article 类的实体
    """
    def get_query_set(self):
        default_queryset = super(ViewableManager, self).get_query_set()
        return default_queryset.filter(status__in=VIEWABLE_STATUS)

class Article(models.Model):
    """
        文章类
    """
    STATUS_CHOICES=((1,'Editing'),
                    (2,'Posted'),)
    articleID=models.AutoField(primary_key=True)
    title=models.CharField(max_length=50,unique=True)
    slug = models.SlugField(max_length=50,unique=True)
    postDate=models.DateField()
    lastUpdate=models.DateTimeField(auto_now=True,auto_now_add=True)
    keywords=models.CharField(max_length=140,blank=True)
    markdown_content=models.TextField()
    html_content=models.TextField(editable=False)
    status=models.IntegerField(choices=STATUS_CHOICES,default=1)
    class Meta:
        ordering=['-postDate','-lastUpdate']

    def get_url(self):
        return r'/article/'+str(self.slug)
    def __unicode__(self):
        return self.title
    def saveCategories(self):
        self.articleCategories.clear()
        categoryList=self.keywords.split()
        for category in categoryList:
            c=Category.objects.filter(label=category)
            if c:
                self.articleCategories.add(c[0])
            else:
                self.articleCategories.create(label=category)                

    def save(self):
        self.html_content=markdown(self.markdown_content)
        self.lastUpdate=datetime.datetime.now()
        super(Article,self).save()
        self.saveCategories()
        print self.html_content
        print self.lastUpdate
        super(Article,self).save()

    admin_objects=models.Manager()
    objects=ViewableManager()

class ArticleAdmin(admin.ModelAdmin):
    list_display = ('title',  'status', 'postDate', 'lastUpdate')
    search_fields = ('title', 'keywords','content')
    list_filter = ('status', 'postDate', 'lastUpdate')

admin.site.register(Article, ArticleAdmin)

class Category(models.Model):
    label=models.CharField(max_length=30,unique=True)
    masterArticle=models.ManyToManyField(Article,related_name='articleCategories',blank=True)
    class Meta:
        verbose_name_plural = "categories" 
    def __unicode__(self):
        return self.label
class CategoryAdmin(admin.ModelAdmin):
    pass

admin.site.register(Category, CategoryAdmin)

And other app named guestbook

# coding:utf-8
from django.db import models
from django.contrib import admin
from md5 import md5 
from article.models import Article

class guestMessage(models.Model):
    guestName=models.CharField(max_length=50)
    guestEmail=models.EmailField(max_length=75)
    gravatarHash=models.CharField(max_length=33,blank=True)
    content=models.TextField()
    postDate=models.DateTimeField(auto_now_add=True)
    article=models.ForeignKey(Article,blank=True,null=True,
                              related_name='guestMessage')
    def save(self):
        super(guestMessage,self).save()
        self.gravatarHash=(md5(self.guestEmail)).hexdigest()
        super(guestMessage,self).save()    


class guestMessageAdmin(admin.ModelAdmin):
    list_display = ('guestName',  'article', 'postDate')
    search_fields = ('guestName', 'article','content')
    list_filter = ('article', 'postDate')

admin.site.register(guestMessage, guestMessageAdmin)

here is the urls.py

    from django.conf.urls.defaults import patterns, include, url
from django.conf import settings
from django.conf.urls.static import static
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
     url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns('article.views',
    url(r'^$', 'index'),
    url(r'^article/([\S]+)$', 'articleDetail'),
    url(r'^category/([\S]+)$','articleBYcategory'),
    url(r'^search/$','atricleSearch'),
)

urlpatterns += patterns('guestbook.views',
    url(r'^guestbook/$','guestbook'),
)

urlpatterns += patterns('archive.views',
    url(r'^archive/$','archive'),
)

urlpatterns += patterns('about.views',
    url(r'^about/$','about'),
)

http://www.mysite.com/admin: there is no add or change link . I don’t have permission?
pic link: http://img3.douban.com/view/photo/photo/public/p1499852307.jpg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:01:10+00:00Added an answer on June 1, 2026 at 6:01 pm

    I have no other ideas than move registering admin sites out of models. Official docs say about them residing in separate admin module.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to set a setting (nglayout.debug.disable_xul_cache) to true. But when i enter
I have tried setting the debug flags using the set command in cmake but
If a SharePoint user (with Regional Settings set to UK) views a calculated date
HI, I want to have set configuration settings for a unit test project that
Can we set the build settings for different targets in the project build settings
When a popover shows, I'm curious whether it's possible to set the underlying settings
I set a variable MAX_REQUEST = 100 in settings.py I write a middleware which
Currently I use Registry Settings within the Setup Project to set the file associations
I want to use my iphone to set alter my wireless router settings, and
Is there any way to set/update values in the settings.bundle from within your app.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.