Skip to content

Commit

Permalink
Make discount URL field non-nullable
Browse files Browse the repository at this point in the history
This changes the field to be in line with Django recommendations:

> Avoid using null on string-based fields such as `CharField` and
> `TextField.` If a string-based field has `null=True`, that means it
> has two possible values for "no data": `NULL`, and the empty string.
> In most cases, it's redundant to have two possible values for "no
> data;" the Django convention is to use the empty string, not `NULL`.

https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models.Field.null

Three more fields on `Trip` have a large number of records with `null`
-- I'd need to address those before I can turn on linting for DJ001.
  • Loading branch information
DavidCain committed Jun 18, 2023
1 parent a4a24ba commit 20d863e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions ws/migrations/0055_discount_url_non_null.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.19 on 2023-06-18 16:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('ws', '0054_allow_null_reminder_sent_at'),
]

operations = [
migrations.AlterField(
model_name='discount',
name='url',
field=models.URLField(blank=True, default=''),
preserve_default=False,
),
]
2 changes: 1 addition & 1 deletion ws/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Discount(models.Model):
name = models.CharField(max_length=255)
summary = models.CharField(max_length=255)
terms = models.TextField(max_length=4095)
url = models.URLField(null=True, blank=True)
url = models.URLField(blank=True)
ga_key = models.CharField(
max_length=63,
# If blank, then we don't actually report this information to a spreadsheet
Expand Down

0 comments on commit 20d863e

Please sign in to comment.