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
RuntimeError: Unable to resolve relationship user
for wagtailcore.ModelLogEntry
. Django is most likely not initialized, and its apps registry not populated. Ensure Django has finished setup before loading FilterSet
s
#9586
Comments
Thanks for the report @Elrigor! We've had a couple of reports of similar issues (e.g. #9582), although we haven't yet definitively determined what triggers it. It looks quite likely that it's related to custom user models, though - are you using one on your project? As another workaround, calling |
Hi, Thank you for your fast reply! |
I'd have to roll back to an earlier commit in my project to confirm this, but I think I had a similar issue last week as I was coding the migration from 2.16 via 3.0 and 4.0 to 4.1rc1. It was resolved by putting the custom user module very early in the INSTALLED_APPS list (in settings), before any other module that referred to the user object. |
That fixed it! Thank you mate 💯 |
Reopening this, as we do want to find a proper fix for this that allows previously-working code to continue working on 4.1. |
The filterset on the snippet history view has been there since 4.0, so I believe that's not the (only) cause. In 4.1, we added this import, which causes the |
Reproduced on a fresh Wagtail project as follows: wagtail start customusersnippet
cd customusersnippet
./manage.py startapp customuser Add from django.db import models
from django.contrib.auth.models import AbstractUser
class CustomUser(AbstractUser):
country = models.CharField(verbose_name='country', max_length=255) Add Edit home/models.py as follows: from django.db import models
from wagtail.models import Page
from wagtail.snippets.models import register_snippet
class HomePage(Page):
pass
@register_snippet
class Advert(models.Model):
text = models.TextField() Now
Placing |
Bisecting shows that 6e1e024 is the commit that triggered this issue. |
Suggestion: Would it be viable to update |
@ababic That sounds like a good plan, yep! We're being a bit quirky with how we mix model and view code here, and while I think django-filter might be technically in the wrong for how early in the execution it's doing model lookups, making it less quirky wouldn't be a bad thing. :-) |
@gasman I think you're right about In addition to the above, maybe we make the 'viewset' argument accept a python path string? That way, we can keep that 'lazy' until we are ready to register views. |
If people are building custom viewsets to pass to |
Fixes wagtail#9586. All calls to `register_snippet` that happen before `WagtailSnippetsAppConfig.ready` are now queued up and processed once we are sure models are fully loaded. This avoids any issues with unloaded models during viewset construction, as seen when subclassing django-filters's FilterSet.
Fixes #9586. All calls to `register_snippet` that happen before `WagtailSnippetsAppConfig.ready` are now queued up and processed once we are sure models are fully loaded. This avoids any issues with unloaded models during viewset construction, as seen when subclassing django-filters's FilterSet.
Hi!
I've updated to the LTS 4.1 but this error came out:
I have the following versions:
Wagtail 4.1
Django 4.0.8
django-filter 22.1]
My temporal "fix"
I was able to solve this by removing the user on the meta class of SnippetHistoryReportFilterSet :
This is located at wagtail/snippets/views/snippets.py
Is that a logger or something like that? If so, is there a way to disable it in order to use the page?
Thanks!
The text was updated successfully, but these errors were encountered: