Skip to content

feature request: make self.request available within javascript_exclude class properties #650

Open
@jacksund

Description

@jacksund

When I set an attribute dynamically via a @property attribute and also add it to javascript_exclude, the request is no longer accessible from self.

Here's the minimal amount of code to reproduce:

class Example(UnicornView):

    class Meta:
        javascript_exclude = (
            "user_id",
        )

    @property
    def user_id(self):
        return self.request.user.id

This is a silly example (since request.user.id is already accessible in the template). In a real-world example, I would use the request.user within a property to grab things like user settings and/or database objects related to user + add extra python logic.

Is there a way to implement this?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions