Top

Tags: Python

How to add tags to your models in Django

Jul 27, 2020 | 663 views

#Python #Django

How to add tags to your models in Django | Django Packages Series #1

https://django-taggit.readthedocs.io/en/latest/api.html


Comments: 0

Adding basic search to your Django site

Jul 27, 2020 | 657 views

#Python #Django

From: https://www.calazan.com/adding-basic-search-to-your-django-site/

and How to Add Search Functionality to a Website in Django

# blogs/views.py

import operator

from django.db.models import Q


class BlogSearchListView(BlogListView):
    """
    Display a Blog List page filtered by the search query.
    """
    paginate_by = 10

    def get_queryset(self):
        result = super(BlogSearchListView, self).get_queryset()

        query = self.request.GET.get('q')
        if query:
            query_list = query.split()
            result = result.filter(
                reduce(operator.and_,
                       (Q(title__icontains=q) for q in query_list)) |
                reduce(operator.and_,
                       (Q(content__icontains=q) for q in query_list))
            )

        return result

Comments: 0

How To Deploy Django App with Nginx, Gunicorn, PostgreSQL and Let’s Encrypt SSL on Ubuntu

Jul 26, 2020 | 666 views

#Python #Django

Django --> Gunicorn (WSGI server) --> Nginx

From here: 

How To Deploy Django App with Nginx, Gunicorn, PostgreSQL and Let’s Encrypt SSL on Ubuntu

and here: 
How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 18.04

Comments: 0