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

  • Home
  • SEARCH
  • 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 8878399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:42:09+00:00 2026-06-14T19:42:09+00:00

I have a simple model form: class ProductSelectionForm(ModelForm): class Meta: model = Product and

  • 0

I have a simple model form:

 class ProductSelectionForm(ModelForm):
     class Meta:
         model = Product

and the model:

class Product(models.Model):
     name = models.CharField(max_length=155)

     def __unicode__(self):
         return self.name

But if I render the form using the {{ form.as_p }} tag it just renders the form as a single text input. How can I get the form to render as radio select options, with the name as the option label and the pk as the value? I have tried using widget but no joy.

Any help much appreciated.

  • 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-14T19:42:11+00:00Added an answer on June 14, 2026 at 7:42 pm

    You don’t want a modelform for that. They’re for creating and editing model instances. Instead, what you seem to want is a form to choose existing instances: for that, use a normal form with a ModelChoiceField:

    class ProductSelectionForm(forms.Form):
        choice = forms.ModelChoiceField(queryset=Product.objects.all(), 
                                        widget=forms.RadioSelect)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple model like this one: class Artist(models.Model): surname = models.CharField(max_length=200) name
I have this simple Post model: class Post(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True)
I have a simple Book Author relationship class Author(models.Model): first_name = models.CharField(max_length=125) last_name =
I've created a simple model class Person(models.Model): name = models.CharField(max_length=25) surname = models.CharField(max_length=25) birth_date
Background : I have a simple model form with a image field. class XYZForm(ModelForm):
I have a simple model that is defined as: class Article(models.Model): slug = models.SlugField(max_length=50,
I have a simple model namespace StackOverflow.Models { public class Test { public Test()
This is my model: class News(models.Model): title = models.CharField(max_length=250) text = models.TextField() pub_date =
I have a simple question. This is my profile: class Profile(models.Model): user = models.ForeignKey(User,
I have 2 simple models; a JobInfo model and a Contact model. class JobInfo(models.Model):

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.