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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:16:19+00:00 2026-05-28T03:16:19+00:00

I have a problem with django and forms. In forms.py I have sth like

  • 0

I have a problem with django and forms.

In forms.py I have sth like this:

class MyForm(forms.Form):

def __init__(self, *args, **kwargs):
    self.answers = kwargs.pop('answers')
    super(AnswersForm, self).__init__(*args, **kwargs)

    choices = ["aaaa", "ssssssssss", "ddddddddd"]
    self.fields['answers'] = forms.ChoiceField(choices = choices, widget=forms.RadioSelect())

And when i use it in template, I have sth like this:

Answers:

- a
- s
- d

Do you know why I haven’t got all words, but only one letter of the word?

  • 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-28T03:16:20+00:00Added an answer on May 28, 2026 at 3:16 am

    choices should be a list (or other iterable) of two-tuples. The first entry in each tuple is the value that gets stored in the database. The second is the human-readable name.
    See the documentation on choices for more information.

    Thus, your choices list should look more like this:

    choices = [("a","aaaa"), ("s", "ssssssssss"), ("d", "ddddddddd")]
    

    As posted, your code is considering each string (aaaa, ssssssss, etc.) to be tuple-like and grabbing the first letter of each for the database representation, and the second letter of each for the human-readable name (used for the label).

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

Sidebar

Related Questions

Weird problem in Django with forms : I have a Form.class defined like this
When I define a Django form class similar to this: def class MyForm(forms.Form): check
I have a django model and model form that look like this: -models.py class
I have a problem in customizing labels in a Django form This is the
I have a simple Django form: class CommentForm(forms.Form): comment = forms.CharField(max_length=2000, required=True) post_id =
Am using django forms on my app. I have a model Client like this:
I have a pretty simple file upload form class in django: class UploadFileForm(forms.Form): category
My problem is similar to Django Passing Custom Form Parameters to Formset Ive have
Summary: u = self.instance.user in def save(self, *args, **kwargs): u = self.instance.user u.first_name =
I have this form in a Django application In Firefox it works as charm,

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.