Closed nerdoc closed 3 months ago
That's because users should not be passed directly.
Solution: pass user ids: {% @ myapp.default.example user_id=request.user.pk / %}
from myapp.models import User
@default.register
class Example(Component):
def load(self, user_id: int, *args, **kwargs) -> None:
self.user = User.objects.get(pk=user_id)
This could be done later automatically. So I'll keep this open until a solution is found.
But that's basically what #31 means. So I'm closing this.
When using a Custom User Model in Django, and creating a Component like the following, you run into problems:
and using it like this:
The fact that a custom user model is passed to the
load()
method, Tetra hickups when unpickling that object. Rendering it when the page is built works fine, but as soon as you click on the "do it" button:With normal modal objects, this is no problem (as long it is not a request, etc, but that's another story).
I think that when pickling a LazyObject, it should resolve the object first - but that's just a wild guess.