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
Can not have a field named the same as a Page model #503
Comments
Thanks for spotting! This sounds like a clash with the virtual field Django provides for finding I'm not sure how this could be solved at the moment. But I would recommend On 25 July 2014 02:44, Tim Heap notifications@github.com wrote:
|
What @kaedroho said. Almost every field name we use in our clients' sites could just as easily describe a whole model required by another part of the project, so we've taken to prefixing all of our page models, whether we foresee a clash or not. |
Ah yes, that would explain it. You're suggested work around would work. This probably needs documenting somewhere though, because it confused the hell out of me! Would it be possible/sensible to disable this relation? I can't see it being used often as Page is a generic base class, so you would not often go from that to a specific page type. On 25 July 2014 6:43:35 PM AEST, Karl Hobley notifications@github.com wrote:
|
I managed to work around this issue by overriding the automatically generated from django.db import models
from wagtail.wagtailcore.models import Page
class Foo(Page):
page_ptr = models.OneToOneField(Page, parent_link=True, related_name='+')
bar = models.CharField(max_length=255)
class Bar(Page):
page_ptr = models.OneToOneField(Page, parent_link=True, related_name='+')
|
Thanks @timheap This wouldn't be easy to fix in Wagtail (it's more of a Django issue anyway) and can be easily worked around by suffixing your page models with |
I've found another issue recently that is related to this. It is not possible to have two page classes with the same name, even if they're in different apps. This is because the reverse accessor from the Page class would be given the same name causing a clash. This is possible to work around using the code above to override |
To work around wagtail#503
To work around wagtail#503
The following model definition will cause an error when instansiating a Foo:
This does not happen when using
django.db.models.Model
as the base class of Foo and Bar, so this is a Wagtail issue. I encountered this issue when attempting to create a Page model namedWebsite
, and had another Page model with a fieldwebsite
.The text was updated successfully, but these errors were encountered: