from django.db import models

class Activity(models.Model):
    group = models.CharField(max_length=4)
    grouptype = models.TextField()
    groupdetail = models.TextField()
    details = models.TextField()
    disabled = models.BooleanField()
    time = models.DecimalField(decimal_places=2, max_digits=10)
    unique_together = (("group", "grouptype", "disabled", "time"),)

class ActivityEntry(models.Model):
    from timetracker.tracker.models import Tbluser
    user = models.ManyToManyField(
        Tbluser,
        related_name="user_foreign"
    )
    activity = models.ManyToManyField(
        Activity,
        related_name="activity_foreign"
    )
    amount = models.BigIntegerField()

    def time(self):
        return self.activity.time * self.amount

from django.db import models

class Activity(models.Model):
    group = models.CharField(max_length=4)
    grouptype = models.TextField()
    groupdetail = models.TextField()
    details = models.TextField()
    disabled = models.BooleanField()
    time = models.DecimalField(decimal_places=2, max_digits=10)
    unique_together = (("group", "grouptype", "disabled", "time"),)

class ActivityEntry(models.Model):
    user = models.ManyToManyField(
        'tracker.Tbluser',
        related_name="user_foreign"
    )
    activity = models.ManyToManyField(
        Activity,
        related_name="activity_foreign"
    )
    amount = models.BigIntegerField()

    def time(self):
        return self.activity.time * self.amount

Use the app string version of foreign keying. It prevents a circular import.
Use the app string version of foreign keying. It prevents a circular import.

  from django.db import models
  
  class Activity(models.Model):
      group = models.CharField(max_length=4)
      grouptype = models.TextField()
      groupdetail = models.TextField()
      details = models.TextField()
      disabled = models.BooleanField()
      time = models.DecimalField(decimal_places=2, max_digits=10)
      unique_together = (("group", "grouptype", "disabled", "time"),)
  
  class ActivityEntry(models.Model):
-     from timetracker.tracker.models import Tbluser
      user = models.ManyToManyField(
-         Tbluser,
+         'tracker.Tbluser',
          related_name="user_foreign"
      )
      activity = models.ManyToManyField(
          Activity,
          related_name="activity_foreign"
      )
      amount = models.BigIntegerField()
  
      def time(self):
          return self.activity.time * self.amount
  
Use the app string version of foreign keying. It prevents a circular import.
## Code Before:
from django.db import models

class Activity(models.Model):
    group = models.CharField(max_length=4)
    grouptype = models.TextField()
    groupdetail = models.TextField()
    details = models.TextField()
    disabled = models.BooleanField()
    time = models.DecimalField(decimal_places=2, max_digits=10)
    unique_together = (("group", "grouptype", "disabled", "time"),)

class ActivityEntry(models.Model):
    from timetracker.tracker.models import Tbluser
    user = models.ManyToManyField(
        Tbluser,
        related_name="user_foreign"
    )
    activity = models.ManyToManyField(
        Activity,
        related_name="activity_foreign"
    )
    amount = models.BigIntegerField()

    def time(self):
        return self.activity.time * self.amount

## Instruction:
Use the app string version of foreign keying. It prevents a circular import.
## Code After:
from django.db import models

class Activity(models.Model):
    group = models.CharField(max_length=4)
    grouptype = models.TextField()
    groupdetail = models.TextField()
    details = models.TextField()
    disabled = models.BooleanField()
    time = models.DecimalField(decimal_places=2, max_digits=10)
    unique_together = (("group", "grouptype", "disabled", "time"),)

class ActivityEntry(models.Model):
    user = models.ManyToManyField(
        'tracker.Tbluser',
        related_name="user_foreign"
    )
    activity = models.ManyToManyField(
        Activity,
        related_name="activity_foreign"
    )
    amount = models.BigIntegerField()

    def time(self):
        return self.activity.time * self.amount
