Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#24971 closed New feature (fixed)

Make startapp generate an apps.py

Reported by: Tim Graham Owned by: Mounir
Component: Core (Management commands) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I guess it might look like:

from django.apps import AppConfig

class AppnameConfig(AppConfig):
    name = 'appname'

and in __init__.py: default_app_config = 'appname.apps.AppnameConfig'

Change History (10)

comment:1 by Mounir, 10 years ago

Owner: changed from nobody to Mounir
Status: newassigned

comment:2 by Tim Graham, 10 years ago

Has patch: set
Patch needs improvement: set

I reviewed the PR.

comment:3 by Tim Graham, 10 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:4 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In e6dd7f99:

Fixed #24971 -- Made startapp generate an apps.py

comment:5 by James Beith, 9 years ago

I just tested this with Django 1.9rc1 and the default_app_config statement was not added to the __init__.py file, the file was blank.

I noticed this first in my own project but also in a blank test project.

Steps

  • Created a new Python 3.4 virtualenv
  • Installed Django 1.9rc1 via pip
  • Ran django-admin startproject mysite
  • Ran python manage.py startapp polls from within the project

Expected Behaviour

  • An apps.py file is created with appropriate content
  • An __init__.py file is created with appropriate default_app_config statement

Actual Behaviour

  • An apps.py file is created with appropriate content
  • An __init__.py file is created but no default_app_config statement is included, the file is blank

comment:6 by Tim Graham, 9 years ago

That's intentional, see #25356.

comment:7 by Tim Graham, 9 years ago

That said, how about a small enhancement to the 1.9 release notes to clarify the expected behavior?

comment:8 by James Beith, 9 years ago

Yeah I think so. Especially if using default_app_config is discouraged, I wasn't aware of this.

comment:9 by Tim Graham <timograham@…>, 9 years ago

In 6258e163:

Refs #24971, #25356 -- Clarified how apps.py works in 1.9 release notes.

comment:10 by Tim Graham <timograham@…>, 9 years ago

In 7bbfc43e:

[1.9.x] Refs #24971, #25356 -- Clarified how apps.py works in 1.9 release notes.

Backport of 6258e163352690faf20bfc92c12468316d1a47ae from master

Note: See TracTickets for help on using tickets.
Back to Top