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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:22:29+00:00 2026-05-27T07:22:29+00:00

In my Django template, I am using the list of objects in a drop

  • 0

In my Django template, I am using the list of objects in a drop down menu. I am processing it based on the selection.

The HTML Template:

<select id="org" name="org_list" onChange="redirectUrl()">
  <option  value="" selected="selected">---SELECT---</option>
  {% for org in organisation %}
   <option value="{{org.id}}">{{org.name|capfirst}}</option>
  {% endfor %}
</select>

The problem is that when I am selecting the value from the drop down menu, I am getting the contents which belong to the selection. Since the attribute selected=”selected” which only fixes to the “—SELECT—“ element, unless I put the selected=”selected” in

<option value="{{org.id}}" selected="selected">{{org.name|capfirst}}</option>

In these organisation, the last iterated element is only being fixed with drop down. But I want the selected element to be displayed in the drop down menu.

How can I solve this issue?

  • 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-27T07:22:30+00:00Added an answer on May 27, 2026 at 7:22 am

    You’ll want to pass the currently selected org into the view, maybe as current_org so that when you’re iterating through the orgs you can compare with the current one to determine whether or not to select it, like:

    {% for org in organisation %}
       <option value="{{org.id}}"
           {% if org == current_org %}selected="selected"{% endif %}>
           {{org.name|capfirst}}
       </option>
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Context: HTML widgets generated using a Django ModelForm and template, jQuery 1.3.2, JavaScript on
I am using django-pagination to paginate the a list of objects in my temlate.
Supose this portion of a Django template. regs is a list of Reg objects.
I'm using the regroup tag in a Django template to list a number of
I'm using django-favorites to pull the list of objects faved by a user. The
I am sending list to a template using render_to_response. I am using django shortcuts.
When I render a page using the Django template renderer, I can pass in
In my django application I am using a template to construct email body, one
I'm using Django Paginator everywhere on my website and even wrote a special template
This is using the web app framework, not Django. The following template code is

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.