from django.db import models
from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver
from django.conf import settings

from competition.models import Team

import json


class TeamStats(models.Model):
    team = models.OneToOneField(Team)
    data_field = models.TextField(null=True, default="null")


    @property
    def data(self):
        return json.loads(self.data_field)

    @data.setter
    def data(self, value):
        self.data_field = json.dumps(value)

from django.db import models
from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver
from django.conf import settings

from competition.models import Team

import json


class TeamStats(models.Model):
    team = models.OneToOneField(Team)
    data_field = models.TextField(null=True, default="null")

    def __str__(self):
        return self.team.name

    @property
    def data(self):
        return json.loads(self.data_field)

    @data.setter
    def data(self, value):
        self.data_field = json.dumps(value)

Add str method to TeamStats
Add str method to TeamStats

  from django.db import models
  from django.db.models.signals import pre_save, post_save
  from django.dispatch import receiver
  from django.conf import settings
  
  from competition.models import Team
  
  import json
  
  
  class TeamStats(models.Model):
      team = models.OneToOneField(Team)
      data_field = models.TextField(null=True, default="null")
  
+     def __str__(self):
+         return self.team.name
  
      @property
      def data(self):
          return json.loads(self.data_field)
  
      @data.setter
      def data(self, value):
          self.data_field = json.dumps(value)
  
Add str method to TeamStats
## Code Before:
from django.db import models
from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver
from django.conf import settings

from competition.models import Team

import json


class TeamStats(models.Model):
    team = models.OneToOneField(Team)
    data_field = models.TextField(null=True, default="null")


    @property
    def data(self):
        return json.loads(self.data_field)

    @data.setter
    def data(self, value):
        self.data_field = json.dumps(value)

## Instruction:
Add str method to TeamStats
## Code After:
from django.db import models
from django.db.models.signals import pre_save, post_save
from django.dispatch import receiver
from django.conf import settings

from competition.models import Team

import json


class TeamStats(models.Model):
    team = models.OneToOneField(Team)
    data_field = models.TextField(null=True, default="null")

    def __str__(self):
        return self.team.name

    @property
    def data(self):
        return json.loads(self.data_field)

    @data.setter
    def data(self, value):
        self.data_field = json.dumps(value)
