Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save BharathKumarRavichandran/acd0bccdb88ed7dbcde475e0306ef5f9 to your computer and use it in GitHub Desktop.

Select an option

Save BharathKumarRavichandran/acd0bccdb88ed7dbcde475e0306ef5f9 to your computer and use it in GitHub Desktop.

Revisions

  1. @bradtraversy bradtraversy revised this gist Oct 2, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion django_cheat_sheet.md
    Original file line number Diff line number Diff line change
    @@ -59,7 +59,7 @@ python manage.py start app APPNAME
    python manage.py makemigrations
    ```

    ### Run migrattion
    ### Run migration
    ```
    python manage.py migrate
    ```
  2. @bradtraversy bradtraversy revised this gist Oct 1, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions django_cheat_sheet.md
    Original file line number Diff line number Diff line change
    @@ -13,10 +13,10 @@ python -m venv ./venv

    ```
    # Mac/Linux
    source venv/bin/activate
    source ./venv/bin/activate
    # Windows
    venv\Scripts\activate.bat - May need to add full path
    venv\Scripts\activate.bat - May need to add full path (c:\users\....venv\Scripts\activate.bat)
    ```

    ### Escape from venv
  3. @bradtraversy bradtraversy created this gist Oct 1, 2018.
    70 changes: 70 additions & 0 deletions django_cheat_sheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    # Django 2.x Cheat Sheet

    ### Creating a virtual environment

    We need to create a virtual env for our app to run in: [More Here](https://docs.python.org/3/library/venv.html)
    Run this command in whatever folder you want to create your venv folder

    ```
    python -m venv ./venv
    ```

    ### Activate the virtualenv

    ```
    # Mac/Linux
    source venv/bin/activate
    # Windows
    venv\Scripts\activate.bat - May need to add full path
    ```

    ### Escape from venv

    ```
    deactivate
    ```

    ### Check packages installed in that venv

    ```
    pip freeze
    ```

    ### Install Django

    ```
    pip install django
    ```

    ### Create your project

    ```
    django-admin startproject PROJECTNAME
    ```

    ### Run Server (http://127.0.0.1:8000) CTRL+C to stop

    ```
    python manage.py runserver
    ```

    ### Create an app
    ```
    python manage.py start app APPNAME
    ```

    ### Create migrations
    ```
    python manage.py makemigrations
    ```

    ### Run migrattion
    ```
    python manage.py migrate
    ```

    ### Collect Static Files
    ```
    python manage.py collectstatic
    ```