from django.contrib.auth.models import User

from rest_framework import serializers

from .models import UserDefinedCategory
from .models import EntryInstance


class UserDefinedCategorySerializer(serializers.HyperlinkedModelSerializer):
    url = serializers.HyperlinkedIdentityField(
        view_name='category-detail'
    )
    # TODO Should I just either not include it, or go with the user name?
    user = serializers.PrimaryKeyRelatedField(read_only=True)

    class Meta:
        model = UserDefinedCategory
        fields = ('url', 'user', 'category', 'pk',)


class EntryInstanceSerializer(serializers.ModelSerializer):
    user = serializers.ReadOnlyField(source='user.username')

    class Meta:
        model = EntryInstance
        fields = ('user', 'category', 'date', 'entry', 'quality_rating', 'pk',)

from rest_framework import serializers

from .models import UserDefinedCategory
from .models import EntryInstance


class UserDefinedCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = UserDefinedCategory
        fields = ('user', 'category', 'pk',)


class EntryInstanceSerializer(serializers.ModelSerializer):
    user = serializers.ReadOnlyField(source='user.username')

    class Meta:
        model = EntryInstance
        fields = ('user', 'category', 'date', 'entry', 'quality_rating', 'pk',)

Revert "beginning hyperlink model serialization"
Revert "beginning hyperlink model serialization"

This reverts commit 6d41c54397512da69604f7e730757f4aff96374f.

- from django.contrib.auth.models import User
- 
  from rest_framework import serializers
  
  from .models import UserDefinedCategory
  from .models import EntryInstance
  
  
- class UserDefinedCategorySerializer(serializers.HyperlinkedModelSerializer):
+ class UserDefinedCategorySerializer(serializers.ModelSerializer):
-     url = serializers.HyperlinkedIdentityField(
-         view_name='category-detail'
-     )
-     # TODO Should I just either not include it, or go with the user name?
-     user = serializers.PrimaryKeyRelatedField(read_only=True)
- 
      class Meta:
          model = UserDefinedCategory
-         fields = ('url', 'user', 'category', 'pk',)
+         fields = ('user', 'category', 'pk',)
  
  
  class EntryInstanceSerializer(serializers.ModelSerializer):
      user = serializers.ReadOnlyField(source='user.username')
  
      class Meta:
          model = EntryInstance
          fields = ('user', 'category', 'date', 'entry', 'quality_rating', 'pk',)
  
Revert "beginning hyperlink model serialization"
## Code Before:
from django.contrib.auth.models import User

from rest_framework import serializers

from .models import UserDefinedCategory
from .models import EntryInstance


class UserDefinedCategorySerializer(serializers.HyperlinkedModelSerializer):
    url = serializers.HyperlinkedIdentityField(
        view_name='category-detail'
    )
    # TODO Should I just either not include it, or go with the user name?
    user = serializers.PrimaryKeyRelatedField(read_only=True)

    class Meta:
        model = UserDefinedCategory
        fields = ('url', 'user', 'category', 'pk',)


class EntryInstanceSerializer(serializers.ModelSerializer):
    user = serializers.ReadOnlyField(source='user.username')

    class Meta:
        model = EntryInstance
        fields = ('user', 'category', 'date', 'entry', 'quality_rating', 'pk',)

## Instruction:
Revert "beginning hyperlink model serialization"
## Code After:
from rest_framework import serializers

from .models import UserDefinedCategory
from .models import EntryInstance


class UserDefinedCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = UserDefinedCategory
        fields = ('user', 'category', 'pk',)


class EntryInstanceSerializer(serializers.ModelSerializer):
    user = serializers.ReadOnlyField(source='user.username')

    class Meta:
        model = EntryInstance
        fields = ('user', 'category', 'date', 'entry', 'quality_rating', 'pk',)
