Adding a new django rest framework application to settings

I am learning this lesson: http://www.django-rest-framework.org/tutorial/1-serialization/ , and there is one thing that I don’t understand a bit. They do python manage.py startapp snippetsand add 'snippets.apps.SnippetsConfig'in INSTALLED_APPS. Why is this and not 'snippets'? When I launch a new application, a package is created apps, and neither WhateverConfig.

+4
source share
1 answer

If you are using djagno1.9 below, just add snippets. In older versions of django startapp, the management team will not create apps.py. you need to create a new apps.py.

> Django 1.9 apps.py startapp

(env) simple: python manage.py startapp snippets
(env) simple: find snippets 
snippets
snippets/models.py
snippets/tests.py
snippets/views.py
snippets/admin.py
snippets/__init__.py
snippets/apps.py   # your apps.py
snippets/migrations
snippets/migrations/__init__.py

(env) simple: cat snippets/apps.py 
from __future__ import unicode_literals

from django.apps import AppConfig


class SnippetsConfig(AppConfig):
    name = 'snippets'

Rest-Framework, Django 1.9. django 1.9 GitHub

apps.py django 1.9

+3

All Articles