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')
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')
def forhome(request): data: dict = get_user(request) return render(request, 'category/forhome.html', context=data)
def turism(request): data: dict = get_user(request) return render(request, 'category/turism.html', context=data)
def electronics(request): data: dict = get_user(request) return render(request, 'category/electronics.html', context=data)
def wear(request): data: dict = get_user(request) ads = Ad.objects.all() data['ads'] = ads return render(request, 'category/wear.html', context=data)
def index(request): data = get_user(request) posts = Post.objects.all() data['posts'] = posts return render(request, 'news/index.html', context=data)
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)