Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added getattr for profilefield in order to be used as the same model #10341

Closed
wants to merge 1 commit into from
Closed

Added getattr for profilefield in order to be used as the same model #10341

wants to merge 1 commit into from

Conversation

FJLendinez
Copy link

With this function we override the standard behaviour of getattr in order to find first in the object if it has the attr and, if it is defined, find over the profilefield model.

Copy link
Member

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @FJLendinez.

We can't add something like this I'm afraid. We can't tie django.db into your specific project field. (We can't even tie django.db into django.contrib.auth.)

If you're looking for features similar to this I suggest you try discussing your needs on django-users or StackOverflow or similar to see what suggestions people have. Then please see the contributing guide if you want to propose new features.

@@ -547,6 +547,16 @@ def __setstate__(self, state):

self.__dict__.update(state)

def __getattr__(self, name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax error here.

try:
return object.__getattribute__(self, item)
except AttributeError:
ProfileField = self._meta.ProfileField
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't add a reference to a project specific field in models/base.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants