agiliq / building-api-django Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Am a beginner in Django and I would like to know where exactly do I run this below -
Using the PollSerializer
Let’s use the serializer to create a Poll object.
In [1]: from polls.serializers import PollSerializer
In [2]: from polls.models import Poll
In [3]: poll_serializer = PollSerializer(data={"question": "Mojito or Caipirinha?", "created_by": 1})
In [4]: poll_serializer.is_valid()
Out[4]: True
In [5]: poll = poll_serializer.save()
In [6]: poll.pk
Out[6]: 5
The poll.pk line tells us that the object has been commited to the DB. You can also use the serializer to update a Poll object.
In [9]: poll_serializer = PollSerializer(instance=poll, data={"question": "Mojito, Caipirinha or margarita?", "created_by": 1})
In [10]: poll_serializer.is_valid()
Out[10]: True
In [11]: poll_serializer.save()
Out[11]: <Poll: Mojito, Caipirinha or margarita?>
In [12]: Poll.objects.get(pk=5).question
Out[12]: 'Mojito, Caipirinha or margarita?'
Do we run it in the terminal? or we create a file and we run it inside there. I will be very happy for your help, and I really thank you for the tutorial, it's really nice.
Hi there, I'm a django developer for 3+ years and love to share resources with the spanish community, I was wondering if you're open to translations
In "Introducing Viewsets and Routers" topic in "More views and viewsets" chapter, has used the deprecated "base_name" argumente in:
router.register('polls', PollViewSet, basename='polls')
From the file 'access-control.rst'
In the line 126 what is the migration?
When I do the POST with user and password reponse User has no auth_token.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.