def retweet(request, tweet_id): tweet = get_object_or_404(Tweet, id=tweet_id) t = Tweet() t.user = request.user t.message = "RT " + tweet.message t.save() return HttpResponseRedirect("/")
def timeline(request): if request.method == "POST": form = TweetForm(request.POST) if form.is_valid(): t = Tweet() t.user = request.user t.message = form.cleaned_data['message'] t.save() return HttpResponseRedirect("/") else: form = TweetForm() tweets = Tweet.objects.all().order_by("-timestamp") return render(request, "website/index.html", {"tweets" : tweets, "form" : form, "show_add_tweet" : True} )
def timeline(request): if request.method == "POST": form = TweetForm(request.POST) if form.is_valid(): t = Tweet() t.user = request.user t.message = form.cleaned_data['message'] t.save() return HttpResponseRedirect("/") else: form = TweetForm() tweets = Tweet.objects.all().order_by('-timestamp') return render(request, 'website/index.html', {'tweets': tweets, 'form': form})