Creating the app for the blog

Python Developer | Audio Editor | Technical Writer | OSS Contributor | Tag Moderator @ @ThePracticalDEV | Valorant TonyPoppins #881488
Search for a command to run...

Python Developer | Audio Editor | Technical Writer | OSS Contributor | Tag Moderator @ @ThePracticalDEV | Valorant TonyPoppins #881488
No comments yet. Be the first to comment.
Learn to jumpstart a production-ready blog using the Cookiecutter-Django framework and how to deploy it to Heroku
Django is based on the Model-View-Template software design architecture, which means that the Model takes care of our data and logic, the views will take care of what the users will see in the browser when you render your site, and the templates will...
A no-fluff deployment runbook for getting a Cookiecutter Django project live on DigitalOcean using Docker and Traefik. Covers the full path from droplet provisioning to a working production deployment

If youâre switching between networks with different trust levelsâhome, cafĂ©, coworking spaceâyou probably donât want your VPN behavior to be static. This guide walks through a clean, system-level way

Why this script exists If you've ever watched your free disk space quietly shrink over a few weeks of active development, you know the feeling: yesterday you had plenty of headroom, today your IDE is

A message from a colleague dropped into my inbox one morning: Hi Ice, now that we pushed the changes sa site, we need to scour the site for mentions of Level 1, Level 2, Level 1/2 and change them acc

Backing up your WordPress site is one of the most important maintenance tasks you can do as a site owner. While plugins like UpdraftPlus or Jetpack make this easy, knowing how to do it manually via SS

Now let's create a new Django application. We'll call our new app main.
$ django-admin startapp main
Once the app is created, we'll have to move the app in the blog_tutorial directory together with the default users app and configure our apps.py, urls.py, and include the app in our base.py config. Let's now create those files and configure it for our app.
Our blog_tutorial/main/apps.py is configured as follow:
# blog_tutorial/main/apps.py
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class MainConfig(AppConfig):
name = 'blog_tutorial.main'
verbose_name = _("Main")
def ready(self):
try:
pass
except ImportError:
pass
And our blog_tutorial/main/urls.py has an empty urlpatterns variable. This is because we will be defining all our URLs in the config/urls.py file.
# blog_tutorial/main/urls.py
app_name = "main"
urlpatterns = [ ]
And don't forget to add our app to the LOCAL_APPS in the config/settings/base.py
# config/settings/base.py
...
LOCAL_APPS = [
"blog_tutorial.users.apps.UsersConfig",
# Your stuff: custom apps go here
"blog_tutorial.main.apps.MainConfig",
]
Then let's apply our migrations and run our app.
$ python manage.py migrate
Operations to perform:
Apply all migrations: account, admin, auth, contenttypes, sessions, sites, socialaccount, users
Running migrations:
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying users.0001_initial... OK
Applying account.0001_initial... OK
Applying account.0002_email_max_length... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying sessions.0001_initial... OK
Applying sites.0001_initial... OK
Applying sites.0002_alter_domain_unique... OK
Applying sites.0003_set_site_domain_and_name... OK
Applying socialaccount.0001_initial... OK
Applying socialaccount.0002_token_max_lengths... OK
Applying socialaccount.0003_extra_data_default_dict... OK
$ python manage.py runserver
Watching for file changes with StatReloader
INFO 2020-07-21 17:21:50,781 autoreload 66844 4497481152 Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
July 21, 2020 - 17:21:51
Django version 3.0.8, using settings 'config.settings.local'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Open your browser and head over https://127.0.0.1:800 or https://localhost:8000 to see what you just created using the Cookiecutter-Django framework.
Ok, bye. Thanks for listening to my Ted talk.
Kidding.
You can check the official docs of Cookiecutter-Django to get more information on the features of the framework. https://cookiecutter-django.readthedocs.io/en/latest/developing-locally.html
In this chapter, we've installed a virtual environment to separate our project in our development environment, install the default project dependencies of Cookiecutter-Django, created a PostgreSQL database, created a Django app and added the necessary config in our app and settings to make our Django blog work.