今天在学习django-rest-framework框架时出现一个BUG。项目结构如下
App中有一个Book Model,定义如下:
class Book(models.Model):
b_name = models.CharField(max_length=32)
然后我在REST app中也建了一个Book,定义如下:
class Book(models.Model):
b_name = models.CharField(max_length=32)
b_price = models.FloatField(default=1.0)
REST中的Serializers.py如下:
from django.contrib.auth.models import User, Group
from rest_framework import serializers
from REST.models import Book
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url','username','email','groups')
class Grou