Snippets Collections
## generate the requirements file
pip freeze > requirements.txt

## specify where to store django static files just above the static url
STATIC_ROOT = BASE_DIR / 'staticfiles'

## tell heroku how to serve them with whitenoise
add this in settings.MIDDLEWARE below security
'whitenoise.middleware.WhiteNoiseMiddleware',

## add allowed hosts, name of app and local host url example
ALLOWED_HOSTS = ['text-test-heroku.herokuapp.com', '127.0.0.1:8000']

## create a runtime.txt file to put the python version required-
python-3.7.9

## create a Procfile file to say from where it would beserved
(make sure to have installed gunicorn in pip)
web: gunicorn MovieReview.wsgi --log-file -
MovieReview is folder where wsgi is located
from django.contrib import admin

from .models import Movies, Series, Clips


admin.site.site_header = 'WISEMAN'

class MoviesAdmin(admin.ModelAdmin):
    list_display = ('title',)
    list_filter = ('upload_date',)
    prepopulated_fields = {'slug': ('title',)}

class SeriesAdmin(admin.ModelAdmin):
    list_display = ('title',)
    list_filter = ('upload_date',)
    prepopulated_fields = {'slug': ('title',)}

class ClipsAdmin(admin.ModelAdmin):
    list_display = ('title',)
    list_filter = ('upload_date',)
    prepopulated_fields = {'slug': ('title',)}

admin.site.register(Movies, MoviesAdmin)

admin.site.register(Series, SeriesAdmin)

admin.site.register(Clips, ClipsAdmin)
// templates 

<div class="container" style="margin-top: 10vh;margin-left: 40vw;margin-right:40vw;">
    <nav aria-label="Page navigation example">
        <ul class="pagination">
            {% if page_obj.has_previous %}
            <li class="page-item">
                <a class="page-link" href="?page=1">First</a>
            </li>
            <li class="page-item">
                <a class="page-link" href="?page={{ page_obj.previous_page_number }}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            {% endif %}
            <li class="page-item active" aria-current="page">
                <a class="page-link" href="#">Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }} <span
                        class="sr-only">(current)</span></a>
            </li>
            {% if page_obj.has_next %}
            <li class="page-item">
                <a class="page-link" href="?page={{ page_obj.next_page_number }}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
            <li class="page-item">
                <a class="page-link" href="?page={{ page_obj.paginator.num_pages }}">Last</a>
            </li>
            {% endif %}
        </ul>
    </nav>
</div>
star

Wed Dec 30 2020 19:24:10 GMT+0000 (Coordinated Universal Time)

#django #python,django
star

Thu Dec 24 2020 14:22:45 GMT+0000 (Coordinated Universal Time)

#python,django
star

Tue Dec 22 2020 11:18:43 GMT+0000 (Coordinated Universal Time)

#python,django

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension