Creating A Django Project

We have downloaded python,pip and vitualenv. After that we created and activated a virtual environment, after which we installed django and whitenoise in that virtual environment. As I said earlier, you must always make sure that your virtual environment is activated in order to work with django (according to this django series), because we installed django only in the virtual environment and not system wide.

Deciding a new project.

We will not go through the typical steps of deciding and planning a project, that is another course. We will just decide a project and see how far we can go. The project I propose here is a news wepbapplication. 

News Web App

So what typically goes into an app like this? Well, a news web app will have users, it will have other users who can write and publish news (staff), it will have a page where one gets to see all the trending news, a page where one gets to read the details of one particular news. 

The news after creation should be updatable, or even deletable. We could even go to the extent of making users able to subscribe so that they get notified in their mails when news is published.

So basically, that's our project. I'm excited, I'm trying to imagine how our finished app will look like. I will list the things we will be doing in the app as list of objectives (just so that it looks like we planned the project), so that we can cancel out the things we have achieved and the things left to be achieved.

Objectives

  1. User management
  2. Staff management
  3. Homepage (this could be our news list page as well)
  4. News list page
  5. News detail page
  6. password management (change,forgotten passwords)
  7. And some other stuff

So those are our objectives right now for our news web application. I will be looking forward to creating or getting some nice logo and design concept for the application.

Creating A New Django Project

Please make sure your virtual environment is activated. We are naming the project Nounews (New News)


Windows users

Activate Virtual environment

cd Desktop
myenv\Scripts\activate

To create a new django project, type the following in the command line which is already opened and has your virtual environment activated.

django-admin startproject Nounews

After hitting enter, django has silently created a new project for you called Nounews on your desktop. This project has so many amazing things already setup for you. A functioning administration site, database connection settings, wsgi, and every other thing you need. All we will be doing is customizing the project to suit what we want to do.


So now, to enter your newly created project called Nounews and see if it's actually set up already do the following

cd Nounews
python3 manage.py runserver

You should see the following output or similar one:

Watching for file changes with StatReloader
Performing system checks...


System check identified no issues (0 silenced).


You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): 
admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.


December 08, 2019 - 19:43:36
Django version 2.2, using settings 'news_proj.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Open your web browser and type http://127.0.0.1:8000/ and see your django rocket about to take off !!!


Linux users

Activate Virtual environment

cd Desktop
source myenv/bin/activate

To create a new django project, type the following in the terminal which should be already opened and has your virtual environment activated.

django-admin startproject Nounews

After hitting enter, django has silently created a new project for you called Nounews on your desktop. This project has so many amazing things already setup for you. A functioning administration site, database connection settings, wsgi, and every other thing you need. All we will be doing is customizing the project to suit what we want to do.


So now, to enter your newly created project called Nounews and see if it's actually set up already do the following

cd Nounews
python3 manage.py runserver

You should see the following output or similar one:

Watching for file changes with StatReloader
Performing system checks...


System check identified no issues (0 silenced).


You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): 
admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.


December 08, 2019 - 19:43:36
Django version 2.2, using settings 'news_proj.settings'Starting development server at http://127.0.0.1:8000/Quit the server with CONTROL-C.

Open your web browser and type http://127.0.0.1:8000/ and see your django rocket about to take off !!!