Sunday, January 17, 2010

How to get bpython working with django for lazy people

bpython is a fancy interface to the Python interpreter for Unix-like operating systems (I hear it works fine on OS X). It is released under the MIT License.

There are many ways to get bpython working with django project you can find them by using google. But to use bpython with django isn't that complicated.
So, let's get it done.
  • If you're using Unix-like OS, you do have env.

    # In your project directory
    env DJANGO_SETTINGS_MODULE="settings" bpython

  • If the command you see above is too long and you are too lazy to do that.

    # In your project directory
    bpython -i validate

    bpython -i is used when we want to drop to bpython shell after running file instead of exiting, so that we can use bpython -i shell then Ctrl+D to get into bpython shell instead.

    # In your project directory
    bpython -i shell

    Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
    [GCC 4.4.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> # Then press (Ctrl+D).
    >>> # You will get bpython shell here.

No comments:

Post a Comment