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

Abstract intermediary class #77

Open
mcosti opened this issue Jan 17, 2024 · 2 comments
Open

Abstract intermediary class #77

mcosti opened this issue Jan 17, 2024 · 2 comments

Comments

@mcosti
Copy link

mcosti commented Jan 17, 2024

HI!

I've just read the issue here:

#61

And it seems I am running into the same kind of problem.

I would like to achieve the following structure.

class BaseClass(TypedModel):
    a = models.CharField(...)


class BaseClassWithFlavor(BaseClass):
    class Meta:
        abstract = True

    b = models.CharField(...)



class Child1(BaseClassWithFlavor):
    pass


class Child2(BaseClassWithFlavor):
    pass

Which would result in both Child1 and Child2 having the "b" field.

Is that possible in anyway?

@craigds
Copy link
Owner

craigds commented Jan 18, 2024

Thanks for the issue. This should work already I think, since it's the same situation as Child1 and Child2 both having an identical b field defined. And per the readme:

Fields defined on subclasses can only be defined on one subclass, unless the duplicate fields are exactly identical.

Presumably it's not working? Can you paste any error information you have?

@mcosti
Copy link
Author

mcosti commented Jan 18, 2024

Hi @craigds, thanks for the answer.

TypeError: Abstract base class containing model fields not permitted for proxy model 'Child1'.

This is the error that I get

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

2 participants