This is an advisor selection system I was asked to build from a friend, though was not used in production eventually. I learned many web development knowledge from this project. The main source of the knowledge is from the Django official tutorial, as you can see the app in this project has the same name as it is in the tutorial, but the functionality is quite different.
This project is very simple in functionality. The administrator creates users for students, and create information for advisors. Students could log into the website with the username and password assigned to them by default. Each advisor could take at most 5 students. The full advisors and available advisors could be shown separately. I am no web dev expert and I don't know much principals in developing web service, so there are many security issue and many bugs in this project. But personaly I think it's a good start for people who has no experience in full stack development at all before and want to dive in.
- Python
- pip
- virtualenv
- Django
I am not familiar with deploying python virtual environment on Windows platforms, so in this quick start, I will not cover how to setup on Windows. But I think it will not be differed quite much.
If you meet any permission problem during the setup process, try using sudo
on the command.
A lot of tools we will use can be installed from pip, which is a package management tools for python. To install pip, use the following command.
curl -O https://bootstrap.pypa.io/get-pip.py && python get-pip.py
To config a development environment for Django project, we often create a virtual environment for isolation purpose. First, we use pip
to install virtualenv
for python
pip install virtualenv
Next, we will start creating our project.
First, create a directory for our project, and change into it.
mkdir -p $Workspace/mysite
cd $Workspace/mysite
Within this directory, we will create our python virtual environment with the following command.
virtualenv venv && . ./venv/bin/activate
Once the virtual environment has been activated successfully, you will see the name of the venv at the beginning of your command line.
Now we can install Django within the virtual environment we just created and activated.
pip install django
django-admin startproject mysite
And then you can go into the root directory of mysite, playing with manage.py with commands like python manage.py runserver
.
git clone https://github.com/chaopli/advisor-selection
In the root directory of our project, which has the manage.py
file, we can migrate our database with the following command.
python manage.py migrate
python manage.py makemigrations polls
python manage.py migrate
Each time we make changes to our polls.models, we need to use python manage.py makemigrations polls
to update the database.
Then django will parse our model
modules to create corresponding schema, table, etc.
Use the manage.py
to create a super user with python manage.py createsuperuser
. You will be prompted to set the username and password.
Finally, you can use python manage.py runserver
to start the Django http server locally.
After the server is started successfully, you can use any browser, use http://localhost:8000
to test the site.
To log into the admin page for your project, use http://localhost:8000/admin
with the super user you just created.
This project has been deployed on openshift successfully. You can try registering for a account. One account can be used to create at most three projects. Once you created a project, you will be provided with a git url. You can add that git url to your local git remote url and push your repo to that url. Your project will be deployed automatically on openshift.