python django 社团管理系统
python django 社员管理系统
该系统简介:
后端:python django
数据库:MySQL
前端:HTML css js
设计功能:
登陆、注册、登出、修改密码等
添加社团成员、添加社员描述、添加社员照片、社团分类、搜索社员等等
源码下载:
链接:https://pan.baidu.com/s/1-ZLWl8SDa-OPKXgUz4ptrA
提取码:tcin
注册功能代码实现:
#注册
def sign_up(request):
if request.user.is_authenticated:
return HttpResponseRedirect(reverse('homepage'))
state = None
if request.method == 'POST':
password = request.POST.get('password', '')
repeat_password = request.POST.get('repeat_password', '')
if password == '' or repeat_password == '':
state = 'empty'
elif password != repeat_password:
state = 'repeat_error'
else:
username = request.POST.get('username', '')
if User.objects.filter(username=username):
state = 'user_exist'
else:
new_user = User.objects.create_user(username=username, password=password,
email=request.POST.get('email', ''))
new_user.save()
state = 'success'
context = {
'active_menu': 'homepage',
'state': state,
'user': None
}
return render(request, 'management/sign_up.html', context)
社员列表:
#社员列表
@login_required
def book_list(request, category='all'):
user = request.user
category_list = Book.objects.values_list('category', flat=True).distinct()
if Book.objects.filter(category=category).count() == 0:
category = 'all'
books = Book.objects.all()
else:
books = Book.objects.filter(category=category)
paginator = Paginator(books, 10000)
page = request.GET.get('page')
try:
books = paginator.page(page)
except PageNotAnInteger:
books = paginator.page(1)
except EmptyPage:
books = paginator.page(paginator.num_pages)
context = {
'user': user,
'active_menu': 'view_book',
'category_list': category_list,
'query_category': category,
'book_list': books
}
return render(request, 'management/book_list.html', context)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)