Hi, i am creator django-python-notes blog. Sorry, i forgot this blog over a year ago. I want to ask something of you. You want to see new notes in the blog?

izzy's playlists!
No title available

@theartofmadeline
Not today Justin
$LAYYYTER
One Nice Bug Per Day
we're not kids anymore.
The Bowery Presents

pixel skylines
will byers stan first human second
art blog(derogatory)
Fai_Ryy
Xuebing Du

oozey mess
ojovivo

❣ Chile in a Photography ❣

gracie abrams
Sade Olutola
The Stonewall Inn
untitled

seen from Malaysia

seen from United States

seen from United States

seen from United Kingdom

seen from Malaysia
seen from United States

seen from Croatia

seen from United States
seen from United States

seen from Singapore
seen from Netherlands

seen from Malaysia

seen from United States
seen from United States

seen from Russia

seen from India
seen from South Africa
seen from United States
seen from United States
seen from United States
@django-python-notes
Hi, i am creator django-python-notes blog. Sorry, i forgot this blog over a year ago. I want to ask something of you. You want to see new notes in the blog?
request.user returns a SimpleLazyObject
if hasattr(user, '_wrapped') and hasattr(user, '_setup'):
if user._wrapped.__class__ == object:
user._setup()
user = user._wrapped
Queryset + Queryset
querysets = queryset1 | queryset2
Making queries "time"
Article.objects.filter(time__year=2013, time__month=4, time__day=10)
Making queries "starts with"
SomeModel.objects.filter(name__startswith='test_')
Example APIView
class SomeView(APIView): serializer_class = SomeSerializer def post(self, request): serializer = self.get_serializer(data=request.DATA) if serializer.is_valid(): return Response({'some_data': '9000'}) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) class SomeSerializer(serializers.Serializer): field = serializers.CharField(max_length=255) def validate(self, attrs): field = attrs.get('field') if len(field) < 10: raise serializers.ValidationError('Filed too small!') if field == 'Duck': raise serializers.ValidationError('No duck') return attrs
Pagination in the generic views
class PaginatedListView(ListAPIView): model = ExampleModel serializer_class = ExampleSerializer paginate_by = 10 paginate_by_param = 'page_size'
Serializer method field or not model field
class MySerializer(serializers.ModelSerializer): name = serializers.SerializerMethodField('get_name') def get_name(self, obj): return '%s %s' % (obj.firstname, obj.lastname) class Meta: model = SomeModel fields = ('firstname', 'lastname', 'avatar')