Help Needed: Database Content Not Displaying on Webpages in Django Project

Hi Django Community,

I hope you’re all doing well. I’m currently working on a Django project and have encountered an issue that’s been puzzling me for a while now. I’m reaching out to seek your expertise and assistance in resolving it.

The Problem: Despite everything seeming to work fine, the content from my database is not displaying on the webpages when I run the development server. Initially, when I create the website, all content loads perfectly. However, upon returning the next day, none of the database content appears on the pages. This issue persists both in my local development environment and when using Docker.

What I’ve Tried:

  • I’ve thoroughly checked my code to ensure there are no obvious errors.
  • I’ve restarted the server multiple times, but the issue persists.
  • I’ve tested both locally and with Docker, experiencing the same problem in both environments.
  • I’ve verified that the database connection is established correctly.

What I Need Help With: I’m at a loss as to what might be causing this issue. I’m seeking advice on where to look next and how to troubleshoot effectively.

Django settings for dj project.

Generated by ‘django-admin startproject’ using Django 5.0.2.

For more information on this file, see

For the full list of settings and their values, see


import os
from pathlib import Path

Build paths inside the project like this: BASE_DIR / ‘subdir’.

BASE_DIR = Path(file).resolve().parent.parent

Quick-start development settings - unsuitable for production

See Deployment checklist | Django documentation | Django

SECURITY WARNING: keep the secret key used in production secret!

SECRET_KEY = “django-insecure-bmh)9+a7$%k)c7g-y!ns_%fby053fs_y2(!+u5a1*–_n@5bs2”

SECURITY WARNING: don’t run with debug turned on in production!

DEBUG = True

ALLOWED_HOSTS = [“localhost”, “”]

Application definition



ROOT_URLCONF = “dj.urls”

“BACKEND”: “django.template.backends.django.DjangoTemplates”,
“DIRS”: [BASE_DIR / “templates”],
“APP_DIRS”: True,
“context_processors”: [

WSGI_APPLICATION = “dj.wsgi.application”


Settings | Django documentation | Django


“default”: {

“ENGINE”: “django.db.backends.sqlite3”,

“NAME”: BASE_DIR / “db.sqlite3”,



“default”: {
“ENGINE”: “django.db.backends.postgresql”,
“NAME”: “postgres”,
“USER”: “postgres”,
“PASSWORD”: “postgres”,
“HOST”: “db”,
“PORT”: 5432,

Password validation

Settings | Django documentation | Django

“NAME”: “django.contrib.auth.password_validation.UserAttributeSimilarityValidator”,
“NAME”: “django.contrib.auth.password_validation.MinimumLengthValidator”,
“NAME”: “django.contrib.auth.password_validation.CommonPasswordValidator”,
“NAME”: “django.contrib.auth.password_validation.NumericPasswordValidator”,


Internationalization and localization | Django documentation | Django



USE_I18N = True

USE_TZ = True

Static files (CSS, JavaScript, Images)

How to manage static files (e.g. images, JavaScript, CSS) | Django documentation | Django

STATIC_URL = “/static/”
STATICFILES_DIRS = [os.path.join(BASE_DIR, “static”)]
STATIC_ROOT = os.path.join(BASE_DIR, “staticfiles”)


MEDIA_URL = “/media/”
MEDIA_ROOT = os.path.join(BASE_DIR, “media”)

Default primary key field type

Settings | Django documentation | Django

DEFAULT_AUTO_FIELD = “django.db.models.BigAutoField”
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path(“”, include(“pages.urls”)),
path(“about/”, include(“about.urls”)),
path(“location/”, include(“location.urls”)),
path(“service/”, include(“services.urls”)),
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

{% extends “_base.html” %} {% block content %}

Rachel's Nails & Make Up Art!

{% for post in post_list_list %}

{{ }}

{{ post.about }}

{% endfor %}

{% endblock content %}

from django.db import models

class Post(models.Model):
name = models.CharField(max_length=100, blank=True)
about = models.TextField()
image = models.ImageField(upload_to=“uploads”)

def __str__(self):

from django.views.generic import ListView
from .models import Post

class HomePostView(ListView):
model = Post
template_name = “home.html”
context_object_name = “post_list”

Pull base image

FROM python:3.11-slim

Set environment variables




Set work directory


Install dependencies

COPY ./requirements.txt .

RUN pip install -r requirements.txt

Copy project

COPY . .

version: “3.9”

build: .
command: python /code/ runserver
- .:/code
- 8000:8000
- db
image: postgres:13
- postgres_data:/var/lib/docker/volumes/rounds_postgres_data/_data
# - postgres_data:/var/lib/postgresql/data/


2024-02-25 19:20:00 web-1 | Django version 5.0.2, using settings ‘dj.settings’
2024-02-25 19:20:00 web-1 | Starting development server at
2024-02-25 19:20:00 web-1 | Quit the server with CONTROL-C.
2024-02-25 19:20:00 web-1 |
2024-02-25 19:20:02 web-1 | [25/Feb/2024 16:20:02] “GET / HTTP/1.1” 200 1196
2024-02-25 19:20:05 web-1 | [25/Feb/2024 16:20:05] “GET /service/service/ HTTP/1.1” 200 1282
2024-02-25 19:35:58 web-1 | [25/Feb/2024 16:35:58] “GET / HTTP/1.1” 200 1196
2024-02-25 19:36:03 web-1 | [25/Feb/2024 16:36:03] “GET /location/loc/ HTTP/1.1” 200 1201
2024-02-25 19:36:05 web-1 | [25/Feb/2024 16:36:05] “GET /about/about/ HTTP/1.1” 200 1222
2024-02-25 19:36:08 web-1 | [25/Feb/2024 16:36:08] “GET /about/about/ HTTP/1.1” 200 1222

Errors I’m Encountering:
Unfortunately, I haven’t received any specific error messages. The issue seems to be more of a content not displaying problem rather than a crash or error. However, I’m open to suggestions on how to capture and share any potential error messages or logs that might be helpful in diagnosing the issue.

Any guidance or insights you can offer would be greatly appreciated. Thank you in advance for your help!

Best regards,
Mom’s Basement!

Please edit your post to facilitate people’s ability to read and understand what you’re trying to share.

Enclose each separate file’s contents between lines of three backtick - ` characters. This means you’ll have a line of ``` before and after the contents of each different file.

Identify each file with the name of the directory and the file name being posted.

Verify whether the data that is “missing” is in the database.