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

Fixed #24472 -- Defined internal types explicitly for related fields #16960

Closed
wants to merge 2 commits into from

Conversation

Akash-Kumar-Sen
Copy link
Contributor

@Akash-Kumar-Sen Akash-Kumar-Sen commented Jun 8, 2023

Ticket - 24472
Following PR #4296

@shangxiao
Copy link
Contributor

I'm not sure I see the point of adding extra boilerplate like this as the name of the field can be determined from the class; and the fact that the ticket & PR never got updated to add some simple tests over the last decade tells me that nobody has a use for it.

If we really wanted this for consistency's sake we can do this:

class OneToOneField:
    @classmethod
    def get_internal_type(cls):
        return cls.__name__

gives:

>>> field = OneToOneField()
>>> field.get_internal_type()
'OneToOneField'
>>> OneToOneField().get_internal_type()
'OneToOneField'

@Akash-Kumar-Sen
Copy link
Contributor Author

Akash-Kumar-Sen commented Jun 9, 2023

  • I also don't see any other reason than consistency.
  • Deriving the string from using cls.__name__ makes more sense rather than hardcoding it. But that won't work on Inherited fields.

@felixxm
Copy link
Member

felixxm commented Jun 9, 2023

If we really wanted this for consistency's sake we can do this:

class OneToOneField:
    @classmethod
    def get_internal_type(cls):
        return cls.__name__

gives:

>>> field = OneToOneField()
>>> field.get_internal_type()
'OneToOneField'
>>> OneToOneField().get_internal_type()
'OneToOneField'

It works this way from the very beginning:

def get_internal_type(self):
return self.__class__.__name__

@felixxm
Copy link
Member

felixxm commented Jun 9, 2023

Closing per ticket.

@felixxm felixxm closed this Jun 9, 2023
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