Skip to content

Add InertiaMeta for automatic serialization #66

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

Merged
merged 2 commits into from
Feb 13, 2025
Merged

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!

@BrandonShar BrandonShar merged commit dafda82 into main Feb 13, 2025
3 checks passed
@BrandonShar BrandonShar deleted the add-inertia-meta branch February 13, 2025 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant