コード例 #1
0
ファイル: views.py プロジェクト: sachintomacc/blog
def index(request):
    featured = Post.objects.filter(featured=True)
    latest = Post.objects.order_by('-timestamp')[0:3]
    if request.method == 'POST':
        email = request.POST['email']
        new_signup = SignUp()
        new_signup.email = email
        new_signup.save()
    context = {'posts': featured, 'latest': latest}
    return render(request, 'index.html', context)
コード例 #2
0
ファイル: views.py プロジェクト: ahmedmunir/django-blog
    def post(self, request, *args, **kwargs):
        email = request.POST.get('email')
        new_signup = SignUp()
        new_signup.email = email
        new_signup.save()

        messages.success(
            request,
            'You successfully registered for newsletter for our website')
        return redirect('blog-home')
コード例 #3
0
def index(request):
    posts = Posts.objects.filter(featured=True)
    latest = Posts.objects.order_by('upload_date')[0:3]
    if request.method == "POST":
        email = request.POST.get("email")
        new_signup = SignUp()
        new_signup.email = email
        new_signup.save()
    contex = {"posts": posts, "latest": latest}
    return render(request, 'index.html', contex)
コード例 #4
0
def index(request):
    featured = Post.objects.filter(featured=True)

    if request.method == 'POST':
        email = request.POST["email"]
        new_signup = SignUp()
        new_signup.email = email
        new_signup.save()
    context = {
        'object_list': featured,
    }
    return render(request, 'index.html', context)
コード例 #5
0
def about(request):
    featured = Post.objects.filter(featured=True)
    latest = Post.objects.order_by('-timestamp')[0:3]

    if request.method == "POST":
        email = request.POST['email']
        new_signup = SignUp()
        new_signup.email = email
        new_signup.save()

    context = {'object_list': featured, 'latest': latest}
    return render(request, 'about.html', context)
コード例 #6
0
def index(request):
    featured = Post.objects.filter(featured=True)
    latest = Post.objects.order_by('-timestamp')[0:3]
    form = EmailSignUpForm()
    if request.method == "POST":
        email = request.POST['email']
        new_signup = SignUp()
        new_signup.email = email
        new_signup.save()

    context = {'object_list': featured, 'latest': latest, 'form': form}
    return render(request, 'index.html', context)
コード例 #7
0
def index(request):

    featured = Post.objects.filter(featured=True, status='published')[0:3]
    latest = Post.objects.filter(
        status='published').order_by('-timestamp')[0:3]

    if request.method == "POST":
        email = request.POST["email"]
        new_signup = SignUp()
        new_signup.email = email
        new_signup.save()

    context = {'object_list': featured, 'latest': latest}
    return render(request, 'index.html', context)
コード例 #8
0
def index(request):
    # featured = Post.objects.filter(featured = True)
    latest = Post.objects.order_by('-timestamp')[0:3]

    if request.method == "POST":
        email = request.POST["email"]
        new_signup = SignUp()
        new_signup.email = email
        new_signup.save()

    context = {
        # 'object_list': featured,
        'latest': latest,
    }
    return render(request, "index.html", context)
コード例 #9
0
ファイル: views.py プロジェクト: krishnapm642/portfolio
def index(request):
	featured = BlogPost.objects.filter(featured = True)
	latest = BlogPost.objects.order_by('-timestamp')[0:3]

	if request.method == 'POST':
		Email = request.POST['email']
		sighup = SignUp()
		sighup.email = Email
		sighup.save()

	context = {
		'object_list' : featured,
		'latest':latest
	}
	return render(request, 'blogs/index.html', context)
コード例 #10
0
 def post(self, request, *args, **kwargs):
     email = request.POST.get('email')
     new_signup = SignUp()
     new_signup.email = email
     new_signup.save()
     return redirect("index")