Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Make URLs nullable to allow non-file media like audio-sets

Dhruv Bhanushalib28ac349c4ca
diff --git a/openverse_api/catalog/api/migrations/0040_nullable_urls.py b/openverse_api/catalog/api/migrations/0040_nullable_urls.py
new file mode 100644
index 000000000..d884ea818
--- /dev/null
+++ b/openverse_api/catalog/api/migrations/0040_nullable_urls.py
@@ -0,0 +1,28 @@
+# Generated by Django 3.2.7 on 2021-10-11 15:52
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('api', '0039_audio_set_thumbs'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='audio',
+ name='url',
+ field=models.URLField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
+ ),
+ migrations.AlterField(
+ model_name='audioset',
+ name='url',
+ field=models.URLField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
+ ),
+ migrations.AlterField(
+ model_name='image',
+ name='url',
+ field=models.URLField(blank=True, help_text='The actual URL to the media file.', max_length=1000, null=True, unique=True),
+ ),
+ ]
diff --git a/openverse_api/catalog/api/models/mixins.py b/openverse_api/catalog/api/models/mixins.py
index 047f6c30f..5607bcbb3 100644
--- a/openverse_api/catalog/api/models/mixins.py
+++ b/openverse_api/catalog/api/models/mixins.py
@@ -69,7 +69,11 @@ class FileMixin(models.Model):
"""
url = models.URLField(
- unique=True, max_length=1000, help_text="The actual URL to the media file."
+ unique=True,
+ max_length=1000,
+ help_text="The actual URL to the media file.",
+ blank=True,
+ null=True,
)
filesize = models.IntegerField(
blank=True,