Пример #1
0
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("/")
Пример #2
0
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} )
Пример #3
0
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})