Creating an About Us Page in Python Django

5/5 - (1 vote)

General Solution

Creating an “About Us” page in Django involves optionally creating a new app, and then defining a view to render the page. You then create a URL for the view and an HTML template for the page content. Finally, you run the server to view your “About Us” page.

Step 1: Create a New Django App (Optional)

If you want to keep your project organized, you can create a new app for your “About Us” page. In your terminal, navigate to your Django project directory and run the following command: python manage.py startapp about.

Step 2: Add the App to Your Project Settings (If a New App is Created)

Open your Django project’s settings file (usually settings.py) and add your new app to the INSTALLED_APPS list.

Step 3: Create a View for the Page

In the views.py file of your app, create a view for your page:

from django.shortcuts import render

def about_view(request):
    return render(request, 'about/about.html')

This view will render the “About Us” page when the page is visited.

Step 4: Create a URL for the View

In the urls.py file of your app, create a URL for your view:

from django.urls import path
from .views import about_view

urlpatterns = [
    path('about/', about_view, name='about'),
]

Step 5: Create a Template for the Page

In your app’s templates directory (you might need to create it), create a new directory named ‘about‘ and inside it, create an HTML file: about.html. This file should contain the HTML for your “About Us” page.

Step 6: Run the Server

Finally, run your server with python manage.py runserver and visit http://localhost:8000/about/ to see your “About Us” page.

Remember to replace ‘about’ with the actual name of your app if it’s different. This is a very basic example. In a real-world application, you might want to add more features, like dynamic content, images, etc.

Example

The ‘About’ or ‘About Us’ page contains information about the purpose and goals of your blog. It should also include your background and expertise in the selected niche and other relevant information to help readers understand your blog.

Let’s create the about.html template.

{% extends 'base.html' %}
{% block content %}

<div class="container">
  <div class="row">
    <div class="col-md-8 card mb-4  mt-3 left  top">
      <div class="card-body">
          <h1>About Us</h1>
          <p class="card-text">I created this blog to share tips, suggestions and practical advice on how to maintain good health</p>
          <p class="card-text">I'm not a health expert but I am passionate about the topic and committed to providing accurate and reliable information.</p>
          <p class="card-text">Any suggestion is highly welcome. Feel free to <a href="{% url 'contact' %}">contact me</a> for more information or to say hello.</p>
      </div>
    </div>
  </div>
</div>
{% endblock %}

As usual, we extend the base template. Inside the block, we write what our blog is all about. Notice how we link the contact page using Django template engine’s {% url … %} tag. Within it, we use the target name we specified earlier in the urls.py file.

We want this ‘About’ page to appear on every post. So, we will include it at the footer of the base template.

<footer class="py-3 bg-grey">
            <p class="m-0 text-dark text-center ">Copyright &copy; Django Blog</p>
            <p class="m-0 text-dark text-center"><a href="{% url 'about' %}">About Us</a></p>
  </footer>

So, from the About page, we can see a link to the contact page. You can as well add a link to your social media pages. For the view function, it’s pretty straightforward.

def about(request):
    return render(request, 'about.html')

Then, the endpoint:

path('about', about, name='about'),

Check out the GitHub repository for the full code of my portfolio app and the beginning of my tutorial series if you haven’t already:

👩‍💻 Recommended: Python Django Portfolio App – How I Made It