3👍
It looks like this might work for the __getattr__
:
def __getattr__(self, key):
if key not in ('original', '_ original_cache'):
return getattr(self.original, key)
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, key))
1👍
What about making CustomArticle a subclass of Article? Django models do support inheritance! Have a look at: https://docs.djangoproject.com/en/dev/topics/db/models/#model-inheritance
- User authentication via ssl certs in django
- Django – annotate() – Sum() of a column with filter on another column
- Monolithic or microservice concept
1👍
try something like this:
class CustomArticle(models.Model):
# Other methods...
original = models.ForeignKey('Article')
def __getattr__(self, name):
return getattr(self.original, name)
- Any way to serialize a pagination object in Django?
- Problem reusing serializers with django and drf-yasg
- Django Rest Framework or JsonResponse
- Adding static() to urlpatterns only work by appending to the list
- Django Apache mod_wsgi 500
Source:stackexchange.com