Opened 8 years ago

Closed 7 years ago

#6654 closed (fixed)

django-admin.py startproject/startapp commands fixes

Reported by: i_i Owned by: i_i
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 i_i 8 years ago.
startproject command fix
startproject-7320.patch (1.3 KB) - added by i_i 7 years ago.
Updated to latest revision
startproject-startapp.patch (2.5 KB) - added by i_i 7 years ago.
startapp included
startproject-startapp.2.patch (2.3 KB) - added by i_i 7 years ago.
fixed startapp.py

Download all attachments as: .zip

Change History (12)

Changed 8 years ago by i_i

startproject command fix

Changed 7 years ago by i_i

Updated to latest revision

comment:1 follow-up: Changed 7 years ago by ramiro

  • 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 ; follow-up: Changed 7 years ago by 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.

comment:3 in reply to: ↑ 2 Changed 7 years ago by i_i

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 7 years ago by i_i

startapp included

comment:4 Changed 7 years ago by i_i

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 7 years ago by i_i

fixed startapp.py

comment:5 Changed 7 years ago by i_i

  • Owner changed from nobody to i_i

comment:6 Changed 7 years ago by i_i

  • Keywords startapp added
  • Summary changed from django-admin.py startproject command enhancement/fix to django-admin.py startproject/startapp commands fixes

comment:7 Changed 7 years ago by Simon Greenhill

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:8 Changed 7 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(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