Created
March 24, 2016 11:53
-
-
Save yinzishao/7c98426911a67d16a41f to your computer and use it in GitHub Desktop.
my_blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
<OptionsSetting value="true" id="Add" /> | |
<OptionsSetting value="true" id="Remove" /> | |
<OptionsSetting value="true" id="Checkout" /> | |
<OptionsSetting value="true" id="Update" /> | |
<OptionsSetting value="true" id="Status" /> | |
<OptionsSetting value="true" id="Edit" /> | |
<ConfirmationsSetting value="0" id="Add" /> | |
<ConfirmationsSetting value="0" id="Remove" /> | |
</component> | |
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.4.3 (/usr/bin/python3.4)" project-jdk-type="Python SDK" /> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/my_blog.iml" filepath="$PROJECT_DIR$/.idea/my_blog.iml" /> | |
</modules> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="PYTHON_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="VcsDirectoryMappings"> | |
<mapping directory="" vcs="" /> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ChangeListManager"> | |
<option name="TRACKING_ENABLED" value="true" /> | |
<option name="SHOW_DIALOG" value="false" /> | |
<option name="HIGHLIGHT_CONFLICTS" value="true" /> | |
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | |
<option name="LAST_RESOLUTION" value="IGNORE" /> | |
</component> | |
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" /> | |
<component name="CreatePatchCommitExecutor"> | |
<option name="PATCH_PATH" value="" /> | |
</component> | |
<component name="NamedScopeManager"> | |
<order /> | |
</component> | |
<component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
<OptionsSetting value="true" id="Add" /> | |
<OptionsSetting value="true" id="Remove" /> | |
<OptionsSetting value="true" id="Checkout" /> | |
<OptionsSetting value="true" id="Update" /> | |
<OptionsSetting value="true" id="Status" /> | |
<OptionsSetting value="true" id="Edit" /> | |
<ConfirmationsSetting value="0" id="Add" /> | |
<ConfirmationsSetting value="0" id="Remove" /> | |
</component> | |
<component name="PropertiesComponent"> | |
<property name="settings.editor.selected.configurable" value="configurable.group.appearance" /> | |
<property name="settings.editor.splitter.proportion" value="0.2" /> | |
</component> | |
<component name="ShelveChangesManager" show_recycled="false" /> | |
<component name="TaskManager"> | |
<task active="true" id="Default" summary="Default task"> | |
<option name="number" value="Default" /> | |
</task> | |
<servers /> | |
</component> | |
<component name="VcsContentAnnotationSettings"> | |
<option name="myLimit" value="2678400000" /> | |
</component> | |
<component name="XDebuggerManager"> | |
<breakpoint-manager /> | |
<watches-manager /> | |
</component> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from article.models import Article | |
# Register your models here. | |
admin.site.register(Article) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
class Migration(migrations.Migration): | |
dependencies = [ | |
] | |
operations = [ | |
migrations.CreateModel( | |
name='Article', | |
fields=[ | |
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | |
('title', models.CharField(max_length=100)), | |
('category', models.CharField(max_length=50, blank=True)), | |
('date_time', models.DateTimeField(auto_now_add=True)), | |
('content', models.TextField(null=True, blank=True)), | |
], | |
options={ | |
'ordering': ['-date_time'], | |
}, | |
), | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
from django.core.urlresolvers import reverse | |
from django.db import models | |
# Create your models here. | |
class Article(models.Model): | |
title = models.CharField(max_length = 100) #博客题目 | |
category = models.CharField(max_length = 50, blank = True) #博客标签 | |
date_time = models.DateTimeField(auto_now_add = True) #博客日期 | |
content = models.TextField(blank = True, null = True) #博客文章正文 | |
#获取URL并转换成url的表示格式 | |
def get_absolute_url(self): | |
path = reverse('detail', kwargs={'id':self.id}) | |
return "http://127.0.0.1:8000%s" % path | |
def __unicode__(self) : | |
return self.title | |
class Meta: #按时间下降排序 | |
ordering = ['-date_time'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponse, Http404 | |
from django.shortcuts import render | |
# Create your views here. | |
from models import Article | |
def home(request): | |
post_list = Article.objects.all() | |
return render(request,'home.html',{"post_list":post_list}) | |
# return render(request,'test.html') | |
# return HttpResponse(str(2)) | |
def detail(request, id): | |
try: | |
post = Article.objects.get(id=str(id)) | |
except Article.DoesNotExist: | |
raise Http404 | |
return render(request, 'post.html', {'post' : post}) | |
def archives(request): | |
try: | |
post_list = Article.objects.all() | |
except Article.DoesNotExist: | |
raise Http404 | |
return render(request,'archives.html',{'post_list':post_list}) | |
def search_tag(request, tag) : | |
try: | |
post_list = Article.objects.filter(category__iexact = tag) #contains | |
except Article.DoesNotExist : | |
raise Http404 | |
return render(request, 'tag.html', {'post_list' : post_list}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQLite format 3 @ 3 E + 3 -� � &������ ) ! Y ��d��I��Y 2 %Aarticle0001_initial2016-03-22 13:11:02.3070063 | |
%Asessions0001_initial2016-03-22 12:55:44.692514A IAauth0006_require_contenttypes_00022016-03-22 12:55:44.491860B KAauth0005_alter_user_last_login_null2016-03-22 12:55:44.391047@ GAauth0004_alter_user_username_opts2016-03-22 12:55:44.156146C MAauth0003_alter_user_email_max_length2016-03-22 12:55:43.910666H WAauth0002_alter_permission_name_max_length2016-03-22 12:55:43.664562H %GAcontenttypes0002_remove_content_type_name2016-03-22 12:55:43.4514290 %Aadmin0001_initial2016-03-22 12:55:43.161393/ %Aauth0001_initial2016-03-22 12:55:42.9269827 %%Acontenttypes0001_initial2016-03-22 12:55:42.658758 � V����lV | |
-django_admin_log +article_article3django_content_type+auth_permission� auth_user /django_migrations | |