Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add InertiaMeta for automatic serialization #66

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BrandonShar
Copy link
Collaborator

This PR adds the concept of InertiaMeta as suggested by @scajanus in #65

class User(models.Model):
  name = models.CharField(max_length=255)
  password = models.CharField(max_length=255)
  created_at = models.DateField(auto_now_add=True)

  class InertiaMeta:
    fields = ('name', 'created_at')

Will result in the props output of a User instance being

{
  "name": "Brandon",
  "created_at": "2025-01-25T10:13:01"
}

Because of the implementation, InertiaMeta can also be used on any class, not just models!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant