-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
56 lines (37 loc) · 1.45 KB
/
models.py
File metadata and controls
56 lines (37 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
__author__ = 'lmm'
# from __future__ import unicode_literals
from django.db import models
from django.utils import timezone
from django import forms
# Create your models here.
class Test(models.Model):
name = models.CharField(max_length=20)
def __str__(self):
return self.name
class Album(models.Model):
pass
class article(models.Model):
title = models.CharField(verbose_name = '标题', max_length = 200)
text = models.TextField(verbose_name = '内容')
create_date = models.DateTimeField(verbose_name = '创建时间', default = timezone.now)
publish_date = models.DateTimeField(verbose_name = '发布时间', blank = True,null = True)
def publish(self):
self.publish_date = timezone.now()
self.save()
def __str__(self):
return self.title
def getAllList(self):
pass
# 按照create_data降序排序,'-'表示降序,不加表示正序
class Meta:
ordering = ('-create_date',)
class ArticleForm(forms.ModelForm):
class Meta:
model = article
exclude = ('create_date','publish_date')
if __name__ == '__main__':
pass
# FAQ: Unknown command: 'syncdb'
# Your models have changes that are not yet reflected in a migration, and so won't be applied.
# Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them