These are chat archives for django/django

Dec 2017
Dec 14 2017 10:31
@emihir0 When you consider datetimeField do not forget that we have timezone. Therefore your best practice is showing the datetimeField, but omit the day. And be caution on timezone.
Dec 14 2017 12:05
I do realise there is a timezone issue; but for my in-house-app that I'm doing it's not an issue as we are not an international company.
and in either case, I'm talking about DateField mostly where I want to omit day. I do realise the advantages of using naive DateField and not 2 intigerfields (or such) for year, month; hence I asked whether there is an open source, properly tested, Year and/or MonthYear field which inherits from DateField but always puts day=1. I don't want to go ahead and make db field, widget and form field for this from scratch as I will, most likely, mess some part up that will catch up with me later on, and most likely if something like this already exists.
Marios Panagopoulos
Dec 14 2017 16:23
class CollectionSerializer(serializers.ModelSerializer):
    class Meta:
        model = Collection
        fields = ('id', 'title')

class FolderSerializer(serializers.ModelSerializer):
    collections = CollectionSerializer(many= True, read_only=True)
    class Meta:
        model = Folder
        fields = ('id', 'title', 'collections')
can anyone tell me why it doesn't return me collections when i call API ?
Marios Panagopoulos
Dec 14 2017 17:11
``` folder = models.ForeignKey(Folder, null = True, blank=True, on_delete=models.SET_NULL, related_name='collections') ```
i found it I should put related_name or it doesn't work but i didn't find it in documentation