|
1 |
| -# boilerplate-code-django |
| 1 | +# [Django Boilerplate](https://appseed.us/boilerplate-code/django-boilerplate/) |
| 2 | + |
| 3 | +Reference codebase used by `AppSeed` in all Django [Apps](https://appseed.us/apps/django/) and [Dashboard](https://appseed.us/admin-dashboards/django/) starters - the product uses an amazing design crafted by `Creative-Tim`. |
| 4 | + |
| 5 | +- 👉 [Django Boilerplate](https://appseed.us/boilerplate-code/django-boilerplate/) - `Product page` |
| 6 | +- 👉 [Django Boilerplate](https://django-material-kit.appseed-srv1.com/) - `LIVE Demo` |
| 7 | +- 👉 Free [Support](https://appseed.us/support/) via `Email` & `Discord` |
| 8 | + |
| 9 | +<br /> |
| 10 | + |
| 11 | +> Features: |
| 12 | +
|
| 13 | +- ✅ `Up-to-date Dependencies` |
| 14 | +- ✅ Theme: [Django Theme Material Kit](https://github.com/app-generator/django-theme-material-kit), **designed by [Creative-Tim](https://www.creative-tim.com/product/material-kit?AFFILIATE=128200)** |
| 15 | +- ✅ **Authentication**: `Django.contrib.AUTH`, Registration |
| 16 | +- 🚀 `Deployment` |
| 17 | + - `CI/CD` flow via `Render` |
| 18 | + |
| 19 | +<br /> |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +<br /> |
| 24 | + |
| 25 | +## Start with `Docker` |
| 26 | + |
| 27 | +> 👉 **Step 1** - Download the code from the GH repository (using `GIT`) |
| 28 | +
|
| 29 | +```bash |
| 30 | +$ git clone https://github.com/app-generator/boilerplate-code-django.git |
| 31 | +$ cd boilerplate-code-django |
| 32 | +``` |
| 33 | + |
| 34 | +<br /> |
| 35 | + |
| 36 | +> 👉 **Step 2** - Start the APP in `Docker` |
| 37 | +
|
| 38 | +```bash |
| 39 | +$ docker-compose up --build |
| 40 | +``` |
| 41 | + |
| 42 | +Visit `http://localhost:5085` in your browser. The app should be up & running. |
| 43 | + |
| 44 | +<br /> |
| 45 | + |
| 46 | +## Manual Build |
| 47 | + |
| 48 | +> 👉 Download the code |
| 49 | +
|
| 50 | +```bash |
| 51 | +$ git clone https://github.com/app-generator/boilerplate-code-django.git |
| 52 | +$ cd boilerplate-code-django |
| 53 | +``` |
| 54 | + |
| 55 | +<br /> |
| 56 | + |
| 57 | +> 👉 Install modules via `VENV` |
| 58 | +
|
| 59 | +```bash |
| 60 | +$ virtualenv env |
| 61 | +$ source env/bin/activate |
| 62 | +$ pip install -r requirements.txt |
| 63 | +``` |
| 64 | + |
| 65 | +<br /> |
| 66 | + |
| 67 | +> 👉 Set Up Database |
| 68 | +
|
| 69 | +```bash |
| 70 | +$ python manage.py makemigrations |
| 71 | +$ python manage.py migrate |
| 72 | +``` |
| 73 | + |
| 74 | +<br /> |
| 75 | + |
| 76 | +> 👉 Create the Superuser |
| 77 | +
|
| 78 | +```bash |
| 79 | +$ python manage.py createsuperuser |
| 80 | +``` |
| 81 | + |
| 82 | +<br /> |
| 83 | + |
| 84 | +> 👉 Start the app |
| 85 | +
|
| 86 | +```bash |
| 87 | +$ python manage.py runserver |
| 88 | +``` |
| 89 | + |
| 90 | +At this point, the app runs at `http://127.0.0.1:8000/`. |
| 91 | + |
| 92 | +<br /> |
| 93 | + |
| 94 | +## Codebase structure |
| 95 | + |
| 96 | +The project is coded using a simple and intuitive structure presented below: |
| 97 | + |
| 98 | +```bash |
| 99 | +< PROJECT ROOT > |
| 100 | + | |
| 101 | + |-- core/ |
| 102 | + | |-- settings.py # Project Configuration |
| 103 | + | |-- urls.py # Project Routing |
| 104 | + | |
| 105 | + |-- home/ |
| 106 | + | |-- views.py # APP Views |
| 107 | + | |-- urls.py # APP Routing |
| 108 | + | |-- models.py # APP Models |
| 109 | + | |-- tests.py # Tests |
| 110 | + | |-- templates/ # Theme Customisation |
| 111 | + | |-- pages # |
| 112 | + | |-- custom-index.html # Custom Footer |
| 113 | + | |
| 114 | + |-- requirements.txt # Project Dependencies |
| 115 | + | |
| 116 | + |-- env.sample # ENV Configuration (default values) |
| 117 | + |-- manage.py # Start the app - Django default start script |
| 118 | + | |
| 119 | + |-- ************************************************************************ |
| 120 | +``` |
| 121 | + |
| 122 | +<br /> |
| 123 | + |
| 124 | +## How to Customize |
| 125 | + |
| 126 | +When a template file is loaded, `Django` scans all template directories starting from the ones defined by the user, and returns the first match or an error in case the template is not found. |
| 127 | +The theme used to style this starter provides the following files: |
| 128 | + |
| 129 | +```bash |
| 130 | +# This exists in ENV: LIB/theme_material_kit |
| 131 | +< UI_LIBRARY_ROOT > |
| 132 | + | |
| 133 | + |-- templates/ # Root Templates Folder |
| 134 | + | | |
| 135 | + | |-- accounts/ |
| 136 | + | | |-- sign-in.html # Sign IN Page |
| 137 | + | | |-- sign-up.html # Sign UP Page |
| 138 | + | | |
| 139 | + | |-- includes/ |
| 140 | + | | |-- footer.html # Footer component |
| 141 | + | | |-- navigation.html # Navigation Bar |
| 142 | + | | |-- scripts.html # Scripts Component |
| 143 | + | | |
| 144 | + | |-- layouts/ |
| 145 | + | | |-- base.html # Masterpage |
| 146 | + | | |
| 147 | + | |-- pages/ |
| 148 | + | |-- index.html # Dashboard Page |
| 149 | + | |-- author.html # Profile Page |
| 150 | + | |-- *.html # All other pages |
| 151 | + | |
| 152 | + |-- ************************************************************************ |
| 153 | +``` |
| 154 | + |
| 155 | +When the project requires customization, we need to copy the original file that needs an update (from the virtual environment) and place it in the template folder using the same path. |
| 156 | + |
| 157 | +> For instance, if we want to **customize the index.html** these are the steps: |
| 158 | +
|
| 159 | +- ✅ `Step 1`: create the `templates` DIRECTORY inside the `home` app |
| 160 | +- ✅ `Step 2`: configure the project to use this new template directory |
| 161 | + - `core/settings.py` TEMPLATES section |
| 162 | +- ✅ `Step 3`: copy the `index.html` from the original location (inside your ENV) and save it to the `home/templates` DIR |
| 163 | + - Source PATH: `<YOUR_ENV>/LIB/theme_material_kit/template/pages/index.html` |
| 164 | + - Destination PATH: `<PROJECT_ROOT>home/templates/pages/index.html` |
| 165 | + |
| 166 | +> To speed up all these steps, the **codebase is already configured** (`Steps 1, and 2`) and a `custom index` can be found at this location: |
| 167 | +
|
| 168 | +`home/templates/pages/custom-index.html` |
| 169 | + |
| 170 | +By default, this file is unused because the `theme` expects `index.html` (without the `custom-` prefix). |
| 171 | + |
| 172 | +In order to use it, simply rename it to `index.html`. Like this, the default version shipped in the library is ignored by Django. |
| 173 | + |
| 174 | +In a similar way, all other files and components can be customized easily. |
| 175 | + |
| 176 | +<br /> |
| 177 | + |
| 178 | +## Deploy on [Render](https://render.com/) |
| 179 | + |
| 180 | +- Create a Blueprint instance |
| 181 | + - Go to https://dashboard.render.com/blueprints this link. |
| 182 | +- Click `New Blueprint Instance` button. |
| 183 | +- Connect your `repo` which you want to deploy. |
| 184 | +- Fill the `Service Group Name` and click on `Update Existing Resources` button. |
| 185 | +- After that your deployment will start automatically. |
| 186 | + |
| 187 | +At this point, the product should be LIVE. |
| 188 | + |
| 189 | +<br /> |
| 190 | + |
| 191 | +--- |
| 192 | +[Django Boilerplate](https://appseed.us/boilerplate-code/django-boilerplate/) - **Django** Starter provided by **[AppSeed](https://appseed.us/)** |
0 commit comments