Skip to main content

Publishing your Django project to github


On this post I will work you through the process of  deploying you app! to the  external service we'll be using  GitHub which is a code hosting service. Deploying is the process of publishing your application on the Internet so people can finally go and see your app. :)

Git is a very popular "version control system" used by a lot of programmers. This software can track changes to files over time so that you can recall specific versions later. A bit like the "track changes" feature in word processor programs (e.g., Microsoft Word or LibreOffice Writer), but much more powerful.

 Installing Git: Debian 

apt install git


Git tracks changes to a particular set of files in what's called a code repository (or "repo" for short). Let's start one for our project. Open up your console and run these commands, to make sure your on the project-level directory. find out your current working directory

pwd        #find out your current working directory
/root/django/finalpro2 ----------- Git will track changes to all the files and folders in this directory.
ls -ali    # make sure your project directory looks somehow like this
1209548 drwxr-xr-x  6 root root   4096 May 29 21:42 .
 671852 drwxr-xr-x 15 root root   4096 May 28 08:29 ..
1209729 drwxr-xr-x  4 root root   4096 May 29 21:09 accounts
1209727 -rw-r--r--  1 root root 131072 May 29 21:42 db.sqlite3
1209713 -rwxr-xr-x  1 root root    628 May 28 08:46 manage.py
1209712 drwxr-xr-x  3 root root   4096 May 29 21:33 news_art
1209714 drwxr-xr-x  4 root root   4096 May 29 21:33 templates
1209549 drwxr-xr-x  6 root root   4096 May 28 08:44 venv

git init   # initializing the repository
Initialized empty Git repository in /root/django/finalpro2/.git/
git config --global user.name "Your Name"
git config --global user.email you@example.com

There are some files we want git to ignore. We do this by creating a file called .gitignore

nano .gitignore 

*.pyc
*~
__pycache__
venv
db.sqlite3
.DS_Store


pip3 freeze > requirements.txt  # write requirements of your project
git status       # enumerate the files and directory that will be commited
On branch master

Initial commit

Untracked files:
  (use "git add ..." to include in what will be committed)

        .gitignore
        accounts/
        manage.py
        news_art/
        requirements.txt
        templates/

nothing added to commit but untracked files present (use "git add" to track)

git add --all
git commit -m "Authentication, first commit"
[master (root-commit) ee683bb] Authentication, first commit
 19 files changed, 384 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 accounts/__init__.py
 create mode 100644 accounts/admin.py
 create mode 100644 accounts/apps.py
 create mode 100644 accounts/migrations/__init__.py
 create mode 100644 accounts/models.py
 create mode 100644 accounts/tests.py
 create mode 100644 accounts/urls.py
 create mode 100644 accounts/views.py
 create mode 100755 manage.py
 create mode 100644 news_art/__init__.py
 create mode 100644 news_art/settings.py
 create mode 100644 news_art/urls.py
 create mode 100644 news_art/wsgi.py
 create mode 100644 requirements.txt
 create mode 100644 templates/accounts/register.html
 create mode 100644 templates/base.html
 create mode 100644 templates/home.html
 create mode 100644 templates/registration/login.html


Go to GitHub.com and sign up for a new, free user account, or login if you already have an account.


Then, create a new repository, giving it the name "django-authentication". Leave the "initialize with a README" checkbox unchecked, leave the .gitignore option blank (we've done that manually) and leave the License as None.



 



 
hook up the Git repository on your computer to the one up on GitHub.
 git clone --mirror https://github.com/kazz54/django-authentication.git
Cloning into bare repository 'django-authentication.git'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.

 

git push origin master --force

Username for 'https://github.com': username you entered when you created your account Password for 'https://you@example.com@github.com':
Counting objects: 25, done.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (25/25), 5.72 KiB | 0 bytes/s, done.
Total 25 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/kazz54/django-authentication.git
 + bf370dc...ee683bb master -> master (forced update)


Your code is now on GitHub. Go and check it out!

Popular posts from this blog

How To Install the Anaconda Python Distribution on Debian 9 And Running a public notebook server

Anaconda Distribution is an open-source package manager, environment manager and distribution of Python and R programming languages. With a collection of 1,000+ open source packages with free community support. Designed for data science and machine learning workflows, you can use it whether you are on Windows, macOS or Linux. The Anaconda distribution ships with the conda command-line package management utility. You can learn more about Anaconda and conda by reading the official Anaconda Documentation . Jupyter is a browser-based interpreter that allows you to interactively work with Python and R. Anaconda provides Jupyter as well. You can think of Jupyter as a digital notebook that gives you an ability to execute commands, take notes and draw charts.It’s primarily used by Data Scientists. But I find that very useful tool if you are learning Python or R. It’s basically the same as working on a shell but much better. The Jupyter notebook web application is based on a

How to create REST API using Django REST Framework

This post begins with already working project and app's, I found that there some few requirement's that my project needed to handle and the best option for those requirement's was to use the Django's  Rest Framework. The way that I will tackle this task is more specific to the needs of the project rather than a one to one how to..., that being said you can still follow along, the approach that I'm going to use is easy to follow since I'll be providing a lot of information a log the way for better understanding of the why and how.....this code is available on Github , enough with the alerts and on with the show. Note:  If you would want to mimic the exactly settings then you will need to enable user authentication on your project you can follow this link for details .  Start with the DRF (Django Rest Framework) installation pip3 install djangorestframework For our app to use DRF, we'll have to add rest_framework into our settings.py.   nan

django react app setting up the backend

On the previous article I demonstrated how we can use the generic views along with ModelSerializer classes to rapidly develop our REST APIs. Knowledge that you will need  in your career as full stack / backend developer, however think of this article as an extension to the previous one, equipped with what we already know about REST API we will step our game up and discuss about ViewSet, ModelViewset we will dig deep into the concepts of Routers which allow us to manage our api routes in a simple and sophisticated manner as well as helping to speed up building APIs even further. There for on part II of this article i'll work you through on how React application can consume this RESTful API. There for at the end of the day we will have a full stack web app, in short we strat our development at the backend then later on we move at the frontend... so are you excited and ready to take the challange? lets do this then..... you can get source code for the bakend on github Preparat