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()
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
--
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...@googlegroups.com.
To post to this group, send email to django...@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.
For more options, visit https://groups.google.com/d/optout.
-- Etienne Robillard tka...@yandex.com https://www.isotopesoftware.ca/