使用grappelli为django admin后台添加模板

yipeiwu_com6年前Python基础

grappelli是github上面star最多的django模板系统
http://django-grappelli.readthedocs.org/en/latest/quickstart.html

复制代码 代码如下:

pip install django-grappelli
settings.py

INSTALLED_APPS = (
    'grappelli',
    'django.contrib.admin',
)

添加url项

复制代码 代码如下:

urlpatterns = patterns('',
    (r'^grappelli/', include('grappelli.urls')), # grappelli URLS
    (r'^admin/',  include(admin.site.urls)), # admin site
)

官方安装说明中有让定义STATICFILES_FINDER,但是跟默认值一样,忽略

定义模板context processors

复制代码 代码如下:

    TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.core.context_processors.tz",
    "django.contrib.messages.context_processors.messages"
)

此处为了方便已经加上了django1.7的默认值.

相关文章

Python Web框架之Django框架Form组件用法详解

本文实例讲述了Python Web框架之Django框架Form组件用法。分享给大家供大家参考,具体如下: Form简介 在HTTP中,表单(form标签),是用来提交数据的,其acti...

Python自定义一个类实现字典dict功能的方法

如下所示: import collections class Mydict(collections.UserDict): def __missing__(self, ke...

windows环境中利用celery实现简单任务队列过程解析

windows环境中利用celery实现简单任务队列过程解析

这篇文章主要介绍了windows环境中利用celery实现简单任务队列过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 一、背景...

pytorch获取模型某一层参数名及参数值方式

1、Motivation: I wanna modify the value of some param; I wanna check the value of some param....

TensorFlow实现RNN循环神经网络

TensorFlow实现RNN循环神经网络

RNN(recurrent neural Network)循环神经网络 主要用于自然语言处理(nature language processing,NLP) RNN主要用途是处理和预测序...