Artificial Intelligence Design Digital News Technology

Building A Message Board App With Django

Pinterest LinkedIn Tumblr

Introduction

In this article, we shall use a database for the first time to build a basic Message Board App where users can post and read short messages.

Initial Setup

At this point, we should be getting a bit familiar with the initial setup for a Django project so we can quickly run through the standard initial setup commands to begin a new one. We need to do the following:

  1. Create a new directory for our code called mb.
  2. Install Django in a new virtual environment.
  3. Create a new project called mb_project.
  4. Create a new app called posts.
  5. update settings.py.

In a new command line console, enter the following commands:

mkdir mb && cd mb

pipenv install django==3.0.1

pipenv shell

django-admin startproject mb_project

python manage.py startapp posts

Next, we need to alert Django to the new app, posts, by adding it to the bottom of the INSTALLED_APPS section of our settings.py file. To do this, we need to do the following:

mb_project/settings.py

INSTALLED_APPS = [

‘django.contrib.admin’

‘django.contrib.auth’

‘django.contrib.contenttypes’

‘django.contrib.sessions’

‘django.contrib.messages’

‘django.contrib.staticfiles’

‘posts.apps.PostsConfig’,

]

Then execute the migrate command to create an initial database on Django’s default server. To do this, type the following command in the command prompt:

python manage.py migrate

 

 

ALSO READ  Types of Version Control Systems.