A batteries-included Django starter project. For a production-ready version see the book Django for Professionals.
- Django 3.1 & Python 3.8
- Install via Pip, Pipenv, or Docker
- User log in/out, sign up, password reset via django-allauth
- Static files configured with Whitenoise
- Styling with Bootstrap v4
- Debugging with django-debug-toolbar
- DRY forms with django-crispy-forms
DjangoX can be installed via Pip, Pipenv, or Docker depending upon your setup. To start, clone the repo to your local computer and change into the proper directory.
$ git clone https://github.com/wsvincent/djangox.git
$ cd djangox
$ source djangox/bin/activate
(djangox) $ pip install -r requirements.txt
(djangox) $ python manage.py migrate
(djangox) $ python manage.py createsuperuser
(djangox) $ python manage.py runserver
# Load the site at http://127.0.0.1:8000
$ pipenv install
$ pipenv shell
(djangox) $ python manage.py migrate
(djangox) $ python manage.py createsuperuser
(djangox) $ python manage.py runserver
# Load the site at http://127.0.0.1:8000
$ docker build .
$ docker-compose up -d
$ docker-compose exec web python manage.py migrate
$ docker-compose exec web python manage.py createsuperuser
# Load the site at http://127.0.0.1:8000
For Docker, the INTERNAL_IPS
configuration in config/settings.py
must be updated to the following:
# config/settings.py
# django-debug-toolbar
import socket
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
INTERNAL_IPS = [ip[:-1] + "1" for ip in ips]
# Run Migrations
(djangox) $ python manage.py migrate
# Create a Superuser
(djangox) $ python manage.py createsuperuser
# Confirm everything is working:
(djangox) $ python manage.py runserver
# Load the site at http://127.0.0.1:8000
(If you don't already have a GitHub account, please create one. Your GitHub username will be referred to later as 'YOUR_GITHUB_USERNAME'. Change it accordingly in the steps below.)
-
Fork https://github.com/CengineLab/cenginelab using GitHub's interface to your own account. Let's say that the forked repository is at
https://github.com/YOUR_GITHUB_USERNAME/cenginelab
. -
Clone the main cenginelab repository https://github.com/CengineLab/cenginelab to a local folder on your computer, say named cenginelab/ (
git clone https://github.com/CengineLab/cenginelab cenginelab
) -
cd cenginelab
-
git remote add pullrequest https://github.com/YOUR_GITHUB_USERNAME/cenginelab
NB: the remote namedpullrequest
should point to YOUR own forked repo, not the main cenginelab repository! After this, your local cloned repository is prepared for making pullrequests, and you can just do normal git operations such as:git pull
git status
and so on. -
When finished with a feature/bugfix/change, you can:
git checkout -b your_new_fix_branch_name
Replaceyour_new_fix_branch_name
with a name that corresponds to your changes made. -
git push pullrequest
# (NOTE: thepullrequest
remote was setup on step 4) -
On GitHub's web interface, go to: https://github.com/CengineLab/cenginelab/pulls
Here the UI shows a dialog with a button to make a new pull request based on the new pushed branch.
-
After making your pullrequest (aka, PR), you can continue to work on the branch
your_new_fix_branch_name
... just do againgit push pullrequest
when you have more commits. -
If there are merge conflicts, or a branch lags too much behind cenginelab's master, you can do the following:
git pull --rebase origin master
# solve conflicts and dogit rebase --continue
git push pullrequest -f
# this will overwrite your current remote branch with the updated version of your changes.
The point of doing the above steps, is to never directly push to the main cenginelab repository, only to your own fork. Since your local master
branch tracks the
main CengineLab repository's master, then git checkout master
, as well as
git pull --rebase origin master
will continue to work as expected and git can always do it cleanly.
Git is very flexible, so there are other ways to accomplish the same thing. See the GitHub flow, for more information.
You can download the hub
tool from https://hub.github.com/ . Using
hub
, you will not need to go through the (sometimes) slow website
to make PRs. Most remote operations can be done through the hub
CLI
command.
NB: You still need to have a GitHub account.
(steps 1..3 need to be done just once):
-
hub clone CengineLab/cenginelab cenginelab
-
cd cenginelab
-
hub fork --remote-name pullrequest
-
git checkout -b my_cool_feature
# Step 4 is better done once per each new feature/bugfix that you make. remembermy_cool_name
refers to the name of a branch you create. Let the name be as close to what you are fixing as possible.
git commit -am "accounts: Add user signup page"
You can test locally whether your changes have not broken something by
running: python manage.py test
.
git push pullrequest
(so that your changes can be merged to the main cenginelab repository)
hub pull-request
Optionally, you can track the status of your PR CI tests with:
hub ci-status --verbose
Give a ⭐️ if this project helped you!