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

Warn (or solve) if there are duplicate child class field names #1

Open
mnieber opened this issue Jun 14, 2013 · 0 comments
Open

Warn (or solve) if there are duplicate child class field names #1

mnieber opened this issue Jun 14, 2013 · 0 comments

Comments

@mnieber
Copy link

mnieber commented Jun 14, 2013

The following does not work because the name "request_message" is duplicated in two child classes of the base class Message, which produces a conflict later on when querying the database.

class Message(TypedModel):
pass

class AcceptMessage(Message):
request_message = models.ForeignKey('self', null=True, blank=True, related_name='+')

class DeclineMessage(Message):
request_message = models.ForeignKey('self', null=True, blank=True, related_name='+')

This can be solved by moving request_message to the base class but this is not always what you want (perhaps a third class inheriting from Message does not have a request_message field).

It would be nice if TypedModel would at least raise an exception in this case so that the programmer becomes aware of the problem.

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

No branches or pull requests

1 participant