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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:24:04+00:00 2026-06-16T00:24:04+00:00

I have a form like so: class ProjectInfoForm(forms.Form): module = forms.ModelChoiceField( queryset=Module.objects.all().order_by(‘name’), ) …

  • 0

I have a form like so:

class ProjectInfoForm(forms.Form):
    module = forms.ModelChoiceField(
        queryset=Module.objects.all().order_by('name'),
    )
    ...

And in my template I have some jQuery which I want to use for selecting an option form the module dropdown:

  $('#id_module').append('<option value="foo" selected="selected">Foo</option>');

However, this actually removes all the original options, which I want to be still available. So I want to select FOO but have the other options available in the drop down below FOO.

  • 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-16T00:24:04+00:00Added an answer on June 16, 2026 at 12:24 am

    If you want to select an existing option you can use the following:

    $('#id_module').find('option[value="foo"]').attr('selected', true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form: class ProjectInfoForm(forms.Form): module = forms.ModelChoiceField( queryset=Module.objects.all(), ) piece = forms.ModelChoiceField(
I have a form like so: class ThingSelectionForm(forms.Form): things = forms.ModelChoiceField( queryset=Product.objects.filter(product=my_product), widget=forms.RadioSelect, empty_label=None,
I have a form that looks like this: class SampleForm(forms.Form): text = forms.CharField(max_length=100) In
I have a form like: #forms.py from django import forms class MyForm(forms.Form): title =
I have form like this: <div class=satu> <input type='text' size='1' maxlength='1' name='score[1][]' id='score[1][]'> </div>
I have a form which is like: class Address_info_updateForm(forms.Form): street = forms.CharField(label=_(Street), required=True) street2
I have a form class that looks like this: class ApplicationDetailsForm(ModelForm): worked_in_industry = forms.TypedChoiceField(coerce=int,
I have a form looking like this: class MarketingActionForm(forms.ModelForm): contact = ManyToManyByLetter(Contact, field_name=first_name) #contact
I have a form like the one below: class ConsentFormTpl(forms.Form): title = forms.CharField() message
I have a form like this: class MyForm(forms.Form): [...] which is rendered in 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.