django-blog(一) 博客分类: django
程序员文章站
2024-03-19 11:17:10
...
706 mkdir blogenv
707 cd blogenv/
708 pip install virtualenv
709 virtualenv blog_env
710 ls
711 cd blog_env/
725 source bin/activate
726 pip install django
727 django-admin startproject blogproject
728 cd blogproject/
730 python manage.py startapp blog
736 pip install pillow
737 vim blogproject/settings.py
707 cd blogenv/
708 pip install virtualenv
709 virtualenv blog_env
710 ls
711 cd blog_env/
725 source bin/activate
726 pip install django
727 django-admin startproject blogproject
728 cd blogproject/
730 python manage.py startapp blog
736 pip install pillow
737 vim blogproject/settings.py
mkdir templetes static
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog'
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [ os.path.join(BASE_DIR,'templates')], #templates seting
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
STATIC_URL = '/static/'
STATICFILES_DIRS=( os.path.join(BASE_DIR,'static'),)
vim blog/views.py
def index(request):
return render(request,'index.html')
vim blogproject/url.py
from django.conf.urls import url
from django.contrib import admin
from blog.views import *
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$',index,name='index'),
]
模版设置
vim index.html
{% load staticfiles %}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{ SITE_NAME }}</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href='{% static "css/base.css" %}' rel="stylesheet">
<link href='{% static "css/index.css" %}' rel="stylesheet">
<script type="text/javascript" src='{% static "js/jquery.min.js" %}'></script>
<script type="text/javascript" src='{% static "js/sliders.js" %}'></script>
推荐阅读
-
django分页 博客分类: python
-
django-blog(一) 博客分类: django
-
django-blog(六)自定义富媒体 博客分类: django
-
django-blog(一) 博客分类: django
-
django-blog(四)自定义公共字段 博客分类: django
-
Django之CBV装饰器method_decorator 博客分类: django
-
hibernate注解初探 博客分类: Hibernate hibernate注解唯一性约束
-
hibernate注解初探 博客分类: Hibernate hibernate注解唯一性约束
-
阿里巴巴的fastjson使用分析(一) 博客分类: 开发工具包 javajson
-
阿里巴巴的fastjson使用分析(一) 博客分类: 开发工具包 javajson