context = {
...
"stars": 5,
"rating": 3,
...
}
def __str__(self):
return self.ingredient.name
def process_exception(self, request, exception: Exception):
import traceback
error_msg = response_for_exception(request, exception).content.decode('utf-8')
log({ 'error_msg': error_msg, "traceback": traceback.format_exc() })
try:
# Тут типо где ждем ошибку:
except Lalal:
import traceback
trace = traceback.format_exc()
error_handler.process_exception(request, exception: Exception, trace):
from django.db import models
class PortfolioManager(models.Manager):
def get_portfolio(self):
return self.get_queryset.filter(name='123')
class Portfolio(models.Model):
client = models.ForeignKey(Client, on_delete=models.CASCADE, related_name='portfolio')
name = models.CharField('название', max_length=255)
objects = PortfolioManager()
Portfolio.objects.get_portfolio()