DRF Serializers
Account serializers for Smarter API
- class smarter.apps.account.serializers.AccountContactSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerSerializer for the AccountContact model in the Smarter API.
This serializer exposes all fields of the AccountContact model, including a minimal account reference. Use it for endpoints that manage or display account contact information.
- Parameters:
account – Instance of
AccountMiniSerializer. Minimal account information.... – All other fields as defined in the AccountContact model.
Note
All fields are read-only in this serializer.
Example usage:
from smarter.apps.account.serializers import AccountContactSerializer serializer = AccountContactSerializer(contact_instance) data = serializer.data
See also
For full account details, use
AccountSerializer.- get_fields()[source]
Return the dict of field names -> field instances that should be used for self.fields when instantiating the serializer.
- class smarter.apps.account.serializers.AccountMiniSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerSerializer for a minimal representation of the Account model in the Smarter API.
This serializer is intended for scenarios where only the account number is required, such as embedding account references in related resources or optimizing API payload size.
- Parameters:
account_number – String. The unique identifier for the account.
Note
Only the
account_numberfield is included in serialization.Tip
Use this serializer for nested relationships or summary views.
Example usage:
from smarter.apps.account.serializers import AccountMiniSerializer serializer = AccountMiniSerializer(account_instance) data = serializer.data
See also
For full account details, use
AccountSerializer.
- class smarter.apps.account.serializers.AccountSerializer(*args, **kwargs)[source]
Bases:
MetaDataModelSerializerSerializer for the Account model in the Smarter API.
This serializer provides full access to all fields of the Account model, making it suitable for detailed account data retrieval and updates via API endpoints.
- Parameters:
account_number – String. The unique identifier for the account.
name – String. The account name.
... – Other fields as defined in the Account model.
Important
All fields in the Account model are included in serialization and deserialization.
Example usage:
from smarter.apps.account.serializers import AccountSerializer serializer = AccountSerializer(account_instance) data = serializer.data
See also
For lightweight account representations, use
AccountMiniSerializer.
- class smarter.apps.account.serializers.MetaDataWithOwnershipModelSerializer(*args, **kwargs)[source]
Bases:
MetaDataModelSerializerSerializer for models that extend MetaDataWithOwnershipModel, adding an ‘account’ field.
- class smarter.apps.account.serializers.UserMiniSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerSerializer for a minimal representation of the User model in the Smarter API.
This serializer is designed for use cases where only essential user information is required, such as listing users or embedding user data in related resources.
- Parameters:
username – String. The user’s username.
email – String. The user’s email address.
Note
All fields are read-only and included in the serialized output.
Tip
Use this serializer for lightweight API responses to reduce payload size.
Example usage:
from smarter.apps.account.serializers import UserMiniSerializer serializer = UserMiniSerializer(user_instance) data = serializer.data
See also
For full user details, use
UserSerializer.
- class smarter.apps.account.serializers.UserProfileSerializer(*args, **kwargs)[source]
Bases:
SmarterCamelCaseSerializerSerializer for the UserProfile model in the Smarter API.
This serializer provides a minimal representation of a user profile, including nested user and account data. Use it for endpoints where a summary of user and account relationships is required.
- Parameters:
user – Instance of
UserMiniSerializer. Minimal user information.account – Instance of
AccountMiniSerializer. Minimal account information.
Note
Only the
userandaccountfields are included in serialization.Example usage:
from smarter.apps.account.serializers import UserProfileSerializer serializer = UserProfileSerializer(profile_instance) data = serializer.data
See also
For more detailed user or account data, use
UserSerializerorAccountSerializer.
- class smarter.apps.account.serializers.UserSerializer(*args, **kwargs)[source]
Bases:
MetaDataModelSerializerSerializer for the User model in the Smarter API.
This serializer converts Django User model instances to and from JSON using camelCase field names, making it suitable for API responses and requests.
- Parameters:
id – Integer. The unique identifier for the user.
username – String. The user’s username.
first_name – String. The user’s first name.
last_name – String. The user’s last name.
email – String. The user’s email address.
is_staff – Boolean. Indicates if the user has staff privileges.
is_superuser – Boolean. Indicates if the user has superuser privileges.
Note
All fields listed in
fieldsare included in serialization. Add more fields to the list if needed.Example usage:
from smarter.apps.account.serializers import UserSerializer serializer = UserSerializer(user_instance) data = serializer.data