I hereby claim:
- I am zhukandrey on github.
- I am azpwnz (https://keybase.io/azpwnz) on keybase.
- I have a public key ASAsaBZQAnbf5vYu51bJO5o-pyV_yh5aZEUjk0fYNQ7wwwo
To claim this, I am signing this object:
class CampaignSerializer(serializers.ModelSerializer): | |
# companies is many-to-many field. Use StringRelatedField will show names of the companes instead of ids. | |
companies = serializers.StringRelatedField(many=True) | |
# format date | |
created_at = serializers.DateTimeField(format="%Y-%m-%d") | |
# custom field with count of companies (which is many-to-many field). It use method with the same name: get_<name of the field>(self, obj) | |
companies_count = serializers.SerializerMethodField() | |
def get_companies_count(self, obj): | |
return obj.companies.count() |
if hasattr(object, 'some_field'): | |
pass |
// In order to use nested contitionals, they must be wrapped into container like array | |
{ this.state.companies | |
? <h3>Companies</h3> | |
: [ | |
(this.state.loading | |
? <p>Loading...</p> | |
: null | |
) | |
] | |
} |
def to_internal_value(self, data): | |
internal_value = super(SearchPresetSerializer, self).to_internal_value(data) | |
user = data.get("user") | |
internal_value.update({ | |
"user": user | |
}) | |
return internal_value |
I hereby claim:
To claim this, I am signing this object: