简体   繁体   English

在DJANGO中加载admin CSS和我的页面时出现问题

[英]Problems loading CSS of admin and my page in DJANGO

I have been going through stackoverflow for days looking for a answer to my problem. 我已经经历了几天的stackoverflow寻找我的问题的答案。

I am working on a Django project with my colleague, and the other day our CSS stoped working. 我正在与同事一起进行Django项目,而前几天我们的CSS停止工作。 From what we recall, none of us touched anything related to CSS, but neither the CSS fom the admin pages nor our ones work. 从我们的回忆中,我们没有人接触过与CSS相关的任何东西,但是无论是管理页面还是我们的CSS都不起作用。

We keep getting this: 我们不断得到这个:

[18/Feb/2014 06:45:18] "GET /static/css/style.css HTTP/1.1" 302 0

SETTINGS.PY """ Settings fan Project for AGBO """ SETTINGS.PY“”“ AGBO”“”设置风扇项目

DEBUG = True
TEMPLATE_DEBUG = DEBUG

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

MANAGERS = ADMINS

DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.sqlite3',     # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
    'NAME': 'fandb',                            # 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.
    }
}

TIME_ZONE = 'America/Chicago'


SITE_ID = 1

USE_I18N = True

USE_L10N = True

USE_TZ = True

MEDIA_ROOT = ''

MEDIA_URL = ''

STATIC_ROOT = ''


STATIC_URL = '/static/'


STATICFILES_DIRS = (
)


STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',

)

SECRET_KEY = '******'

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.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',
)

ROOT_URLCONF = 'fan.urls'

WSGI_APPLICATION = 'fan.wsgi.application'

TEMPLATE_DIRS = (
'templates'
)


INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'fanApp',
)

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,
    },
}
}

main.html call to css main.html调用CSS

link rel="stylesheet" type="text/css" href="http://localhost:1234/static/style.css" media="screen"

urls.py urls.py

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

admin.autodiscover()

urlpatterns = patterns('',
url(r'^$','fanApp.views.home', name='home'),
#Tweet
url(r'^newTweet$', 'fanApp.views.newTweet'),
url(r'^showAllTweets$','fanApp.views.showAllTweets'),
url(r'^deleteTweetFromDatabase/(.+)','fanApp.views.deleteTweetFromDatabase'),
#Repo
url(r'^showRepo$', 'fanApp.views.viewRepo'),
url(r'^deleteTweetFromRepo/(.+)','fanApp.views.deleteTweetRepo'),
url(r'^addTweetToRepo/(.+)','fanApp.views.addTweetRepo'),
#Algorithm
url(r'^viewAlgor','fanApp.views.viewAlgor'),
#Analyzers
url(r'^analyzer','fanApp.views.analyzer'),  
#Login/Logout
url(r'^login', 'django.contrib.auth.views.login'),
url(r'^logout', 'django.contrib.auth.views.logout',{'next_page':'/'}),
#WP Blogs
url(r'^cocoaosx','fanApp.views.cocoaosx'),
url(r'^agboBlog','fanApp.views.agboBlog'),
#Admin
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
#Default
url(r'accounts/profile/', 'fanApp.views.showAllTweets'),
url(r'^(.+)$', 'fanApp.views.defaultAction'),
)

I would really appreciate any help, It's driving us both mad and we cant find the problem anywhere. 我真的很感谢您的帮助,这使我们俩都疯了,我们在任何地方都找不到问题。

The problem is likely to be the catch-all URL in the end: 问题很可能是最后的全部URL:

url(r'^(.+)$', 'fanApp.views.defaultAction'),

It is better to use a middleware like PageFallbackMiddleware for this. 为此,最好使用像PageFallbackMiddleware这样的中间件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM