Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5843247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:07:41+00:00 2026-05-22T12:07:41+00:00

I reaaaally don´t know what else to do but come here and ask you

  • 0

I reaaaally don´t know what else to do but come here and ask you guys. Heres the situation:

models.py

class Vote(models.Model):
    """ Generic vote model """

    user = models.ForeignKey(User)  
    question = models.ForeignKey(Question)
    created = models.DateTimeField(auto_now_add=True)

    objects = models.Manager()
    cache = CacheVoteManager()

    class Meta:
        abstract = True

    def __unicode__(self):
        return '%s : %s' % (self.user.username, self.question.question)

 class OptionVote(Vote):
    option = models.ForeignKey(Option)

forms.py

  class OptionChoiceField(forms.ModelChoiceField):
  """ Custom model choice field for options """
  widget = forms.RadioSelect(attrs={'class': 'c-opt'})
  def label_from_instance(self, obj):   
      return mark_safe(
          '<span class="c-opt-img">%s</span><span class="c-opt-name">%s</span>'
          % (obj.media_content.draw_create_widget() , obj.name))

 class OptionVoteForm(ModelForm):
     """ Form to vote in a option-based question """
     option = OptionChoiceField(queryset=OptionVote.objects.none(), 
                            empty_label=None)
     class Meta:
         model = OptionVote
         exclude = ['user', 'question']
     def __init__(self, options=None, *args, **kwargs):
         super(OptionVoteForm, self).__init__(*args, **kwargs)
         if options:
             self.fields['option'].queryset = options

views.py

form = OptionVoteForm(request.POST)
form.is_valid()
>> FALSE!!!!!!!!!!!!!!!

I have tried to see the errors in the form and there seems to be no one. I have put some flags on the form’s clean method, and they don´t get called. Sames goes for clean method in OptionChoiceField.

The following code in the view

print 'PRINTING ERRORS: ' + str(form.errors)
    for field in form:
        print str(field.label_tag()) + ': ' + str(field.errors)

returns:

 PRINTING ERRORS: 
 <label for="id_option_0">Option</label>: 

please help me out here, i´m reaaally stuck in this one.

EDIT
when i try to do

form = OptionVoteForm(request.POST)
print form

i get the following error:

Exception Type: AttributeError
Exception Value: 'QueryDict' object has no attribute 'all'
ExceptionLocation: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/forms/models.py in __iter__, line 882

oh, and btw, I´m using django 1.3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:07:42+00:00Added an answer on May 22, 2026 at 12:07 pm

    You’re overriding the default constuctor so it accepts an queryset, so you should do:

    qs = OptionVote.objects.all()
    form = OptionVoteForm(qs, request.POST)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might sound like a reaaaally dumb question but... why do browsers have a
I'm reaaallly new at JSON, but here's what I got. I needed to create
So I have this reaaaally long method that I want to test. I could
i would like to know how to implement push notifications. I know that i
This has really been a hassle, but I have two sprites, both of them
I've written some really nice, funky libraries for use in LinqToSql. (Some day when
Well, I got an object called Mamamia and inside of it has some string
I am learning drupal and am trying to add some extra features to a
I am trying to wrap some words with HTML tags, for that I am
I am developing a framework, and some of the objects have reaaally long names.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.