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

  • SEARCH
  • Home
  • 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 8919399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:01:02+00:00 2026-06-15T06:01:02+00:00

Note: Solved, solution at the end. I’m trying to pass a request value to

  • 0

Note: Solved, solution at the end.

I’m trying to pass a request value to a form I have to filter a field in a form, but it keeps returning TypeError, and I think the code is ok.

views.py:

class AddProposalSet(FormView):

    """
    Create a new prpoposal set, it can be related to a debate or be in free mode,
    which is not linked to anything. If it's linked to a debate, people can
    make their proposals related to the debate notes.

    .. versionadded: 0.1.5

    :rtype: Form object
    :context: form, get_place
    """
    #form_class = ProposalSetForm
    template_name = 'proposals/proposalset_form.html'

    def get_success_url(self):
        space = self.kwargs['space_url']
        return reverse(urln_space.SPACE_INDEX, kwargs={'space_url':space})

    def get_form_class(self):
        """
        The reason for overriding "form_class" is that we pass here the
        request to the form, that way we can filter the debates based on the
        current space.
        """
        return ProposalSetForm(self.kwargs['space_url'])

    def form_valid(self, form):
        self.space = get_object_or_404(Space, url=self.kwargs['space_url'])
        form_uncommited = form.save(commit=False)
        form_uncommited.space = self.space
        form_uncommited.author = self.request.user
        form_uncommited.save()
        return super(AddProposalSet, self).form_valid(form)

    def get_context_data(self, **kwargs):
        context = super(AddProposalSet, self).get_context_data(**kwargs)
        self.space = get_object_or_404(Space, url=self.kwargs['space_url'])
        context['get_place'] = self.space
        return context

    @method_decorator(permission_required('proposals.add_proposalset'))
    def dispatch(self, *args, **kwargs):
        return super(AddProposalSet, self).dispatch(*args, **kwargs)

forms.py

class ProposalSetForm(ModelForm):

    """
    ProposalSetForm is a basic form autogenerated form from ProposalSet model.
    Returns an empty form to create a new proposal set.

    :rtype: HTML Form

    .. versionadded:: 0.1.5b
    """
    class Meta:
        model = ProposalSet

    def __init__(self, *args, **kwargs):
        super(ProposalSetForm, self).__init__(*args, **kwargs)
        get_place = get_object_or_404(Space, url=args[0])
        if self.instance:
            self.fields['debate'].queryset = Debate.objects.filter(end_date__lte=datetime.date.today(), space=get_place)

The error:

TypeError at /en-gb/spaces/test/proposal/add/set/
'ProposalSetForm' object is not callable

I’m not able to find what can be happening, am I missing something?

SOLUTION:

views.py

class AddProposalSet(FormView):

    """
    Create a new prpoposal set, it can be related to a debate or be in free mode,
    which is not linked to anything. If it's linked to a debate, people can
    make their proposals related to the debate notes.

    .. versionadded: 0.1.5

    :rtype: Form object
    :context: form, get_place
    """
    form_class = ProposalSetForm
    template_name = 'proposals/proposalset_form.html'

    def get_success_url(self):
        space = self.kwargs['space_url']
        return reverse(urln_space.SPACE_INDEX, kwargs={'space_url':space})

    def get_form_kwargs(self, **kwargs):
        kwargs = super(AddProposalSet, self).get_form_kwargs(**kwargs)
        kwargs['initial']['space'] = self.kwargs['space_url']
        return kwargs

    def form_valid(self, form):
        self.space = get_object_or_404(Space, url=self.kwargs['space_url'])
        form_uncommited = form.save(commit=False)
        form_uncommited.space = self.space
        form_uncommited.author = self.request.user
        form_uncommited.save()
        return super(AddProposalSet, self).form_valid(form)

    def get_context_data(self, **kwargs):
        context = super(AddProposalSet, self).get_context_data(**kwargs)
        self.space = get_object_or_404(Space, url=self.kwargs['space_url'])
        context['get_place'] = self.space
        return context

    @method_decorator(permission_required('proposals.add_proposalset'))
    def dispatch(self, *args, **kwargs):
        return super(AddProposalSet, self).dispatch(*args, **kwargs)

forms.py

class ProposalSetForm(ModelForm):

    """
    ProposalSetForm is a basic form autogenerated form from ProposalSet model.
    Returns an empty form to create a new proposal set.

    :rtype: HTML Form

    .. versionadded:: 0.1.5b
    """
    class Meta:
        model = ProposalSet

    def __init__(self, *args, **kwargs):
        super(ProposalSetForm, self).__init__(*args, **kwargs)
        get_place = get_object_or_404(Space, url=kwargs['initial']['space'])
        if self.instance:
            self.fields['debate'].queryset = Debate.objects.filter(end_date__lte=datetime.date.today(), space=get_place)
            print self.fields['debate']
  • 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-06-15T06:01:03+00:00Added an answer on June 15, 2026 at 6:01 am

    The get_form_class() method, should return the class not object/instance of the form class. So your method can be updated to

    def get_form_class(self):
        return ProposalSetForm
    

    However, I’m not sure how will this pass parameters that you need to __init__() of the class.

    May be you can define get_form() rather than get_form_class() and return appropriate form instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: I have solved the majority of this problem but have run into a
Simple problem, I have it solved .. but python has a million ways to
NOTE : My specific problem is solved (explained at the bottom), but I'll leave
Note -- Solved This is the function which is setting the center in my
I have such a basic problem in Delphi,I can't solve it. My Code: Note:DataR
NOTE: This is a followup to my question here. I have a program that
There must be a simple solution to this, but after 4 hours of browsing
I have a solution in VS2010 with 3 projects: WCFServiceLib - a project created
Note: Solved. It turned out that I was importing a previous version of the
I'm trying to add commas to floats for display to end users of my

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.