first commit
This commit is contained in:
0
myapp/__init__.py
Normal file
0
myapp/__init__.py
Normal file
BIN
myapp/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
myapp/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
myapp/__pycache__/admin.cpython-312.pyc
Normal file
BIN
myapp/__pycache__/admin.cpython-312.pyc
Normal file
Binary file not shown.
BIN
myapp/__pycache__/apps.cpython-312.pyc
Normal file
BIN
myapp/__pycache__/apps.cpython-312.pyc
Normal file
Binary file not shown.
BIN
myapp/__pycache__/models.cpython-312.pyc
Normal file
BIN
myapp/__pycache__/models.cpython-312.pyc
Normal file
Binary file not shown.
BIN
myapp/__pycache__/urls.cpython-312.pyc
Normal file
BIN
myapp/__pycache__/urls.cpython-312.pyc
Normal file
Binary file not shown.
BIN
myapp/__pycache__/views.cpython-312.pyc
Normal file
BIN
myapp/__pycache__/views.cpython-312.pyc
Normal file
Binary file not shown.
3
myapp/admin.py
Normal file
3
myapp/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
myapp/apps.py
Normal file
6
myapp/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class MyappConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'myapp'
|
||||
24
myapp/migrations/0001_initial.py
Normal file
24
myapp/migrations/0001_initial.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 5.2.8 on 2025-11-12 01:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='User',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('city', models.CharField(max_length=100)),
|
||||
('sex', models.CharField(max_length=100)),
|
||||
('age', models.IntegerField()),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
myapp/migrations/__init__.py
Normal file
0
myapp/migrations/__init__.py
Normal file
BIN
myapp/migrations/__pycache__/0001_initial.cpython-312.pyc
Normal file
BIN
myapp/migrations/__pycache__/0001_initial.cpython-312.pyc
Normal file
Binary file not shown.
BIN
myapp/migrations/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
myapp/migrations/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
10
myapp/models.py
Normal file
10
myapp/models.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class User(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
city = models.CharField(max_length=100)
|
||||
sex = models.CharField(max_length=100)
|
||||
age = models.IntegerField()
|
||||
|
||||
3
myapp/tests.py
Normal file
3
myapp/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
9
myapp/urls.py
Normal file
9
myapp/urls.py
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
from django.urls import path,include
|
||||
from myapp import views
|
||||
|
||||
urlpatterns = [
|
||||
path('user/', views.user),
|
||||
path('user_list/', views.user_list),
|
||||
path('user_add', views.user_add),
|
||||
]
|
||||
34
myapp/views.py
Normal file
34
myapp/views.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from django.shortcuts import render
|
||||
from django.http import HttpResponse
|
||||
from myapp.models import User
|
||||
# Create your views here.
|
||||
|
||||
def user(request):
|
||||
if request.method == 'GET':
|
||||
return HttpResponse('获取用户')
|
||||
elif request.method == 'POST':
|
||||
name = request.POST.get('name')
|
||||
city = request.POST.get('city')
|
||||
sex = request.POST.get('sex')
|
||||
age = request.POST.get('age')
|
||||
User.objects.create(
|
||||
name=name,
|
||||
city=city,
|
||||
sex = sex,
|
||||
age = age,
|
||||
|
||||
)
|
||||
print(request.POST)
|
||||
return HttpResponse('创建用户')
|
||||
elif request.method == 'PUT':
|
||||
return HttpResponse('创建用户')
|
||||
elif request.method == 'DELETE':
|
||||
return HttpResponse('删除用户')
|
||||
|
||||
def user_list(request):
|
||||
users = User.objects.all()
|
||||
return render(request, 'user_list.html', {'users': users})
|
||||
|
||||
|
||||
def user_add(request):
|
||||
return render(request, 'user_add.html')
|
||||
Reference in New Issue
Block a user