1

I run Django through a Python 3.4 virtualenv and I want to make some cronjob scripts that will access models and save.

I can do this through the Django shell python manage.py shell will initiate the Django shell. From there I can do from polls.models import Poll, Choice and make a new Poll and save it into the DB.

How can I do this through the regular Python shell?

1 Answer 1

3

Your best bet is probably to create a management command. You can run it from the command line by calling (python manage.py ) and from within the script you can access any django functions or models.

For further instructions on how see here https://docs.djangoproject.com/en/dev/howto/custom-management-commands/

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome. Just what I was looking for. Didn't even know you can do this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.