第8月第19天 django restframe

Posted lianhuaren

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第8月第19天 django restframe相关的知识,希望对你有一定的参考价值。

 

1.

    def retrieve(self, request, pk=None):
        try:
            book = Book.objects.get(book_id=pk)
        except Book.DoesNotExist:
            return HttpResponse(status=404)    
        
        # queryset = Book.objects.all()
        # book = get_object_or_404(queryset, pk=pk)
        serializer = BookSerializer(book)
        return Response(serializer.data)

 

http://www.cnblogs.com/pycode/p/6365905.html

http://www.django-rest-framework.org/api-guide/viewsets/

 

2.boostrap

 

http://www.cnblogs.com/fnng/p/3998774.html

 

3.

class Category(models.Model):
    categoryid = models.IntegerField(default=0)
    createtime = models.IntegerField(default=0)
    display = models.IntegerField(default=0)
    uses = models.IntegerField(default=0)
    entitle = models.CharField(max_length=255, unique=True)
    zhtitle = models.CharField(max_length=255, unique=True)
    intro = models.TextField(blank=True)
    miniposter = models.CharField(max_length=255, unique=True)
    poster = models.CharField(max_length=255, unique=True)
    status = models.IntegerField(default=0)
    topcatid = models.IntegerField(default=0)
    
    def __unicode__(self):
        return \'%s\' % self.entitle

class Theme(models.Model):
    themeid = models.IntegerField(default=0)
    category = models.ForeignKey(Category)
    display = models.IntegerField(default=0)
    grade = models.IntegerField(default=0)
    intro = models.TextField(blank=True)
    poster = models.CharField(max_length=255, unique=True)
    status = models.IntegerField(default=0)
    uses = models.IntegerField(default=0)
    tips = models.CharField(max_length=255, blank=True)
    title = models.CharField(max_length=255, unique=True)
    
    def __unicode__(self):
        return \'%s\' % self.title

 

class ThemeSerializer(serializers.HyperlinkedModelSerializer):
    category = CategorySerializer()
    class Meta:
        model = Theme
        fields = (\'category\',  \'display\', \'grade\', \'intro\', \'poster\', \'status\', \'themeid\', \'uses\', \'title\', \'tips\')

class ThemeSet(viewsets.ModelViewSet):
    queryset = Theme.objects.all()
    serializer_class = ThemeSerializer

 

http://python.jobbole.com/87226/

 

以上是关于第8月第19天 django restframe的主要内容,如果未能解决你的问题,请参考以下文章

第25月第2天 django项目01

第19月第20天 UITableView:改变 TableHeaderView 的高度

第25月第4天 djangochinaorg项目记录01

第28月第8天

第38月第8天 ios13 _placeholderLabel

第8月第22天 python scrapy