这里要说下安装vue 的依赖包
教程是用cnpm 而不是npm 我查了一下 是淘宝出的 npm 所以要去安装下
npm install cnpm -g --registry=https://registry.npm.taobao.org
就可以了然后到vue项目的所在目录 执行 cnpm install
等待完成就可以了
然后执行 cnpm run dev即可
但是我的前端包好像少了许多东西 回头找下完整的包
接下来就是django 建app
分别 startapp goods trade user_operation (这3个分别startapp)
然后写user的model
# -*- coding:utf-8 -*-
from datetime import datetime
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class UserProfile(AbstractUser):
"""
用户
"""
GENDER_CHOICES = (
('male', u'男'),
('female', u'女')
)
name = models.CharField(max_length=30, null = True, blank = True, verbose_name=u'姓名')
birthday = models.DateField(null = True, blank=True, verbose_name=u'出生年月')
mobile = models.CharField(max_length=11, verbose_name=u'电话')
gender = models.CharField(max_length=6, choices=GENDER_CHOICES, default='female', verbose_name=u'性别')
email = models.CharField(max_length=100, null=True, blank=True, verbose_name=u'邮箱')
class Meta:
verbose_name = u'用户'
verbose_name_plural = verbose_name
def __str__(self):
return self.name
class VerifyCode(models.Model):
"""
短信验证码
"""
code = models.CharField(max_length=10, verbose_name=u'验证码')
mobile = models.CharField(max_length=11, verbose_name=u'电话')
add_time = models.DateTimeField(default=datetime.now, verbose_name=u'添加时间')
class Meta:
verbose_name = u'短信验证码'
verbose_name_plural = verbose_name
def __str__(self):
return self.code
然后在settings.py中添加以下代码:
AUTH_USER_MODEL = 'users.UserProfile'
其实这篇Django方面的内容都是上次教程中的