48đź‘Ť
The built-in solution for re-naming Django projects in PyCharm has worked for me in the past on small projects, although I haven’t tried it on a large project yet. To use it, select the project folder from the file-tree (by default on the left hand side of the screen), then press shift-F6 to bring up the rename dialogue. You can enter in your new name here and preview the changes, which can help prevent surprises. If you’re happy with the preview, click on the “Do Refactor” button at the bottom of the window.
This is also a useful way to rename Django apps.
You can access the same functionality through right-clicking on the folder/item and hovering over the Refactor sub-menu. Or pressing ctrl+shift+a and searching for rename
.
12đź‘Ť
I’m using Windows, but it’s probably the same for other operating systems.
- Close PyCharm, open the directory in Windows Explorer (or your favorite file manager).
- Rename the project directory.
- Rename the subdirectory of the same name that is inside your project directory.
- Open the
.idea
directory (in the project folder), rename the.iml
file. - Also in the
.idea
directory, open the.name
file in a text editor and change the name in there. - Open the project in PyCharm again.
- In the
settings.py
file, you’ll need to update the path specified inTEMPLATE_DIRS
.
You may also want to update your Run/Debug configurations (Alt+Shift+F10).
You’ll need to replace some other occurrences of your old project name. In PyCharm, Ctrl+Shift+F will allow you to search the contents of all your files to find these occurrences.
- [Django]-How can I programmatically obtain the max_length of a Django model field?
- [Django]-Django admin – inline inlines (or, three model editing at once)
- [Django]-Django – The included urlconf doesn't have any patterns in it
10đź‘Ť
Maybe: right-click on root folder in “Project” window, choose Refactoring -> Rename and choose “Rename Project”
- [Django]-Why don't my south migrations work?
- [Django]-Setting default value for Foreign Key attribute in Django
- [Django]-Django – Model graphic representation (ERD)
3đź‘Ť
svass’s answer worked for me, except that I also had to manually change instances of my old project name in files located inside the .idea directory of my project.
If you cd into your project directory and grep for your old project name
grep -rli oldprojectname ./.idea
That returned the following list for me, then I manually modified each file.
./.idea/modules.xml
./.idea/workspace.xml
./.idea/dataSources.xml
./.idea/oldprojectname.iml <-- this will need to be renamed to new project name, and it's contents modified
./.idea/dataSources.ids
./.idea/.name
./.idea/misc.xml
- [Django]-Django.db.utils.OperationalError Could not connect to server
- [Django]-Disable button after submit with jQuery
- [Django]-How to do a multi-step form in Django?