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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:14:04+00:00 2026-05-15T19:14:04+00:00

It’s simple – All I want to do is set who answered the question

  • 0

It’s simple – All I want to do is set who answered the question if the question is answered. Can someone please enlighten me on how to set a form value if the question was answered. I know that I could also set this as an initial value but then I have to selectively determine which records were answered. This seemed simpler but I’m pulling my hair out tryig to figure this out. Can someone help me out.

The model is simple enough

class ProjectQuestion(models.Model):
    question = models.CharField(max_length=255, editable=True)
    answer_type = models.CharField(max_length=50, choices=VALUE_TYPE_CHOICES, editable=True)
    answer = models.CharField(max_length=255, null=True, blank=True)
    answer_comment = models.TextField(blank = True, null = True)
    answered_by = models.ForeignKey(Employee, related_name="answered_by_test", null=True, blank=True)
    answer_date = models.DateTimeField(auto_now = True, null=True)
    objects = models.Manager()


    def __unicode__(self):
        return u'%s' % (self.question)

And the representing view is also simple.

# views.py
if request.method == "POST":
    print request.POST
    print request.user
    formset = QuestionFormSet(data=request.POST, files=request.FILES,
                              queryset=ProjectQuestion.objects.filter(id__lt=shortname))
    print formset.forms
    if formset.is_valid():
        person =  Employee.objects.get(name__iexact = request.user.get_full_name())
        for i in range(0, formset.total_form_count()):
            form = formset.forms[i]
            if form.cleaned_data['answer']:
                # THIS DOESN'T WORK...  PLEASE FIX..
                form.save(commit=False)
                form.answered_by = person
                form.save()
else:
    active_section = ProjectQuestion.objects.filter(id__lt=shortname)
  • 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-15T19:14:04+00:00Added an answer on May 15, 2026 at 7:14 pm

    isn’t it supposed to be

    if form.cleaned_data['answer']:
        # THIS DOESN'T WORK...  PLEASE FIX..
        question = form.save(commit=False)
        question.answered_by = person
        question.save()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into

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.