I installed virtualenvwrapper on ubuntu. I added the following lines to the top of bashrc file:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/myprojects
source /usr/local/bin/virtualenvwrapper.sh
everething works perfect except that when I use django-admin start project command, the project gets created in my home directory not the directory I specified in bashrc file which is myprojects.
shouldn't new projects be created in myprojects folder?
thanks in advance.
I assume you're running django-admin startproject in your home folder? django-admin doesn't know anything about virtualenvwrapper and, unless you explicitly specify a folder, it creates the project in the current folder. See https://docs.djangoproject.com/en/dev/ref/django-admin/#startproject-projectname-destination
Related
I have set environment variable to python27/Scripts. I am able to create project by
Scrapy startproject fund
So a project fund is created. Now I go inside the directory of fund where configure file is present and here scrapy is not recognised. Say I want to generate a spider or crawl it it does not work? Please advise on how to correct this problem.
I don't know if you are working with Anaconda, but if you are, than you might have to activate the virtual environment.
open: Anaconda prompt
Write: activate [insert name of your virtual environment]
cd to the place where you want to start your project (so for example cd desktop)
write: scrapy startproject [NameOfYourProject]
After upgrading to django 1.9 and tried creating new project.Getting following error
How should i solve this?
After upgrading to django 1.9 and creating new project following error occurred
CommandError: /home/shaastr/ehgg/manage.py already exists, overlaying a project or app into an existing directory won't replace conflicting files
I think you have 2 versions of django installed, and both are being called when trying to start the project.
Try running pip uninstall django twice, if it runs both time then this was what was going on. Obviously, pip install django afterwards to get it working again
I had the same problem after using pip to install django 1.10 over an older version.
I used pip to uninstall and manually deleted the leftover django folder in the site-packages folder.
re-installed using pip, and now it is working with no problem.
I am also working with docker containers. I had this problem where it said that manage.py already exists in the workdirectory (that I made through the Dockerfile file) when I tried to restart the process of making a container after deleting the old one.
It did not show me where the workdirectory was made and hence could not delete the manage.py as pointed out in the error.
The solution that worked was I changed the service name in my yml file and gave the command with new servicenm
docker-compose run servicenm django-admin.py startproject projectnm directory
remove manage.py then re-run your django-admin startproject command, it will work
Make sure that if you have deleted (rm -r) "your Django project_name" to also delete (rm) the manage.py corresponding deleted project python file in the same repository.
sudo pip uninstall django
sudo rm /usr/local/lib/python2.7/dist-packages/django/ -rf
sudo pip install django==1.10
This resolved my problem.
You need to define another directory for your new project. Not /ehgg directory.
It seems though you are creating a new project inside your old project.
And this error clearly state that, there is old setting i.e "manage.py" for your old project. Since every time a new settings manage.py created for your new project.
I hope it's clear to you.
Thank you.
Check whether the project name is correct or not. Django avoids
hypens (-) in project names.
It can happen due to two reasons:
You are trying to create a new folder with the exiting folder name.
You have previously deleted a folder with this name. Deleted it for some reason. But again trying to create package with this name.
To resolve this follow
Rename the manage.py from your project folder.
Go to <%System Path%>/PycharmProjects/<%Your Project Name%>/.idea/workspace.xml
edit this file "workspace.xml" and then search with the package name you are trying to create.
delete that line and save the file.
Now try to run the command again.
I hope this helps.
Regards,
I've just installed django and I'm having trouble creating a project.
Running django-admin.py startproject test_project returns:
CommandError: '/usr/local/mysql-5.6.13-osx10.7-x86_64/docs/test_project' already exists
I also looked in the path above and there is no test_project folder.
Anybody come across this one?
EDIT
I restarted the terminal and tried again. The error has disappears but it doesn't seem to be creating the test_project folder on my desktop.
You seem to have found your solution through gersande's comment (update your question if you haven't with the new problem); so I'm just going to formalize it here:
I restarted the terminal and tried again. The error has disappears but it doesn't seem to be creating the test_project folder on my desktop.
I'm not sure why restarting the terminal helped (and it's probably a heisenbug), but I do notice an incongruence in your question: you've (seemingly, as the command isn't outputting any errors; but you could confirm by checking if running echo $? is 0 right after) created you new Django project directory in /usr/local/mysql-5.6.13-osx10.7-x86_64/docs/, but you seem to be looking for it on your Desktop (which is mapped to a different folder, probably ~/Desktop.
Simply navigate to the above path in your file explorer, or run cd <directory> to view it in your terminal.
I'm very new to Heroku and I've just pushed my Django app into Heroku. Does anyone know how to create a 'log' directory under '/app'? Is /app the top directory of my app?
Thanks
Is the log directory in your .gitignore file? If /log is an unversioned directory then K Z's answer should help regarding Heroku; unless something else is going on with Heroku and the log directory in your repo.
Regarding committing an empty directory
You cannot commit empty directories to git, but you can add a .gitignore file in a directory that ignores all files inside except itself. This would be as close as you can get to versioning an empty directory as I'm sure you don't want to version control your log files.
Make sure the log directory is not in your main .gitignore file. Then in your log directory create a new .gitignore that contains the following:
# Ignore everything in this directory
*
# Except this file
!.gitignore
You can check out Jamie Flournoy's answer here How can I add an empty directory to a Git repository?
To create a new directory you can simply create one in your local directory (i.e., cd app; mkdir log then commit & push to Heroku.
Whether /app is the top directory or not depends on your directory structure, normally it is the name of the app on Heroku that's set as the top directory. Though, if you are inside your git repository that's used for your Heroku app, you can find the root directory by:
git rev-parse --show-toplevel
which is a git command that tells you the top level directory of this git directory.
I'm new to Django, and I can't figure out why my app isn't loading. I've created all the files: models.py, views.py, urs.py with default code in. But when I run python manage.py runserver, it says the following:
Error: No module named app_name
What am I doing wrong?
Did you remember to include __init__.py in your folder?
If you did, make sure the permissions on the file are also correct. There's also a similar question here.
Just an additional hint: Instead of manually creating the files you can use django-admin.py startapp APPNAME to automatically create a directory with all necessary files for a new app.
I got your point the init file thing also dosen't work out for me as well. Just ensure that are you writing the proper command inside the proper directory while creating the app, using the terminal.
Like while writing the command "django-admin startapp APP_NAME", ensure that the command is written inside your root configuration directory (which gets created after you typein command "django-admin startproject PROJECT-NAME"), not anywhere else. Then mention the app name inside the settings.py file, under the INSTALLED_APPS[ ] list. Then finally run the command "python manage.py runserver" in the same root configuration directory. I assure you, this will work for sure and the "No modules found" thing will disappear. Have a try and tell me if it don't. Thank you.