Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified db.sqlite3
Binary file not shown.
3 changes: 2 additions & 1 deletion training/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib import admin

from .models import Post
# Register your models here.
admin.site.register(Post)
2 changes: 1 addition & 1 deletion training/templates/training/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<title>培训公司管理系统</title>
</head>
<body>
欢迎
<p><a href="{% url 'post_create' %}">添加文章</a></p>
</body>
</html>
14 changes: 14 additions & 0 deletions training/templates/training/post_create.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>添加公告</title>
</head>
<body>
<form action="." method="post">
{% csrf_token %}
{{ form.as_p }}
<p><input type="submit" value="添加"></p>
</form>
</body>
</html>
1 change: 1 addition & 0 deletions training/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
from . import views
urlpatterns = [
path('',views.index,name='index'),
path('create/',views.PostCreat.as_view(),name='post_create')
]
13 changes: 12 additions & 1 deletion training/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from django.shortcuts import render
from django.views.generic import CreateView
from .models import Post, Profile, Course
from django.urls import reverse_lazy


# Create your views here.
def index(request):
return render(request,'training/index.html')
return render(request, 'training/index.html')


class PostCreat(CreateView):
model = Post
fields = ('title', 'content',)
template_name = 'training/post_create.html'
success_url = reverse_lazy('index')