标签:user utils python zone foreign delete auth osi pytho
1、django-admin startproject mysite
2、进到mysite目录 python manage runserver
使用 http://172.0.0.1:8000/ 登录
3、创建应用 python manage startapp blog
4、在models.py 写数据模型
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
class BlogArticles(models.Model):
title = models.CharField(max_length=300)
author = models.ForeignKey(User,related_name=‘blog_posts‘,on_delete = models.CASCADE,)
body = models.TextField()
publish = models.DateTimeField(default=timezone.now)
class Meta:
ordering = (‘-publish‘,)
def __str__(self):
return self.title
开始报TypeError: __init__() missing 1 required positional argument: ‘on_delete‘错误,查询解决https://www.cnblogs.com/phyger/p/8035253.html
5、https://www.cnblogs.com/0bug/p/8193356.html
标签:user utils python zone foreign delete auth osi pytho
原文地址:https://www.cnblogs.com/lxr0529/p/9136568.html