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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:48:15+00:00 2026-05-25T11:48:15+00:00

I have a choiceField called from a context_processors so it can appear in all

  • 0

I have a choiceField called from a context_processors so it can appear in all of my site’s pages. It provides the projects existing in a database. The problem is that it does not refresh correctly.
I deleted some records in my database and they still are in my selection. Also I’d like it to refresh automatically when a user creates a new project.

Here is my form and how I call it. If anyone has a suggestion, it would be appreciated.

forms.py:

class SelectForm(forms.Form):

        def __init__(self, *args, **kwargs):
                super(SelectForm, self).__init__(*args, **kwargs)
                self.fields['project'].initial=[(p.proj_id, p.proj_name+"_"+p.proj_description) for p in Project.getProjectParent(Project())]


        project_choices = [(p.proj_id, p.proj_name+"_"+p.proj_description) for p in Project.getProjectParent(Project())]

        project = forms.ChoiceField(project_choices)

        def save(self):
                project = self.cleaned_data['project']
                src = ''
                p = {'proj': project, 'src': src}
                return p

context_processors.py :

def display_select_proj(request):
        if request.method == "POST" and (request.POST.get("action", "") == "Change"):
                form = SelectForm(request.POST)
                if form.is_valid():
                        p = form.save()
                        proj = p['proj']
                        src = p['src']

                        request.session['proj'] = proj

        else:
                proj = request.session['proj']
                src = ""
                form = SelectForm(initial={'project': proj})

        return {'select_form': form, 'proj': proj, 'src': src}
  • 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-25T11:48:16+00:00Added an answer on May 25, 2026 at 11:48 am

    for the first part move project_choices inside init so it is generated as the form is called, it will then update on refresh.

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

Sidebar

Related Questions

I have a simple form where users can select a department from a choicefield.
I have a ChoiceField in a bound form, whose choices are: [('all', 'All users'),
Have just started using Google Chrome , and noticed in parts of our site,
Have you refactored from an ActiveRecord to a DataMapper pattern? What conditions prompted the
I have got a choiceField in my form, where I display filtered data. To
I have a field in my form myFormList = [(u'Select',u'Select')] myForm = forms.ChoiceField(choices=myFormList) and
Here i have the form vote = forms.ChoiceField(widget=forms.Select(), choices=(('1', '1',), ('2', '2',), ('3', '3',)),
I have a ChoiceField in my form class, presumably a list of users. How
I am trying to have a choicefield that only displays the users with the
I have several strings in my site that don't belong to any app, for

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.