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 552943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:33:11+00:00 2026-05-13T11:33:11+00:00

I have customized one of my forms and now it does not pass the

  • 0

I have customized one of my forms and now it does not pass the is_valid() test. No form.errors are visible. Any ideas for where I went wrong?

Form:

class SearchForm(forms.Form):
    param = forms.CharField(required=False, max_length = 500, label = 'Search for')
    sets = forms.ModelMultipleChoiceField(queryset=Set.objects.all())    
    onlyDiffer = forms.BooleanField(required=False, label = 'Display varying only') 

    def __init__(self, userN = False, *args, **kwargs):
        super(SearchForm,self).__init__(*args,**kwargs)
        self.userN = userN
        self.fields['sets'].queryset=Set.objects.filter(Q(owner = None) | Q(owner=self.userN))

View:

def search(request):
    template = 'search.html'
    if request.method == 'POST':
        form = SearchForm(request.POST)
        if form.is_valid():
           (..do search..)
        else:
           return direct_to_template(request, template, {'form' : SearchForm(), 'errors' : form.errors})
    else:
        usr = request.user
        form = SearchForm(usr)
        return direct_to_template(request, template, { 'form': form })

Thank you!

  • 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-13T11:33:12+00:00Added an answer on May 13, 2026 at 11:33 am

    gruzczy has the right idea, but a better way to do it is to avoid changing the function signature of __init__ in the first place.

    def __init__(self, *args, **kwargs):
        self.userN = kwargs.pop('userN', None)
        super(SearchForm,self).__init__(*args,**kwargs)
        ...etc...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does any one have tried to customize default section index displayed in UITableView. I
I have a client who has one webpage with customized routes added in global.asax
In my magento project the search result not displays. I have customized my magento.
I have a form in struts 1.3 which is dynamically generated one and having
I have a form, one of the fields is a select field, with 5
I have two user controls (ascx); one contains some forms, and the other one
I have a form (edited for brevity) as follows: class InteractionForm(forms.Form): def __init__(self, *args,
I have customized the look and field of my form's select field with the
I have customized one banner and one drop down menu. On mouse over the
I have a subclass of NSWindow to customize one of my windows for 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.