> It runs OK (no errors) but doesn't save a single thing
     It has to run without errors because you have enclosed the whole thing
in try.

     You have to coerce the record_id and user_id into int before assigning
to the model fields, for it to save.

On Tue, Jul 14, 2009 at 9:45 PM, The Danny Bos <danny...@gmail.com> wrote:

>
> Heya, am trying to simply save 3 values to a database, without using
> Forms.
>
> In the Template:
>
> <form action="rating/" method="post">
>        <input type="hidden" name="record_id" value="1" />
>        <input type="hidden" name="user_id" value="2" />
>        Rate This: <select name="rating">{% for n in numbers %}<option
> value="{{ n }}">{{ n }}</option>{% endfor %}</select>
>        <input type="submit" value="Rate" />
> </form>
>
> In the View:
>
> from mysite.rating.models import Rating
> def critics_rating(request):
>        try:
>                record_id = request.POST['record_id']
>                user_id = request.POST['user_id']
>                rating_val = request.POST['rating']
>
>                rating = Rating()
>                rating.rating = rating_val
>                rating.item = record_id
>                rating.writer = user_id
>                rating.save()
>
>                return HttpResponseRedirect('/')
>        except:
>                pass
>        obj = Record.objects.get(id=record)
>        return render_to_response('record/detail.html', {'object_detail':
> obj}, context_instance=RequestContext(request))
>
> It runs OK (no errors) but doesn't save a single thing, also it goes
> back to the 'detail.html' page fine, but when you hit reload, it sends
> the data again. Again, not saving.
>
> Any ideas what's wrong with this?
> I've done a lot of searching but all people seem to use the Forms
> widget, I was thinking as this is only three fields I'd skip that.
> Silly?
> >
>


-- 
Regards,
Lakshman
becomingguru.com
lakshmanprasad.com

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to