How do I redirect Django commands using PyDev?
I would like to run the following Django command (to dump the contents of my database into a text file):
pyth开发者_Python百科on manage.py dumpdata my_app > data.json
I'm using the Django framework within PyDev as an Eclipse plugin. Therefore, in order to run the above command in PyDev I go to "Custom command" and insert dumpdata my_app > data.json
. However, doing so results in an error because of the >
character:
Error: Unknown application: >
How can I use >
(redirection) in PyDev?
- Open Eclipse and go to menu Run > Run configurations
- Click on Pydev Django and then the "New" icon to create a new launch configuration
- Tab main: select the project and main module (
manage.py
) - Tab interpreter: select which interpreter will run manage.py
- Tab arguments: write
dumpdata my_app
in Program arguments - Tab common: check File in "Standard input and Output" and set your output location and filename. Uncheck "Allocate console".
Finally click on Apply and Run. A bit tricky but works as it should.
精彩评论