`
deepfuture
  • 浏览: 4350352 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:79581
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:68760
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:101965
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:282212
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:14710
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:66120
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:31485
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:45406
社区版块
存档分类
最新评论

django-构造第一个blog

 
阅读更多

1、安装好postgresql和psycopg2

2、django-admin.py startproject blog

3、manage.py startapp myblog

4、打开models.py


并编辑

 #!/usr/bin/env python 
from django.db import models

class BlogPost(models.Model):
    title=models.CharField(max_length=150)
    body=models.TextField()
    timestamp=models.DateTimeField()

 

打开settings.py



 并编辑其中的DATABASES段

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'myblog',                      # Or path to database file if using sqlite3.
        'USER': 'adadmin',                      # 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.
    }
}

 

5、创建表

F:\test\blog>manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any superuse
rs defined.
Would you like to create one now? (yes/no): y
Please enter either "yes" or "no": yes
Username (Leave blank to use 'deepfuture'): myblog
E-mail address: deepfuturelx@gmail.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
No fixtures found.

  • 大小: 57.5 KB
  • 大小: 61.3 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics