lightweightdjango / examples

Code examples for "Lightweight Django", by Julia Elman and Mark Lavin.
http://bit.ly/lightweightdjango
441 stars 221 forks source link

scrum: validate_end() missing 1 required positional argument: 'source' #2

Closed dawidp closed 9 years ago

dawidp commented 9 years ago

After fixing error:

It is redundant to specify `get_links` on SerializerMethodField 'links' in serializer 'SprintSerializer',
because it is the same as the default method name. Remove the `method_name` argument.

in class SprintSerializer and TaskSerializer with links, status_display fields I got stuck with this error:

TypeError at /api/sprints/
validate_end() missing 1 required positional argument: 'source'
Request Method: POST
Request URL:    http://localhost:8000/api/sprints/
Django Version: 1.7.1
Exception Type: TypeError
Exception Value:    validate_end() missing 1 required positional argument: 'source'
Exception Location: /home/dade/.virtuaenvs/kikiri-test/lib/python3.4/site-packages/rest_framework/serializers.py in to_internal_value, line 362
Python Executable:  /home/dade/.virtuaenvs/kikiri-test/bin/python
Python Version: 3.4.0
Python Path:    
['/home/dade/projects/python/kikiri-test-django/scrum',
 '/home/dade/.virtuaenvs/kikiri-test/lib/python3.4',
 '/home/dade/.virtuaenvs/kikiri-test/lib/python3.4/plat-x86_64-linux-gnu',
 '/home/dade/.virtuaenvs/kikiri-test/lib/python3.4/lib-dynload',
 '/usr/lib/python3.4',
 '/usr/lib/python3.4/plat-x86_64-linux-gnu',
 '/home/dade/.virtuaenvs/kikiri-test/lib/python3.4/site-packages']
Server time:    Thu, 18 Dec 2014 02:16:36 +0000

this happens when I try to post a sprint with due date set to 01/12/2014. Firstly I thought this was my type error but after cloning examples got the same error.

dawidp commented 9 years ago

I think I've found the problem(s): I was using following versions of Django and Django Rest Framework:

Django==1.7.1
djangorestframework==3.0.1

while these examples were build (probably) using:

Django==1.7
djangorestframework==2.4.4

I think it would be good idea to add requirements.txt with versions of the packages

mlavin commented 9 years ago

You are correct. The book was written for Django Rest Framework 2.X and isn't compatible with the latest serializer changes in 3.X. We'll update to make that more explicit.

Copser commented 9 years ago

Great book by the way, @dawidp and @mlavin, tank you for clearing this out for me...;-D

ghost commented 9 years ago

Thank you so much guys.... :+1:

gddk commented 9 years ago

ditto the thank you, I've been enjoying coding the examples and learning rest_framework. I too ran into the 3 vs 2 problem with validation, but figured out how to convert to v3 style. See https://github.com/djangopractice/scrum/blob/17c3b8b2850aa7d8aa1d3fecd38f0b654dfa2744/board/serializers.py for rest framework v3 style validation.

mlavin commented 9 years ago

@juliaelman and I have been trying to figure out the best way to address this, particularly for those who have print copies of the book. We want to keep this repo in line with the book and any submitted corrections so we can't just fix it here. There are a bunch of little changes which aren't too difficult to follow if you read the 3.0 release notes but might be tedious in the errata. The easiest correction/errata would be to say pip install djangorestframework<3.0 in the chapter but that feels like a bit of a cop out. If anyone has thoughts or feelings about a note/correction that would save people some heart ache when working through this chapter we'd love to hear them.

mlavin commented 9 years ago

We've pushed updates and confirmed the errata for the known issues related to Django REST Framework 3.0.X: https://github.com/lightweightdjango/examples/compare/396eb56e96...bbf88e2076

Thank you to everyone who reported this issue and those who submitted fixes. I know it was helpful for our readers to be able to find those before we were able to make the updates.