Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#33890 closed Bug (invalid)

call_command('startproject', 'project_name', '.') raises CommandError 'project_name' — at Version 2

Reported by: piscvau Owned by: nobody
Component: Core (Management commands) Version: 4.0
Severity: Normal Keywords: call_command raises exception
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by piscvau)

call_command ('startproject', 'project_name', '.') shoud create a project named 'project_name' in the current directory.

to reproduce the bug :
from django.core import management
from pathlib import Path
project_name = Path.cwd().stem
management.call_command('startproject', project_name, '.')

This raises the exception

django.core.management.base.CommandError: <project_name> conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name.

This is because the initial directory of the python script is in sys.module.

When called from the command line, in the exact same condition, the command passes :

in directory project_name :

django-admin startproject project-name .

in django docs it is described as the right usage to create a project project_name in the current directory!....

SO I do believe this is a bug!.....

Change History (2)

comment:1 by Mariusz Felisiak, 22 months ago

Resolution: invalid
Status: newclosed

This is not a bug in Django but in your code. You cannot create project with the name of an existing Python module (as is explained in the error message). If you're having trouble understanding how Django works, see TicketClosingReasons/UseSupportChannels for ways to get help.

comment:2 by piscvau, 22 months ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top