示例#1
0
def create(request):
    data = get_user(request)
    if request.method == 'GET':
        data['form'] = PostForm()
        return render(request, 'news/create.html', context=data)
    elif request.method == 'POST':
        fill_form = PostForm(request.POST, request.FILES)
        fill_form.save()
        return redirect('/news')
示例#2
0
def create(request):
    data = get_user(request)
    if request.method == 'GET':
        data['form'] = AdForm()
        return render(request, 'category/create.html', context=data)
    elif request.method == 'POST':
        ad_form = AdForm(request.POST, request.FILES)
        #ad_form.Meta.model.publish = timezone.now()
        ad_form.save()
        return redirect('category/wear')
示例#3
0
def forhome(request):
    data: dict = get_user(request)
    return render(request, 'category/forhome.html', context=data)
示例#4
0
def turism(request):
    data: dict = get_user(request)
    return render(request, 'category/turism.html', context=data)
示例#5
0
def electronics(request):
    data: dict = get_user(request)
    return render(request, 'category/electronics.html', context=data)
示例#6
0
def wear(request):
    data: dict = get_user(request)
    ads = Ad.objects.all()
    data['ads'] = ads
    return render(request, 'category/wear.html', context=data)
示例#7
0
def index(request):
    data = get_user(request)
    posts = Post.objects.all()
    data['posts'] = posts
    return render(request, 'news/index.html', context=data)
示例#8
0
def delete(request, post_id):
    data = get_user(request)
    data['post'] = Post.objects.get(id=post_id)
    return render(request, 'news/delete.html', context=data)