add Tags, Properties and Categories
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
91cd5c57b3
commit
7e1b92a162
10 changed files with 414 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from rest_framework import serializers
|
||||
from authentication.models import KnownIdentity
|
||||
from toolshed.models import Category, Property
|
||||
|
||||
|
||||
class FriendSerializer(serializers.ModelSerializer):
|
||||
|
|
@ -11,3 +12,20 @@ class FriendSerializer(serializers.ModelSerializer):
|
|||
|
||||
def get_username(self, obj):
|
||||
return obj.username + '@' + obj.domain
|
||||
|
||||
|
||||
class PropertySerializer(serializers.ModelSerializer):
|
||||
category = serializers.SlugRelatedField(queryset=Category.objects.all(), slug_field='name')
|
||||
|
||||
class Meta:
|
||||
model = Property
|
||||
fields = ['name', 'description', 'category', 'unit_symbol', 'unit_name', 'unit_name_plural', 'base2_prefix']
|
||||
|
||||
|
||||
class CategorySerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Category
|
||||
fields = ['name']
|
||||
|
||||
def to_representation(self, instance):
|
||||
return str(instance)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue