2016-01-06 05:21:55 +00:00
#+TITLE : Django layer
2015-11-08 18:04:44 +00:00
2019-05-07 08:21:07 +00:00
#+TAGS : framework|layer|programming
2019-05-02 21:49:30 +00:00
2015-07-04 03:52:33 +00:00
[[file:img/django.png ]]
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description ][Description ]]
2018-01-28 19:58:25 +00:00
- [[#features ][Features: ]]
2017-05-22 14:16:12 +00:00
- [[#install ][Install ]]
2018-12-05 03:03:03 +00:00
- [[#key-bindings ][Key bindings ]]
2018-01-28 19:58:25 +00:00
- [[#general-managment ][General Managment ]]
2017-05-22 14:16:12 +00:00
- [[#fabric ][Fabric ]]
- [[#files ][Files ]]
- [[#interactive ][Interactive ]]
- [[#server ][Server ]]
- [[#southsyncdb ][South/Syncdb ]]
- [[#test ][Test ]]
2015-07-04 03:52:33 +00:00
* Description
2018-01-28 19:58:25 +00:00
This layer adds support for the Python web framework [[https://www.djangoproject.com/ ][Django ]] to Spacemacs.
** Features:
- Test execution directly from emacs
- Starting/stopping of the Django test server
- Starting of an interactive Python shell in the current project for debugging
- Fixed commands to open various Django specific settings files
- Automatic deployment with [[http://www.fabfile.org ][Fabric ]] directly from emacs
- Control of [[http://south.aeracode.org/ ][South ]] database migration tool
2015-07-04 03:52:33 +00:00
* Install
2016-01-06 05:21:55 +00:00
To use this configuration layer, add it to your =~/.spacemacs= . You will need to
add =django= to the existing =dotspacemacs-configuration-layers= list in this
file.
2015-07-04 03:52:33 +00:00
2018-12-05 03:03:03 +00:00
* Key bindings
2018-01-28 19:58:25 +00:00
Django related key bindings uses [[https://github.com/davidmiller/pony-mode ][pony-mode ]] and are behind the prefix ~SPC m j~ in =Python-mode= .
Various configuration options for =pony-mode= are documented at [[http://www.deadpansincerity.com/docs/pony/configuration.html ][deadpansincerity.com ]].
2015-07-04 03:52:33 +00:00
2018-01-28 19:58:25 +00:00
** General Managment
2015-07-04 03:52:33 +00:00
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2018-01-28 19:58:25 +00:00
|-------------+---------------------------------------|
| ~SPC m j m~ | Start a =pony-mode= managment session |
2015-07-04 03:52:33 +00:00
** Fabric
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-04 03:52:33 +00:00
|---------------+----------------------------------|
| ~SPC m j a f~ | Run a fabric command |
| ~SPC m j a d~ | Deploy project with =fab deploy= |
** Files
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-04 03:52:33 +00:00
|---------------+---------------------------------------------------------------|
| ~SPC m j f s~ | Open the =settings.py= for this project |
| ~SPC m j f c~ | Interactively display a setting value in the minibuffer |
| ~SPC m j f t~ | Jump to template at point |
| ~SPC m j f r~ | Jump to the view file that the URL resolves to (experimental) |
** Interactive
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2018-01-28 19:58:25 +00:00
|---------------+----------------------------------------------------------------------------|
2019-05-26 20:58:52 +00:00
| ~SPC m j i d~ | Run interpreter for this project's default database as an inferior process |
| ~SPC m j i s~ | Open a Python shell with the current pony project's context loaded. |
2018-01-28 19:58:25 +00:00
| | If the project has the django_extras package installed, then use the |
| | excellent =shell_plus= command. Otherwise, fall back to =manage.py shell= |
2015-07-04 03:52:33 +00:00
** Server
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-04 03:52:33 +00:00
|---------------+-------------------------------------------------------------------|
| ~SPC m j r d~ | Stop the dev server |
| ~SPC m j r o~ | Open a tab at the dev server |
| ~SPC m j r r~ | Restart the dev server (works better with django_extras/werkzeug) |
| ~SPC m j r u~ | Start or open the dev server |
2019-05-26 20:58:52 +00:00
| ~SPC m j r t~ | Open a second server with a "throwaway" host/port |
2015-07-04 03:52:33 +00:00
** South/Syncdb
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-04 03:52:33 +00:00
|---------------+--------------------------------------------|
| ~SPC m j s c~ | Convert an existing app to south |
| ~SPC m j s h~ | Create migration for modification |
| ~SPC m j s i~ | Run the initial south migration for an app |
| ~SPC m j s m~ | Migrate an app |
| ~SPC m j s s~ | Run syncdb on the current project |
** Test
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2015-07-04 03:52:33 +00:00
|---------------+------------------------------------------------------------------|
| ~SPC m j t d~ | Move down the traceback one level |
| ~SPC m j t e~ | Go to the file and line of the last stack trace in a test buffer |
| ~SPC m j t o~ | Open the file in a traceback at the line specified |
| ~SPC m j t t~ | Run the test(s) given by =command= |
| ~SPC m j t u~ | Move up the traceback one level |