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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:17:08+00:00 2026-06-15T03:17:08+00:00

My django model needs a field which should have input ,the integers 1 to

  • 0

My django model needs a field which should have input ,the integers 1 to 10.I modelled this as below

class Review(model):
    ...
    rating = models.IntegerField(default=5,help_text='value 1 to 10')

I am providing forms for creating and editing a Review as below

class ReviewForm(ModelForm):    
    class Meta:
        model=Review
    ...

class ReviewEditForm(ModelForm):    
    class Meta:
        model=Review
    ....

What should I do to make sure that user inputs an integer 1 to 10 ..Should I check for this in clean method of forms ? Or is there a better way?

Ideally I want to show the field as a slider which is available in html5 (RangeInput I think),which shows as a slider in chrome and textfield in firefox16.0.2ubuntu.But I don’t know how this can be done without javascript

  • 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-15T03:17:10+00:00Added an answer on June 15, 2026 at 3:17 am

    You could use django validators for the job

    from django.core.validators import *
    
    rating = models.IntegerField(default=5, help_text='value 1 to 10', validators=[MaxValueValidator(10),
                MinValueValidator(1)])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a Django model to have a date field in which the year,
I have a Django model which I need to hold a callable (in this
I have some Django models with a structure similar to this: class Grandparent(models.Model): name
I have a model named Domain which looks like this: class Domain(models.Model): Model for
Previously I had a django model like this class Review(models.Model): reviewdate=models.DateField(default=date.today) description=models.TextField() author=models.ForeignKey(User,null=True) I
If I have a Django model with a FileField e.g., class Probe(models.Model): name =
I have django model which consist of parent child relationship filed I want to
In a django application I have the following model: class Appointment(models.Model): #some other fields
So I have this model Game that has an Awayteam and Hometeam field. Now
I have three functions which I need in every Django Model: def __unicode__(self): return

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.