You can do that with proxy models which allows you to override and add
methods.
Of course if there is a need to really modify original model it gets tricky.
la 27. heinäk. 2019 klo 10.49 אורי kirjoitti:
> Hi,
>
> I had to change the following lines because tests failed:
>
> class
Hi,
I had to change the following lines because tests failed:
class Friend1(object):
def __str__(self):
return "User {} is friends with {}".format(self.to_user, self.from_user)
class FriendshipRequest1(object):
def __str__(self):
return "Friendship request from user {}
Django users,
I want to override def __str__ of models I'm using, but the models are
maintained by other developers. I think the __str__ is only used by the
admin interface. I found out that I can do something like this:
from django.contrib import admin
from django.contrib.sites.models import
3 matches
Mail list logo