Warning: mkdir(): No space left on device in /var/www/hottg/post.php on line 59

Warning: file_put_contents(aCache/aDaily/2024-05-22/post/pythondaily/--): Failed to open stream: No such file or directory in /var/www/hottg/post.php on line 72
How to set foreign key to str method of a model without making alot of db calls? @Python Daily
TG Telegram Group & Channel
Python Daily | United States America (US)
Create: Update:

How to set foreign key to str method of a model without making alot of db calls?

I'm having two models
class A(models.Model):
name = models.CharField()


class B(models.Model):
model_a = models.ForeignKey(A)

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



This is making alot of db calls. how to fix it?

​

/r/django
https://redd.it/1cglc6y

How to set foreign key to str method of a model without making alot of db calls?

I'm having two models
class A(models.Model):
name = models.CharField()


class B(models.Model):
model_a = models.ForeignKey(A)

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



This is making alot of db calls. how to fix it?

​

/r/django
https://redd.it/1cglc6y


>>Click here to continue<<

Python Daily






Share with your best friend
VIEW MORE

United States America Popular Telegram Group (US)


Fatal error: Uncaught TypeError: shuffle(): Argument #1 ($array) must be of type array, null given in /var/www/hottg/post.php:344 Stack trace: #0 /var/www/hottg/post.php(344): shuffle() #1 /var/www/hottg/route.php(63): include_once('...') #2 {main} thrown in /var/www/hottg/post.php on line 344