How do you use a link as a post request?
How do you use a link as a post request? this is a thing that I have never done before... maybe use it inside a form? I searched and didn't find anything similar in django... Thanks in advance! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/KuSVbiENOWMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
How can I make a view called "push" to add +1 to my Entry.push model?
I have this in mind: having entries in a page and people will be able to push them (voting them +1 to get them higher in the page). The more pushes the higher the post will be displayed. (I order them by the amount of pushes) I have put a submit button next to each post. The question: 1.How can I make a view called "push" to add +1 to my Entry.push model? 2. Is it possible to make it for each user to vote once? I have searched and i haven't really understood how request.POST and GET works... Thanks in advance!! -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/KVp0D9ZalUMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Problem with my view or template (DRIVES ME NUTS)
I don't get an error... Nothing just happens my view: (I think the problem is here) def push(request, pk): if request.method == 'POST': entry = Entry.objects.get(pk=pk) entry.pushes +=1 entry.save() My template: {% for entry in entries.object_list %} {{ entry.title }} Posted on {{ entry.posted }} by {{ entry.submitter }} | pushed {{ entry.pushes }} time(s). {% if user.is_authenticated %} #or maybe here... {% csrf_token %} {% endfor %} This is my first project and i haven't really understood how GET and POST request's work with models... Thanks in advance :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/8GXXgG28NcQJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with my view or template (DRIVES ME NUTS)
no, no errors get displayed... Just nothing happens. Do you mean passing the pk in my url? On Monday, March 5, 2012 5:13:14 PM UTC+2, eng.Ilian Iliev wrote: > > Hi, > > first of all use if request.POST, second pehaps you should pass the pk as > part of the action URL. > Do you get any errors or anything? > > > -- > eng. Ilian Iliev > Web Software Developer > > Mobile: +359 88 66 08 400 > Website: http://ilian.i-n-i.org > > > On Mon, Mar 5, 2012 at 4:54 PM, leaks wrote: > >> I don't get an error... Nothing just happens >> >> my view: (I think the problem is here) >> >> def push(request, pk): >> if request.method == 'POST': >> entry = Entry.objects.get(pk=pk) >> entry.pushes +=1 >> entry.save() >> >> My template: >> >> >> {% for entry in entries.object_list %} >> {{ entry.title }} >> Posted on {{ entry.posted }} by {{ entry.submitter }} | pushed {{ >> entry.pushes }} time(s). >> {% if user.is_authenticated %} >> #or maybe here... >> >> {% csrf_token %} >> >> >> >> {% endfor %} >> >> >> This is my first project and i haven't really understood how GET and POST >> request's work with models... >> >> Thanks in advance :) >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/8GXXgG28NcQJ. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/iShERmwDeBgJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with my view or template (DRIVES ME NUTS)
dHey tom... The homepage displays a list of entries posted by users... Each entry has a submit button next to it, I watched many tutorials and i still dont get how those requests work... I made the view as above and the main idea is to add +1 to my "pushes"(my model has a pushes field wich is an integer field). Plus I don't want it to leave the page. That's why i didn't add a render_to_response() I created the form as above, and when i click on the submit button it doesn't do anything at all, well it shows it refreshed the page but it didn't add a +1 neither an error occurs On Monday, March 5, 2012 5:35:29 PM UTC+2, Tom Evans wrote: > > On Mon, Mar 5, 2012 at 3:24 PM, leaks wrote: > > no, no errors get displayed... Just nothing happens. > > Absolutely and literally 'nothing happens'? Really? > > Does the browser submit the form, django receive a request and render > a response? I would definitely class that as 'something' and not > 'nothing'. > > We can only help you if you help us. You need to explain precisely > what happens, and what you expected to happen. Saying 'nothing > happens' is nonsense, and perhaps if you had investigated what was > actually happening, you may have understood why it didn't happen as > you expected, rather than expecting us to magically deduce both things > from the ether. > > Cheers > > Tom > > On Monday, March 5, 2012 5:35:29 PM UTC+2, Tom Evans wrote: > > On Mon, Mar 5, 2012 at 3:24 PM, leaks wrote: > > no, no errors get displayed... Just nothing happens. > > Absolutely and literally 'nothing happens'? Really? > > Does the browser submit the form, django receive a request and render > a response? I would definitely class that as 'something' and not > 'nothing'. > > We can only help you if you help us. You need to explain precisely > what happens, and what you expected to happen. Saying 'nothing > happens' is nonsense, and perhaps if you had investigated what was > actually happening, you may have understood why it didn't happen as > you expected, rather than expecting us to magically deduce both things > from the ether. > > Cheers > > Tom > > On Monday, March 5, 2012 5:35:29 PM UTC+2, Tom Evans wrote: > > On Mon, Mar 5, 2012 at 3:24 PM, leaks wrote: > > no, no errors get displayed... Just nothing happens. > > Absolutely and literally 'nothing happens'? Really? > > Does the browser submit the form, django receive a request and render > a response? I would definitely class that as 'something' and not > 'nothing'. > > We can only help you if you help us. You need to explain precisely > what happens, and what you expected to happen. Saying 'nothing > happens' is nonsense, and perhaps if you had investigated what was > actually happening, you may have understood why it didn't happen as > you expected, rather than expecting us to magically deduce both things > from the ether. > > Cheers > > Tom > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/iFdP8Mr7JXIJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with my view or template (DRIVES ME NUTS)
Tried HttpResponseRedirect('/') and still nothing happens. Thanks On Monday, March 5, 2012 5:52:50 PM UTC+2, ke1g wrote: > > If that's your complete view, you've forgotten to return an HTTPResponse > object. > > Since action='.', it appears that you are using the same view to get > the form and to > post (which is fine), but each case must return a response for the > prowser, presumably > rendered from the same template. The render_to_response() shortcut is > your friend > here. > > Also, while not required, it is usual for a successful post to > actually return a redirect to > a separate success view (helps guard, I believe, against inadvertent > double submits). > > On 3/5/12, Tom Evans wrote: > > On Mon, Mar 5, 2012 at 3:24 PM, leaks wrote: > >> no, no errors get displayed... Just nothing happens. > > > > Absolutely and literally 'nothing happens'? Really? > > > > Does the browser submit the form, django receive a request and render > > a response? I would definitely class that as 'something' and not > > 'nothing'. > > > > We can only help you if you help us. You need to explain precisely > > what happens, and what you expected to happen. Saying 'nothing > > happens' is nonsense, and perhaps if you had investigated what was > > actually happening, you may have understood why it didn't happen as > > you expected, rather than expecting us to magically deduce both things > > from the ether. > > > > Cheers > > > > Tom > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > > http://groups.google.com/group/django-users?hl=en. > > > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/RMceYOkYr3AJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How do you use a link as a post request?
thanks bb6xt..! I couldn't find an answer so I went with a forms POST request... Thank you anyway... Will give it a try :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/G7tDKNn80tUJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.