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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:08:56+00:00 2026-06-03T13:08:56+00:00

I have something like this: forms.py: AVATAR_CHOICES = ((‘1′,’option1’), (‘2′,’option2’), (‘3′,’option3’), (‘4′,’option4’)) class RegistrationForm(forms.Form):

  • 0

I have something like this:

forms.py:

AVATAR_CHOICES = (('1','option1'), ('2','option2'), ('3','option3'), 
('4','option4'))

class RegistrationForm(forms.Form):
    avatar = ChoiceField(widget=RadioSelect, choices=AVATAR_CHOICES)

I’m passing form from my view:

views.py

form = RegistrationForm()
return render_to_response('registration/register.html', {'form': form},
                          context_instance=RequestContext(request))

into a template like this:

registration.html:

{% for radio in form.avatar %}
  <label class="radio">{{ radio.tag }}</label>
{% endfor %}

but I’d like to include images in front of these option fields as a way to let the users choose an avatar. However, I don’t know how to access keys or values from the tuple AVATAR_CHOICES. The main idea is to be able to do something like this:

{% for radio in form.avatar %}
      <label class="radio">{{ radio.tag }}</label>
      <img src="{{ STATIC_URL }}img/avatars/{{ radio.tag.value }}.jpg"/>
{% endfor %}

How can I do this?

Thanks in advance.

  • 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-03T13:08:58+00:00Added an answer on June 3, 2026 at 1:08 pm

    You could try

    {{ radio.choice_value }}{# value of the choice of the current input #}
    {{ radio.choice_label }}{# label of the choice of the current input #}
    {{ radio.choice_index }}{# 0-based index #}
    

    Only choice_label gets documented, but you could safely use it so far.

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

Sidebar

Related Questions

I have something like this in form : class EventForm(ModelForm): reg_due_date = forms.DateTimeField(input_formats=('%d/%m/%Y %H:%M',),
I have something like this set up: class CategoryPage (webapp.RequestHandler): def get(self): ** DO
I have something like this in my Spring Application: public class Book{ public Book(){
I have a model that looks something like this class Post(models.Model): id = models.IntegerField(unique=True,
I have option groups, somethings like this: Choices = (('Group1',(('Option1','Option1'),('Option2','Option2')))) Is there anyway to
I'd like to do something like this in Django: class MyForm(forms.Form): items = Items.objects.all()
i have done something like this: <form action=validate.php method=get> Id :<input type=text name=pID/><br/><br/> Name
I have a simple html form that is structured something like this: <form name=test
I have an ASP.NET MVC form laid out something like this: @using (Html.BeginForm(null, null,
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())

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.