Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Basic Process For Setting Up A Django Home Page

TODO : Fix the formatting of this post that got busted during the move to nextjs

Basic Setup for Foreign Key stuff


- Make the name of the project ``config`` in the same directory as the pyvenv. 
        
        
        django-admin startproject config .
        python manage.py startapp pages
        python manage.py migrate
        

- In `config/settings.py`, Add;
    
        'pages'
        
    To:
        
        INSTALLED_APPS
                
    
- In `config/settings.py, under:

        TEMPLATES
    
    Change:
    
        'DIRS': [],
        
    To:
    
        TODO: think about moving this down.
    
        'DIRS': [str(BASE_DIR.joinpath('templates'))],
        

- In ``config/urls.py`` change:

        from django.urls import path
        
    To:
    
        from django.urls import includes, path
        

- In ``config/urls.py`` add this:
        
        path('', include('pages.urls')),
        
    To:
    
        urlpatterns
        
- Create file:

        pages/urls.py
        
    With:
    

-- code
-- python

  from django.urls import path

  from . import views

  app_name = 'pages'

  urlpatterns = [
      path('', views.homepage),
  ]

-- p


- Change ``pages/views.py`` to:


        from django.shortcuts import render
        
        def homepage(request):
            return render(
                request,
                'pages/homepage.html'
            )


- Make `pages/templates/pages/homepage.html`


      {% extends 'base.html' %}
      
      {% block content %}
      <h3>Welcome to the Music Site</h3>
      {% endblock content %}


    
- Make ``templates/base.html`` at the root of the project. With something like:
    
        <!DOCTYPE html>
        <html>
        <head>
        <title>Music site</title>
        </head>
        <body>
        <h1>Music Site</h1>
        {% block content %}{% endblock content %}
        </body>
        </html>
    

-- hr

TODO: Add:

    STATICFILES_DIRS = [
        BASE_DIR / "static",
    ]