![]() ![]() from django.db import modelsįrom pygments.lexers import get_all_lexersįrom pygments.styles import get_all_styles Although you will find them in our repository version of this tutorial code, we have omitted them here to focus on the code itself. Note: Good programming practices include comments. Go ahead and edit the snippets/models.py file. Creating a model to work withįor the purposes of this tutorial we're going to start by creating a simple Snippet model that is used to store code snippets. Let's edit the tutorial/settings.py file: INSTALLED_APPS = [ We'll need to add our new snippets app and the rest_framework app to INSTALLED_APPS. Once that's done we can create an app that we'll use to create a simple Web API. To get started, let's create a new project to work with. For more information see the venv documentation. Note: To exit the virtual environment at any time, just type deactivate. Pip install pygments # We'll be using this for the code highlighting Now that we're inside a virtual environment, we can install our package requirements. This will make sure our package configuration is kept nicely isolated from any other projects we're working on. The completed implementation is also online as a sandbox version for testing, available here.īefore we do anything else we'll create a new virtual environment, using venv. Note: The code for this tutorial is available in the encode/rest-framework-tutorial repository on GitHub. If you just want a quick overview, you should head over to the quickstart documentation instead. ![]() The tutorial is fairly in-depth, so you should probably get a cookie and a cup of your favorite brew before getting started. Along the way it will introduce the various components that make up REST framework, and give you a comprehensive understanding of how everything fits together. This tutorial will cover creating a simple pastebin code highlighting Web API. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |