Trying to run a management command with no success.
Was getting an error in terminal ImportError, and in my IDE it would not resolve the models.
I found the answer and the issue was that I was not running the management command via manage.py.
The error in terminal would come up when running
../management/commands$ python import_puzzle.py
Instead of calling the management command directly from it's folder. You should run it from the src folder using manage.py:
`../src$ python manage.py import_puzzle`
The reason is that import_puzzle is actually a management command and must be called using the manage.py. I'm too much of a beginner to elaborate any further! :)
Related
if i run
(My_Virtual_Env) G:\My-Project\My_Code>python ..\My_Virtual_Env\Scripts\django-admin.py startproject My_django_project
its working fine and new project is getting created.
But when i run
(My_Virtual_Env) G:\My-Project\My_Code>django-admin.py startproject My_django_project
am getting error
ImportError: No module named django.core
i want to know why it is happening ? and what are the changes need to do to run second command as it is ?
The My_Virtual_Env/Scripts folder is not added to the classpath by default. That is why you get that error. If you install django, the directory of this will directly be added to classpath. Why do you execute from another place?
I've been working with the PaaS service AppFog and I was able to get my Django up and running, but the problem is that my application uses static files and this are not working because it needs to execute the collectstatic command in shell.
I've been reading about it on the internet but I wasn't able to find a proper solution. Should I make a shell file and execute it? How?
I appreciate your time.
You can execute collectstatic with the following command:
python manage.py collectstatic
This is called an administrative management command. You can find out more about these and implementing them yourself by reading https://docs.djangoproject.com/en/1.4/howto/custom-management-commands/.
On my project i have an app : my_app with Managment command : my_command.py
On SSH i try :
my/folder/project/and/app/python2.4 manage.py my_command all is ok
but if i try : python2.4 /my/folder/project/and/app/manage.py my_command, manage.py doesn't know my command...
i try to run my command on a crontab..
Thx
laurent
In my experience I had this kind of issues for several reasons.
I'd check first the python interpreter used. If you are using virtualenv or something like that you should ensure you are using the correct python executable.
If your server has selinux, you should ensure it's not denying the cron to read some files.
I also had an issue like this because the settings file (I used a separate setting file to make it less verbose) didn't exist.
On my local machine (Mac OSX 10.6) I wrote a django custom admin command which works great. I can use it both within and outside my project directory just fine. For some reason on my CentOS 5.6 server, it won't work from outside the project directory. This is really annoying since using this custom admin command in a cron job requires it to run from the home directory.
in short:
When I run "python ./manage.py scrape" or "python manage.py scrape", everything is fine.
When I run "python /home/[username]/webapps/myproject/manage.py scrape" or "python myproject/manage.py scrape", I get the following error:
unknown command: 'scrape'
Type 'manage.py help' for usage.
On CentOS, when I run manage.py help inside the project directory, scrape shows up as a command; but if I run it outside the project directory, scrape does not appear as a valid command. On OS-X scrape appears as a valid command regardless of where I run manage.py help from.
Any idea how I can fix this?
I know CentOS ships with Python 2.4, so is your code running on 2.4 or are you using a contained environment, this is usually fixed by adding your PYTHONPATH correctly
import sys
print sys.path
verify such for starters
This should get you up and running: http://djangosnippets.org/snippets/374/
This is blowing my mind because it's probably an easy solution, but I can't figure out what could be causing this.
So I have a new dev box and am setting everything up. I installed virtualenv, created a new environment for my project under ~/.virtualenvs/projectname
Then, I cloned my project from github into my projects directory. Nothing fancy here. There are no .pyc files sitting around so it's a clean slate of code.
Then, I activated my virtualenv and installed Django via pip. All looks good so far.
Then, I run python manage.py syncdb within my project dir. This is where I get confused:
ImportError: No module named projectname
So I figured I may have had some references of projectname within my code. So I grep (ack, actually) through my code base and I find nothing of the sorts.
So now I'm at a loss, given this environment why am I getting an ImportError on a module named projectname that isn't referenced anywhere in my code?
I look forward to a solution .. thanks guys!
Is projectname exactly (modulo suffix) the name of the directory the project is in? Wild guess, but I know Django does some things with the current directory…
Also, what is trying to import projectname? Do you get a traceback? If not, try running with py manage.py --traceback syncdb and see what happens.