Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces URL Char fields with URL fields and updates all objects. #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions python-in-edu/resources/migrations/0009_auto_20210516_1108.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
20 changes: 20 additions & 0 deletions python-in-edu/resources/migrations/0010_auto_20210516_1133.py
Original file line number Diff line number Diff line change
@@ -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)
]
6 changes: 3 additions & 3 deletions python-in-edu/resources/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down