Hi Kubilay,

I guess you could use sessions for that.

For example:

contest = request.session['contest_name']

See: https://docs.djangoproject.com/en/2.0/topics/http/sessions/

HTH

Etienne


Le 2017-12-18 à 10:36, Kubilay Yazoğlu a écrit :
Hello. I have two apps. Posts and Contests.

In templates/contest/detail.html, there is a button that takes you to templates/post/create.html

What I want is to send the contest name from detail to create so that the post will be added to the right contest. For that, I guess I should do something to send contest name from detail.html to create view of post/create. Right? In the following code (post\views.py), the contest name is determined randomly. Help me to get the right contest please.

if request.method== 'POST': items= Contest.objects.all()
     random_item= random.choice(items)
     form= PostForm(request.POST,request.FILES)

     if form.is_valid(): post= form.save(commit = False)
         post.contest= random_item
         post.ownername= request.user
         post.save()
         messages.success(request,'You have succesfully sent a post')
         return HttpResponseRedirect(random_item.get_absolute_url())
else: form= PostForm()
--
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ddc3b1d3-32a3-4457-a36d-5cbbea6255b6%40googlegroups.com <https://groups.google.com/d/msgid/django-users/ddc3b1d3-32a3-4457-a36d-5cbbea6255b6%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/28b623ce-0214-0814-82c1-a1d9f1f3aef5%40yandex.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to