diff --git a/python-in-edu/resources/migrations/0009_auto_20210516_1108.py b/python-in-edu/resources/migrations/0009_auto_20210516_1108.py new file mode 100644 index 0000000..c13d625 --- /dev/null +++ b/python-in-edu/resources/migrations/0009_auto_20210516_1108.py @@ -0,0 +1,28 @@ +# Generated by Django 3.1.6 on 2021-05-16 18:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('resources', '0008_auto_20210512_1226'), + ] + + operations = [ + migrations.AlterField( + model_name='resource', + name='url1', + field=models.URLField(help_text='You must link at least one resource.'), + ), + migrations.AlterField( + model_name='resource', + name='url2', + field=models.URLField(blank=True, help_text='Optional additional url related to the same resource', null=True), + ), + migrations.AlterField( + model_name='resource', + name='url3', + field=models.URLField(blank=True, help_text='Optional additional url related to the same resource', null=True), + ), + ] diff --git a/python-in-edu/resources/migrations/0010_auto_20210516_1133.py b/python-in-edu/resources/migrations/0010_auto_20210516_1133.py new file mode 100644 index 0000000..0358f30 --- /dev/null +++ b/python-in-edu/resources/migrations/0010_auto_20210516_1133.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1.6 on 2021-05-16 18:33 + +from django.db import migrations + + +def force_url_objects(apps, schema_editor): + Resource = apps.get_model("resources", "Resource") + + Resource.objects.all().update() + + +class Migration(migrations.Migration): + + dependencies = [ + ('resources', '0009_auto_20210516_1108'), + ] + + operations = [ + migrations.RunPython(force_url_objects, reverse_code=migrations.RunPython.noop) + ] diff --git a/python-in-edu/resources/models.py b/python-in-edu/resources/models.py index c08eff0..f270839 100644 --- a/python-in-edu/resources/models.py +++ b/python-in-edu/resources/models.py @@ -42,13 +42,13 @@ def create_user_profile(sender, instance, created, **kwargs): class Resource(models.Model): #Required and optional fields - url1 = models.CharField(max_length=200, help_text="You must link at least one resource.") + url1 = models.URLField(max_length=200, help_text="You must link at least one resource.") url_description1 = models.CharField(max_length=50, blank=True, null=True, help_text="Use this field, if you are including multiple urls") # resource = models.ForeignKey('Resource', on_delete=models.CASCADE, related_name='links') - url2 = models.CharField(max_length=200, blank=True, null=True, help_text="Optional additional url related to the same resource") + url2 = models.URLField(max_length=200, blank=True, null=True, help_text="Optional additional url related to the same resource") url_description2 = models.CharField(max_length=50, blank=True, null=True, help_text="Use this field, if you are including multiple urls") # resource = models.ForeignKey('Resource', on_delete=models.CASCADE, related_name='links') - url3 = models.CharField(max_length=200, blank=True, null=True, help_text="Optional additional url related to the same resource") + url3 = models.URLField(max_length=200, blank=True, null=True, help_text="Optional additional url related to the same resource") url_description3 = models.CharField(max_length=50, blank=True, null=True, help_text="Use this field, if you are including multiple urls") # resource = models.ForeignKey('Resource', on_delete=models.CASCADE, related_name='links')