简体   繁体   中英

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.

I am working on a Django project with my colleague, and the other day our CSS stoped working. From what we recall, none of us touched anything related to CSS, but neither the CSS fom the admin pages nor our ones work.

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 """

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

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

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(r'^(.+)$', 'fanApp.views.defaultAction'),

It is better to use a middleware like PageFallbackMiddleware for this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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