python django 社团管理系统(毕设、课设、学习)

python django 社团管理系统(毕设、课设、学习),第1张

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)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/741399.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-28
下一篇 2022-04-28

发表评论

登录后才能评论

评论列表(0条)

保存