Issue #18 new

Invalid data in vote form.

Francesco Spegni
created an issue

When I follow this tutorial:

https://django-generic-ratings.readthedocs.org/en/latest/usage_examples.html

for simple rating, using the star form (I've added the lines below in my models.py):

ratings.register(<ModelName>, score_range=(1, 5), form_class=StarVoteForm)

I get the error above, and in the console (using Firebug) I see:

TypeError: objects.rating is not a function

related to the following piece of code added by the star_widget.html template:

var vote_form = objects.closest('form');
objects.rating({
    callback: function(value, link) {
    if (value) {
        vote_form.find('#id_score').val(value);
        vote_form.trigger('star_change', [value]);
    } else {
        vote_form.find('#id_score').val(0);
        vote_form.trigger('star_delete');
    };
}

is objects.rating(...) a lecit method call? where is it defined?

I don't know if it is related to this, but later in your tutorial I can see (on a different example), the following included js/css:

<link href="/path/to/jquery.rating.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/path/to/jquery.MetaData.js"></script>
<script type="text/javascript" src="/path/to/jquery.rating.js"></script>

should I include those files? If yes, where do I find them?

Comments (2)

  1. Francesco Spegni reporter

    update: installing jquery.rating.css / js and jquery.metadata.js plugins I get rid of the "TypeError: objects.rating is not a function", but the original problem "Invalid data in vote form" remains.

    The generated post looks like the following:

    Vote : Vota
    content_type : resources.concept
    csrfmiddlewaretoken : ZMRxoFKEoinCDQLPNmxQsO7xnGFusxea
    honeypot : 
    key : main
    object_pk : 1
    
  2. Paola Coccia

    Your POST data is missing the score...it should look like this:

    csrfmiddlewaretoken:ZMRxoFKEoinCDQLPNmxQsO7xnGFusxea
    score:5.5
    content_type:resources.concept
    object_pk:1
    key:main
    honeypot:
    

    Have you rendered the full rating form?

  3. Log in to comment