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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:31:00+00:00 2026-06-14T03:31:00+00:00

models.py class MyModel(models.Model): maximum_limit = models.PositiveIntegerField(default=5) Here I set maximum_limit default value is 5.

  • 0

models.py

class MyModel(models.Model):
maximum_limit = models.PositiveIntegerField(default=5)

Here I set maximum_limit default value is 5.

But I want to set a value which is also editable from admin and use here as a default value. (editable default value for model MyModel)

My initial approach is(not working). I want something like this.

class MySettings(models.Model):
mx_limit = models.PositiveIntegerField(default=5)

class MyModel(models.Model):
maximum_limit = models.PositiveIntegerField(default=MySettings.mx_limit)

Please help me

  • 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-14T03:31:01+00:00Added an answer on June 14, 2026 at 3:31 am

    Your approach is wrong, a maximum for a db value should be set with the proper attribute, namely max_value.

    However this would require a schemamigration everytime you want to change it. So what you really should be doing is dynamic form validation where your form checks for a setting (which should probably be saved in your database and not be statically stored in a module like Settings, which would require server restarts).

    There are plenty examples how to make a form validation more dynamically on stackoverflow

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

Sidebar

Related Questions

I have a model which looks like this: class MyModel(models.Model) value = models.DecimalField() date
in a Model I have a CharField with choices: class MyModel(models.Model): THE_CHOICES=( ('val',_(u'Value Description')),
my model looks like this: class MyModel(models.Model): field1 = models.FloatField(default=0) field2 = models.FloatField(default=0) This
I have a Model that looks like: class MyModel(Model): name = models.TextField(blank=True, default='') bio
I created a form class based on a model: class MyModel(models.Model): increasing_field = models.PositiveIntegerField()
I have this code class MyModel(models.Model): date = models.DateTimeField(blank=True, default=datetime.now) in models.py. In view
I have a simple Python/Django class: class myModel(models.Model): date = models.DateTimeField() value = models.IntegerField()
Let the models class: class MyModel(models.Model): name = models.CharField(max_length=200) category = models.CharField(max_length=200) I want
I've built this model which contains a generic foreign key: class MyModel(models.Model): content_type =
Given a Django model likeso: from django.db import models class MyModel(models.Model): textfield = models.TextField()

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.