Commit a978a7ed by Ahsan Ulhaq Committed by Ahsan Ul Haq

Fix migration issue

Fixed 'Course' object has no attribute 'history' issue in the migration
parent 394c6ad8
...@@ -8,11 +8,13 @@ from django.db import migrations, models ...@@ -8,11 +8,13 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
def add_created_modified_date(apps, schema_editor): def add_created_modified_date(apps, schema_editor):
Course = apps.get_model('courses', 'Course') Course = apps.get_model('courses', 'Course')
HistoricalCourse = apps.get_model('courses', 'historicalcourse')
courses = Course.objects.all() courses = Course.objects.all()
for course in courses: for course in courses:
course.created = course.history.earliest().history_date history = HistoricalCourse.objects.filter(id=course.id)
course.modified = course.history.latest().history_date course.created = history.earliest().history_date
course.modified = history.latest().history_date
course.save() course.save()
dependencies = [ dependencies = [
......
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