I set my Django model field budget
but when I try the following...
budget = models.DecimalField(max_digits=5, decimal_places=2)
...only non-numeric characters can be entered (like
abc,#
etc...
This should work.
- I can key in digits in other programs on my computer, but not in my web form budget
field.
- I tried other fields like: models.IntegerField()
or models.PositiveIntegerField()
- I ran npm run dev
, python manage.py makemigrations
, migrate
, runserver
.
Same thing. Digit keys frozen.
Any other ideas? Thanks.
======= UPDATE
from django.db import models
from django.contrib.auth.models import User
class Order(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField(max_length=100, unique=True)
shopping_list = models.CharField(max_length=500, blank=True)
budget = models.DecimalField(max_digits=5, decimal_places=2)
owner = models.ForeignKey(User, related_name="leads", on_delete=models.CASCADE, null=True)
created_at = models.DateTimeField(auto_now_add=True)
======= UPDATE
I tried the code in my REACT frontend web form by Iqbal Hussain... I still get the same. Only characters are accepted in the DecimalField
.
I thought that was a Django backend issue...It could be a REACT-related issue.
======= UPDATE
The inspector shows:
<input class="form-control" type="number" name="integer" value="">
The React code for the budget input is:
...
<div className="form-group">
<label>Budget</label>
<input
className="form-control"
type="number"
name="integer"
onChange={this.onChange}
value={budget}
/>
</div>
...