0

I'm new to python and didn't use django before. I want to run the Django REST framework quickstart tutorial so I can use it for testing another application (http://django-rest-framework.org/tutorial/quickstart.html).

I ran in two issues:

1) I'm confused at the "Settings" step, I don't know what file is the listing suposed to be in. (I pasted the contents in urls.py, then I tried with a settings.py in the same folder as the other files.)

2) Just before the "Testing our API" section, I don't know the command to launch the project. (I tried "python urls.py" because url has references to the other files.)

Thank you.

0

2 Answers 2

2

Before you start using the django-rest-framework, you may want to learn more about django itself, so try the django tutorial.

https://docs.djangoproject.com/en/dev/intro/tutorial01/

About your question: when you start a project in django, it contains a settings.py.

Inside this file you have to edit the INSTALLED_APPS Tuple adding 'rest_framework,' in the end of it (one line before ")") and putting

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAdminUser',),
    'PAGINATE_BY': 10
}

in the end of the file.

To launch the project you have to sync the database first, so do python manage.py syncdb, and once you did this call python manage.py runserver

Sign up to request clarification or add additional context in comments.

2 Comments

I can second this notion...the Django REST Framework tutorial ONLY makes sense if you are comfortable with Django. You need to have built the tutorial polls app before you can even begin to understand the Django REST framework tutorial.
Closing question as I gave up on using django for now, and this reply was the most helpful.
0
  1. settings.py obviously
  2. python manage.py runserver

urls.py is an important file that manages the mapping of urls to the executables, but it's not an entry point to the django. manage.py provides tons of functionality and even able to run development server for you. In short, read the manual :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.