Skip to content

Commit f7467c8

Browse files
committed
django3
1 parent 4d56719 commit f7467c8

21 files changed

+208
-170
lines changed

api/migrations/0001_initial.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Generated by Django 3.0.5 on 2020-04-19 09:30
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='User',
16+
fields=[
17+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('name', models.CharField(max_length=100)),
19+
('age', models.IntegerField()),
20+
],
21+
),
22+
]

api/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.forms.models import model_to_dict
55
from django.contrib import auth
66
from django.contrib.auth.decorators import login_required
7-
from guest2.settings import BASE_DIR
7+
from guest3.settings import BASE_DIR
88
from api.models import User
99
from api.common import response
1010

db.sqlite3

12 KB
Binary file not shown.

guest2/__init__.py

-2
This file was deleted.

guest3/__init__.py

Whitespace-only changes.

guest3/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for guest3 project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'guest3.settings')
15+
16+
application = get_asgi_application()

guest2/settings.py guest3/settings.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
2-
Django settings for guest2 project.
2+
Django settings for guest3 project.
33
4-
Generated by 'django-admin startproject' using Django 2.0.
4+
Generated by 'django-admin startproject' using Django 3.0.5.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/2.0/topics/settings/
7+
https://docs.djangoproject.com/en/3.0/topics/settings/
88
99
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/2.0/ref/settings/
10+
https://docs.djangoproject.com/en/3.0/ref/settings/
1111
"""
1212

1313
import os
@@ -17,10 +17,10 @@
1717

1818

1919
# Quick-start development settings - unsuitable for production
20-
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
20+
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
2121

2222
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = '&bgi^6l3)&^d$a!g0j3i6a1)4)uo6)i!+nv(agmp&&9wf_m3ah'
23+
SECRET_KEY = 'du=2bvekws%16-p^^9h7d%&e^ue%pe0na5*jc@fluyh-hrmv#)'
2424

2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
@@ -38,7 +38,6 @@
3838
'django.contrib.messages',
3939
'django.contrib.staticfiles',
4040
'sign',
41-
'bootstrap3',
4241
'api',
4342
]
4443

@@ -52,7 +51,7 @@
5251
'django.middleware.clickjacking.XFrameOptionsMiddleware',
5352
]
5453

55-
ROOT_URLCONF = 'guest2.urls'
54+
ROOT_URLCONF = 'guest3.urls'
5655

5756
TEMPLATES = [
5857
{
@@ -70,12 +69,12 @@
7069
},
7170
]
7271

73-
WSGI_APPLICATION = 'guest2.wsgi.application'
72+
WSGI_APPLICATION = 'guest3.wsgi.application'
7473

7574

7675
# Database
77-
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
78-
# SQLite3 config
76+
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
77+
7978
DATABASES = {
8079
'default': {
8180
'ENGINE': 'django.db.backends.sqlite3',
@@ -94,8 +93,9 @@
9493
}
9594
}
9695
'''
96+
9797
# Password validation
98-
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
98+
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
9999

100100
AUTH_PASSWORD_VALIDATORS = [
101101
{
@@ -114,7 +114,7 @@
114114

115115

116116
# Internationalization
117-
# https://docs.djangoproject.com/en/2.0/topics/i18n/
117+
# https://docs.djangoproject.com/en/3.0/topics/i18n/
118118

119119
LANGUAGE_CODE = 'en-us'
120120

@@ -128,6 +128,6 @@
128128

129129

130130
# Static files (CSS, JavaScript, Images)
131-
# https://docs.djangoproject.com/en/2.0/howto/static-files/
131+
# https://docs.djangoproject.com/en/3.0/howto/static-files/
132132

133133
STATIC_URL = '/static/'

guest2/urls.py guest3/urls.py

+4-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""guest2 URL Configuration
1+
"""guest3 URL Configuration
22
33
The `urlpatterns` list routes URLs to views. For more information please see:
4-
https://docs.djangoproject.com/en/2.0/topics/http/urls/
4+
https://docs.djangoproject.com/en/3.0/topics/http/urls/
55
Examples:
66
Function views
77
1. Add an import: from my_app import views
@@ -14,11 +14,10 @@
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
1616
from django.contrib import admin
17-
from django.urls import path, include
17+
from django.urls import path, include
1818
from sign.views import views
1919

2020

21-
# 路由文件
2221
urlpatterns = [
2322
path('admin/', admin.site.urls),
2423
path('index/', views.index),
@@ -33,22 +32,10 @@
3332
path('search_phone/', views.search_phone),
3433
path('sign_index/<int:event_id>/', views.sign_index),
3534
#path('sign_index2/<int:event_id>/', views.sign_index2),
36-
path('sign_index_action/<int:event_id>/',views.sign_index_action),
35+
path('sign_index_action/<int:event_id>/', views.sign_index_action),
3736
path('logout/', views.logout),
3837
path('api/', include('sign.urls')),
3938

4039
path('v1/', include('api.urls')),
4140

4241
]
43-
44-
45-
46-
47-
48-
49-
50-
51-
52-
53-
54-
#

guest2/wsgi.py guest3/wsgi.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"""
2-
WSGI config for guest2 project.
2+
WSGI config for guest3 project.
33
44
It exposes the WSGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
88
"""
99

1010
import os
1111

1212
from django.core.wsgi import get_wsgi_application
1313

14-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "guest2.settings")
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'guest3.settings')
1515

1616
application = get_wsgi_application()

manage.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
23
import os
34
import sys
45

5-
if __name__ == "__main__":
6-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "guest2.settings")
6+
7+
def main():
8+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'guest3.settings')
79
try:
810
from django.core.management import execute_from_command_line
911
except ImportError as exc:
@@ -13,3 +15,7 @@
1315
"forget to activate a virtual environment?"
1416
) from exc
1517
execute_from_command_line(sys.argv)
18+
19+
20+
if __name__ == '__main__':
21+
main()

sign/admin.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
from django.contrib import admin
2-
from sign.models.event import Event
3-
from sign.models.guest import Guest
1+
# from django.contrib import admin
2+
# from sign.models.event import Event
3+
# from sign.models.guest import Guest
44

55

6-
# Register your models here.
7-
class EventAdmin(admin.ModelAdmin):
8-
list_display = ['name', 'status', 'start_time','id']
9-
search_fields = ['name'] # 搜索功能
10-
list_filter = ['status'] # 过滤器
6+
# # Register your models here.
7+
# class EventAdmin(admin.ModelAdmin):
8+
# list_display = ['name', 'status', 'start_time', 'id']
9+
# search_fields = ['name'] # 搜索功能
10+
# list_filter = ['status'] # 过滤器
1111

1212

13-
class GuestAdmin(admin.ModelAdmin):
14-
list_display = ['realname', 'phone','email','sign','create_time','event_id']
15-
list_display_links = ('realname', 'phone') # 显示链接
16-
search_fields = ['realname','phone'] # 搜索功能
17-
list_filter = ['event_id'] # 过滤器
13+
# class GuestAdmin(admin.ModelAdmin):
14+
# list_display = ['realname', 'phone', 'email',
15+
# 'sign', 'create_time', 'event_id']
16+
# list_display_links = ('realname', 'phone') # 显示链接
17+
# search_fields = ['realname', 'phone'] # 搜索功能
18+
# list_filter = ['event_id'] # 过滤器
1819

1920

20-
admin.site.register(Event, EventAdmin)
21-
admin.site.register(Guest, GuestAdmin)
21+
# admin.site.register(Event, EventAdmin)
22+
# admin.site.register(Guest, GuestAdmin)

sign/apps.py

-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@
33

44
class SignConfig(AppConfig):
55
name = 'sign'
6-
7-
## 应用的一些配置

sign/migrations/0001_initial.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 2.0 on 2018-01-13 16:06
1+
# Generated by Django 3.0.5 on 2020-04-19 01:11
22

33
from django.db import migrations, models
44
import django.db.models.deletion
@@ -35,9 +35,9 @@ class Migration(migrations.Migration):
3535
('create_time', models.DateTimeField(auto_now=True)),
3636
('event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sign.Event')),
3737
],
38-
),
39-
migrations.AlterUniqueTogether(
40-
name='guest',
41-
unique_together={('phone', 'event')},
38+
options={
39+
'ordering': ['-id'],
40+
'unique_together': {('phone', 'event')},
41+
},
4242
),
4343
]

sign/migrations/0002_auto_20190310_1848.py

-17
This file was deleted.

sign/models/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .event import Event
2+
from .guest import Guest

sign/templates/base.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<html>
22
<head>
3-
{% load bootstrap3 %}
4-
{% bootstrap_css %}
3+
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
54
</head>
65
<body>
76
{% block content %}

sign/templates/index.html

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
<html>
22

33
<head>
4-
{% load bootstrap3 %}
5-
{% bootstrap_css %}
4+
<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
65
</head>
76

87
<body>
98
<div class="container" style="width: 330px;">
109
<form class="form-signin" method="post" action="/login_action/">
1110
<h2 class="form-signin-heading">Guest System</h2>
1211
<label for="inputUsername" class="sr-only">Username</label>
13-
<input name="username" type="text" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
12+
<input name="username" type="text" id="inputUsername" class="form-control" placeholder="Username" autofocus>
1413
<label for="inputPassword" class="sr-only">Password</label>
15-
<input name="password" type="password" id="inputPassword" class="form-control" placeholder="Password" required>
14+
<input name="password" type="password" id="inputPassword" class="form-control" placeholder="Password">
1615
<p style="color:red">{{error}}</p> <br>
1716
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
1817
</form>

0 commit comments

Comments
 (0)