from django.utils import timezone
from django.db import models

from users.models import Course, BaseModel, User


class Pledge(BaseModel):
    user = models.ForeignKey(User)
    course = models.ForeignKey(Course)
    money = models.DecimalField(max_digits=8, decimal_places=2)
    pledge_date = models.DateTimeField('date pledged', default=timezone.now())
    complete_date = models.DateTimeField('date completed', null=True)
    is_active = models.BooleanField(default=True)
    is_complete = models.BooleanField(default=False)


class Follower(BaseModel):
    pledge = models.ForeignKey(Pledge)
    email = models.EmailField(default='', blank=True)
from django.utils import timezone
from django.db import models

from users.models import Course, BaseModel, UserProfile


class Pledge(BaseModel):
    user = models.ForeignKey(UserProfile)
    course = models.ForeignKey(Course)
    money = models.DecimalField(max_digits=8, decimal_places=2)
    pledge_date = models.DateTimeField('date pledged', default=timezone.now())
    complete_date = models.DateTimeField('date completed', null=True)
    is_active = models.BooleanField(default=True)
    is_complete = models.BooleanField(default=False)


class Follower(BaseModel):
    pledge = models.ForeignKey(Pledge)
    email = models.EmailField(default='', blank=True)
Make pledge foreignkey to userprofile
Make pledge foreignkey to userprofile

  from django.utils import timezone
  from django.db import models
  
- from users.models import Course, BaseModel, User
+ from users.models import Course, BaseModel, UserProfile
  
  
  class Pledge(BaseModel):
-     user = models.ForeignKey(User)
+     user = models.ForeignKey(UserProfile)
      course = models.ForeignKey(Course)
      money = models.DecimalField(max_digits=8, decimal_places=2)
      pledge_date = models.DateTimeField('date pledged', default=timezone.now())
      complete_date = models.DateTimeField('date completed', null=True)
      is_active = models.BooleanField(default=True)
      is_complete = models.BooleanField(default=False)
  
  
  class Follower(BaseModel):
      pledge = models.ForeignKey(Pledge)
      email = models.EmailField(default='', blank=True)
Make pledge foreignkey to userprofile
## Code Before:
from django.utils import timezone
from django.db import models

from users.models import Course, BaseModel, User


class Pledge(BaseModel):
    user = models.ForeignKey(User)
    course = models.ForeignKey(Course)
    money = models.DecimalField(max_digits=8, decimal_places=2)
    pledge_date = models.DateTimeField('date pledged', default=timezone.now())
    complete_date = models.DateTimeField('date completed', null=True)
    is_active = models.BooleanField(default=True)
    is_complete = models.BooleanField(default=False)


class Follower(BaseModel):
    pledge = models.ForeignKey(Pledge)
    email = models.EmailField(default='', blank=True)
## Instruction:
Make pledge foreignkey to userprofile
## Code After:
from django.utils import timezone
from django.db import models

from users.models import Course, BaseModel, UserProfile


class Pledge(BaseModel):
    user = models.ForeignKey(UserProfile)
    course = models.ForeignKey(Course)
    money = models.DecimalField(max_digits=8, decimal_places=2)
    pledge_date = models.DateTimeField('date pledged', default=timezone.now())
    complete_date = models.DateTimeField('date completed', null=True)
    is_active = models.BooleanField(default=True)
    is_complete = models.BooleanField(default=False)


class Follower(BaseModel):
    pledge = models.ForeignKey(Pledge)
    email = models.EmailField(default='', blank=True)