This commit is contained in:
chenyang
2022-06-29 08:18:58 +08:00
parent 16fbea9f1d
commit 553895477c
10 changed files with 84 additions and 5 deletions
+5 -1
View File
@@ -38,6 +38,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'rest_framework',
'server',
'server_auth',
'channels',
]
@@ -116,7 +117,7 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
@@ -138,3 +139,6 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# 静态文件目录
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
# AUTH_USER_MODEL为我们自定义的用户类
AUTH_USER_MODEL = "server_auth.MindUser"
View File
+3
View File
@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.
+6
View File
@@ -0,0 +1,6 @@
from django.apps import AppConfig
class ServerAuthConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'server_auth'
+46
View File
@@ -0,0 +1,46 @@
# Generated by Django 3.2.11 on 2022-06-29 08:18
import django.contrib.auth.models
import django.contrib.auth.validators
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
]
operations = [
migrations.CreateModel(
name='MindUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('wx_openid', models.CharField(blank=True, max_length=64, null=True, verbose_name='微信openid')),
('wx_nick_name', models.CharField(blank=True, max_length=64, null=True, verbose_name='微信名称')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'verbose_name': '脑图用户表',
'db_table': 'mind_user',
'ordering': ['-id'],
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
]
View File
+15
View File
@@ -0,0 +1,15 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class MindUser(AbstractUser):
# 继承了AbstractUser拥有的所有字段
# 自定义我们需要的字段
wx_openid = models.CharField(verbose_name='微信openid', max_length=64, null=True, blank=True)
wx_nick_name = models.CharField(verbose_name='微信名称', max_length=64, null=True, blank=True)
class Meta:
db_table = 'mind_user'
ordering = ['-id']
verbose_name = "脑图用户表"
+3
View File
@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.
+3
View File
@@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.
+3 -4
View File
@@ -23,10 +23,9 @@
</head>
<body>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">Primary</button>
<!-- Modal start-->
<div class="modal fade" id="exampleModal" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
@@ -35,7 +34,7 @@
</button>
</div>
<div class="modal-body">
...
<img src="https://img0.baidu.com/it/u=3881180510,1470858589&fm=253&fmt=auto&app=138&f=JPEG?w=200&h=200" height="300px">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
@@ -50,7 +49,7 @@
<a class="navbar-brand col-md-2 col-lg-2 mr-0 px-3" href="#">协作思维导图</a>
<ul class="navbar-nav px-3">
<li class="nav-item text-nowrap">
<a class="nav-link" href="#">登录/注册</a>
<a class="nav-link" href="#" data-toggle="modal" data-target="#exampleModal">登录/注册</a>
</li>
</ul>
</nav>