Skip to content

Latest commit

 

History

History

django-pagination

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Pagination for a User-Friendly Django App

This repository contains the source code for the Django project that you'll complete in Real Python's Pagination for a User-Friendly Django App.

Create the Django Project

After you've cloned this repository and navigated into its folder, you can run the provided example project on your local machine by following the steps outlined below.

Create a new virtual environment:

$ python3 -m venv venv

Activate the virtual environment:

$ source ./venv/bin/activate

Navigate to the folder for the step that you're currently on.

Install the dependencies for this project if you haven't installed them yet:

(venv) $ python -m pip install -r requirements.txt

Apply the migrations for the project to build your local database:

(venv) $ python manage.py migrate

Run the Django development server:

(venv) $ python manage.py runserver

Navigate to http://localhost:8000/all. You should see an empty page with a Python Keywords headline.

Prepare the Database

Run the Django migrations:

(venv) $ python manage.py migrate

This will create the tables for the Python wiki project in your database.

Add the Python Keywords Data

Enter the Django shell:

(venv) $ python manage.py shell

Add the Python keywords to your database:

>>> import keyword
>>> from terms.models import Keyword
>>> for kw in keyword.kwlist:
...     k = Keyword(name=kw)
...     k.save()
...

Verify that the keywords were added to your database:

>>> Keyword.objects.all()
<QuerySet [<Keyword: False>, <Keyword: None>, '...(remaining elements truncated)...']>

Run the Django development server:

(venv) $ python manage.py runserver

Navigate to http://localhost:8000/all to see the page with all the Python keywords.