so i have this method in one model
def total_price(self):
prices = []
items: QuerySet = self.items.filter(cart=self)
for i in items:
prices.append(i.final_price)
return sum(prices)
which works fine but didn't work when i made it a @property
and i can see it in admin page
in another model i have this:
class CartItem(models.Model):
gift_amount = models.PositivSmallIntegerField(default=0)
@property
def gift_amount(self):
if self.quantity >= 70:
return 5
...
which uses @property but works fine
and i can see the results in admin page
but then i have this
class CustomUser(AbstractUser):
...
is_sales = models.BooleanField(default=False)
def sales_id(self):
if self.is_sales:
import secrets
while True:
sales_id = secrets.toke_url(5)
if not CustomUser.objects.filter(sales_id=sales_id).exists():
return sales_id
which doesn't work with or without @property and errors when i try to access it from admin page or django shell