Re: How to not allow additional properties

2018-01-15 Thread Jani Tiainen
Hi,

Is there a reason you want to reject requests with extra data rather than
just ignore extra values?

One way to do that could be whitelisting allowed params per view but that
you have to do yourself. You could probably use DRF authentication API for
that.

15.1.2018 18.43 "Daniel Chimeno"  kirjoitti:

> Hello!
>
> How could I deny requests that has additional properties?
> Example:
>
> class IntervalSerializer(serializers.Serializer):
> month = serializers.DateField(format='%Y-%m', input_formats=['%Y-%m'])
> day_of_week = serializers.IntegerField(min_value=1, max_value=7)
> start_hour = serializers.IntegerField(min_value=0, max_value=24)
> end_hour = serializers.IntegerField(min_value=1, max_value=24)
>
> I would like to allow incoming requests like:
> {'month': '2017-03', 'day_of_week': 7, 'start_hour': 3, 'end_hour': 2}
>
>
> but to not allow incoming requestse like:
> {'month': '2017-03', 'day_of_week': 7, 'start_hour': 3, 'end_hour': 2,
> 'another_attribute': 3}
>
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-rest-framework+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can I use DRF 2.4.x with Django 1.11?

2018-01-15 Thread wolfg
Got it. Thanks!

在 2018年1月16日星期二 UTC+8上午12:32:43,Xavier Ordoquy写道:
>
> Hi,
>
> It’s unlikely that 2.4 supports Django 1.11 out of the box. Either you’ll 
> have to upgrade to a more recent Django REST framework or you’ll have to 
> port DRF 2.4.x
>
> Regards,
> Xavier.
>
> Le 15 janv. 2018 à 17:23, wolfg > a écrit 
> :
>
> Hi, I have a project using Django 1.6.x and DRF 2.4.3. Can I upgrade the 
> Django to the 1.11 LTS? The reason is not using DRF 3.x is the project is 
> big and using heavy customization on the top of DRF 2.4.x.
>
> Regards
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-rest-framework+unsubscr...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to not allow additional properties

2018-01-15 Thread Daniel Chimeno
Hello!

How could I deny requests that has additional properties?
Example:

class IntervalSerializer(serializers.Serializer):
month = serializers.DateField(format='%Y-%m', input_formats=['%Y-%m'])
day_of_week = serializers.IntegerField(min_value=1, max_value=7)
start_hour = serializers.IntegerField(min_value=0, max_value=24)
end_hour = serializers.IntegerField(min_value=1, max_value=24)

I would like to allow incoming requests like:
{'month': '2017-03', 'day_of_week': 7, 'start_hour': 3, 'end_hour': 2}


but to not allow incoming requestse like:
{'month': '2017-03', 'day_of_week': 7, 'start_hour': 3, 'end_hour': 2, 
'another_attribute': 3}


Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can I use DRF 2.4.x with Django 1.11?

2018-01-15 Thread Xavier Ordoquy
Hi,

It’s unlikely that 2.4 supports Django 1.11 out of the box. Either you’ll have 
to upgrade to a more recent Django REST framework or you’ll have to port DRF 
2.4.x

Regards,
Xavier.

> Le 15 janv. 2018 à 17:23, wolfg  a écrit :
> 
> Hi, I have a project using Django 1.6.x and DRF 2.4.3. Can I upgrade the 
> Django to the 1.11 LTS? The reason is not using DRF 3.x is the project is big 
> and using heavy customization on the top of DRF 2.4.x.
> 
> Regards
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django REST framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-rest-framework+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Can I use DRF 2.4.x with Django 1.11?

2018-01-15 Thread wolfg
Hi, I have a project using Django 1.6.x and DRF 2.4.3. Can I upgrade the 
Django to the 1.11 LTS? The reason is not using DRF 3.x is the project is 
big and using heavy customization on the top of DRF 2.4.x.

Regards

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.