Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Django Dev Environment Howto

Django Dev Environment Howto

The Comprehensive Guide to Setting up a Development Environment for Django Project. SlideShare entry here: http://www.slideshare.net/uranusjr/django-dev-envhowto

Tzu-ping Chung

November 06, 2013
Tweet

More Decks by Tzu-ping Chung

Other Decks in Programming

Transcript

  1. Topics • Choose your database (carefully) • Yes, when you

    develop • Construct a perfect Python dev machine • Linux • OS X
  2. Topics • Choose your database (carefully) • Yes, when you

    develop • Construct a perfect Python dev machine • Linux • OS X • Windows
  3. Topics • Choose your database (carefully) • Yes, when you

    develop • Construct a perfect Python dev machine • Other things
  4. Why? • Free as in Freedom • Recommended by dentists

    core developers • Data migration
  5. Engine Behaviour • A true story • Handling long strings

    • Type safety (if you use something raw) • Bugs on production machine are hard to find
  6. Data Migration • Fixtures do not represent your data completely

    • They are just JSON, after all • You can't rollback loaddata • ContentTypes
  7. SQLite Is (Still) Useful • Easy to wipe everything and

    start over • Quick 'n' dirty tests • Early stages during development
  8. But... • MySQL is okay • Even Oracle is okay

    if you don't care • MariaDB • Just use it
  9. Python • Anything over 2.7.0 should be enough • YUM

    is still based on 2.6... Oops. • Python 3 is coming…or not • Having both Python 2 and 3 installed on Windows can be a nightmare
  10. Virtualenv • pip install virtualenv • virtualenvwrapper • pip install

    virtualenvwrapper • pip install virtualenvwrapper-win • pip install virtualenvwrapper-powershell
  11. WUT? • setuptools = Python's package manager • Ever heard

    of distribute? • pip = Better easy_install alternative • virtualenv = Prevent Python lib pollution • virtualenvwrapper = Better virtualenv UI • Windows variants • Didi I hear somebody say APT?
  12. virtualenvwrapper • WORKON_HOME • Load the commands (if needed) •

    Commands • mkvirtualenv • workon • Read the docs
  13. Django and Friends • Always install packages inside virtualenv with

    pip • pip install django • pip install -r <requirement_file> • pip freeze
  14. PostgreSQL Libs (in C) • OS X • Installer or

    Homebrew • Linux • Your favourite package manager • Windows • Installer
  15. Build a C Extension • Get a C compiler •

    Install (or compile) library to bind with • Install CPython headers • apt-get install python-dev • pip install <binding_package>
  16. Build a C Extension • Get THE ONE TRUE C

    compiler • Install (or compile) library to bind with • Install CPython headers • apt-get install python-dev • pip install <binding_package>
  17. Get a Compiler • apt-get install build-essential • OK, I

    got lazy :p • Install Xcode and its "console tools" • Install Visual Studio (Express) • The "for Windows Desktop" version • Use the correct prompt
  18. I No Want C Compiler! • Pre-compiled binaries from the

    package manager • Pre-compiled binaries from the Web
  19. Words of Warning • Version mismatch • CPU Architecture mismatch

    (Windows sucks) • Security issue • Why pip doesn't offer binary installing
  20. From APT • apt-get install python-psycopg2 • What does it

    install? • http://packages.debian.org • .deb file is merely an ar archive • ln -s everything into $ENV/lib/site-packages
  21. Pre-Built Installer • http://www.lfd.uci.edu/~gohlke/pythonlibs/ • Simply a compressed archive (usually

    gzip) • Viewable with 7-Zip or similar • easy_install <installer_path> • Use where to make sure
  22. Miscellaneous • http://rudix.org has pre-built packages for OS X •

    I never used it, to be honest :p • RPM packages can be converted with rpm2cpio and then extracted with cpio • Actually you can use MinGW • Why? • If you really know what you're doing