Opened 9 years ago

Closed 8 years ago

#6654 closed (fixed)

django-admin.py startproject/startapp commands fixes

Reported by: Ivan Illarionov Owned by: Ivan Illarionov
Component: Core (Management commands) Version: master
Severity: Keywords: startproject startapp command
Cc: ivan.illarionov@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

django-admin.py startproject command can create projects with names that conflict with existing installed Python modules. I fixed this. See attached patch. It won't allow users accidentally block existing python modules or create several projects with the same name in different places and therefore prevent potential hard-to-diagnose bugs.

Attachments (4)

startproject.patch (1.3 KB) - added by Ivan Illarionov 9 years ago.
startproject command fix
startproject-7320.patch (1.3 KB) - added by Ivan Illarionov 9 years ago.
Updated to latest revision
startproject-startapp.patch (2.5 KB) - added by Ivan Illarionov 9 years ago.
startapp included
startproject-startapp.2.patch (2.3 KB) - added by Ivan Illarionov 9 years ago.
fixed startapp.py

Download all attachments as: .zip

Change History (12)

Changed 9 years ago by Ivan Illarionov

Attachment: startproject.patch added

startproject command fix

Changed 9 years ago by Ivan Illarionov

Attachment: startproject-7320.patch added

Updated to latest revision

comment:1 Changed 9 years ago by Ramiro Morales

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

This same problem was dealt at exactly that commit ([7320]) but in a slightly different way (it also checks importing a module with that name but additionally compares it against against the INVALID_PROJECT_NAMES list. Are you saying with your patch that the INVALID_PROJECT_NAMES test isn't necessary?. #6509 is similar but for startapp.

comment:2 in reply to:  1 ; Changed 9 years ago by Ivan Illarionov

Replying to ramiro:

This same problem was dealt at exactly that commit ([7320]) but in a slightly different way (it also checks importing a module with that name but additionally compares it against against the INVALID_PROJECT_NAMES list. Are you saying with your patch that the INVALID_PROJECT_NAMES test isn't necessary?. #6509 is similar but for startapp.
Yes, that's why I updated it. All names in INVALID_PROJECT_NAMES will be detected by import.

comment:3 in reply to:  2 Changed 9 years ago by Ivan Illarionov

Replying to i_i:

Replying to ramiro:

This same problem was dealt at exactly that commit ([7320]) but in a slightly different way (it also checks importing a module with that name but additionally compares it against against the INVALID_PROJECT_NAMES list. Are you saying with your patch that the INVALID_PROJECT_NAMES test isn't necessary?. #6509 is similar but for startapp.

Yes, that's why I updated it. All names in INVALID_PROJECT_NAMES will be detected by import.

Changed 9 years ago by Ivan Illarionov

Attachment: startproject-startapp.patch added

startapp included

comment:4 Changed 9 years ago by Ivan Illarionov

Comments:

  1. Names django, test and site will all be imported in the try/except/else clause and generate CommandError. This makes INVALID_PROJECT_NAMES test unnecessary.
  1. Ticket #6789 that was committed in 7320 is a duplicate of this ticket and deals with the same problem in a less efficient way.
  1. The fix for #6509 is also added.

Changed 9 years ago by Ivan Illarionov

fixed startapp.py

comment:5 Changed 9 years ago by Ivan Illarionov

Owner: changed from nobody to Ivan Illarionov

comment:6 Changed 9 years ago by Ivan Illarionov

Keywords: startapp added
Summary: django-admin.py startproject command enhancement/fixdjango-admin.py startproject/startapp commands fixes

comment:7 Changed 8 years ago by Simon Greenhill

Triage Stage: UnreviewedReady for checkin

comment:8 Changed 8 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [7652]) Fixed #6654 -- Slightly refactored the way 'startproject' and 'startapp' check for existing Python modules. Thanks, i_i

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