Change WidgetUser id_num from integer to string of integers

parent 228cb14e
# Generated by Django 4.0.3 on 2022-04-02 10:10
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('homepage', '0004_widgetuser_department'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='id_num',
field=models.CharField(max_length=7, validators=[django.core.validators.RegexValidator('^\\d+$')]),
),
]
from django.core.validators import MaxValueValidator from django.core.validators import RegexValidator
from django.db import models from django.db import models
...@@ -14,9 +14,10 @@ class WidgetUser(models.Model): ...@@ -14,9 +14,10 @@ class WidgetUser(models.Model):
first_name = models.CharField(max_length=50) first_name = models.CharField(max_length=50)
middle_name = models.CharField(max_length=50) middle_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50)
id_num = models.PositiveIntegerField(validators=[MaxValueValidator(9999999)]) # check if id_num string contains digits only
email = models.EmailField(max_length = 200) id_num = models.CharField(max_length=7, validators=[RegexValidator(r'^\d+$')])
email = models.EmailField(max_length=200)
department = models.ForeignKey(Department, on_delete=models.CASCADE, null=True) department = models.ForeignKey(Department, on_delete=models.CASCADE, null=True)
def __str__(self): def __str__(self):
return self.email return self.id_num
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment