Django: Multiple Pagination in a single Template

Assuming you would like to display two models in the same template each with their own pagination, here’s how to do it. views.py def myview(): Model_one = Model.objects.all() paginator = Paginator(Model_one, 6) page = request.GET.get(‘page1’) try: Model_one = paginator.page(page) except PageNotAnInteger: Model_one = paginator.page(1) except EmptyPage: Model_one = paginator.page(paginator.num_pages) Model_two = Model_other.objects.all() paginator = Paginator(Model_two,…Read More

Django-allauth Installation

There is a useful django-allauth video tutorial at Create third party Facebook login in Django. The document below simply follows that but only adds facebook social authentication. Documentation can be found at django-alluth documentation. django-allauth can also be installed by cloning from https://github.com/pennersr/django-allauth I am running Django 1.9.5 and will install django-allauth 0.25.2 Setup a…Read More

Part 6: Django CRUD, Update

Continued from Part 5: Django CRUD, Delete Full code on https://github.com/shanegibney/djangoCRUD We may wish to update the model ‘Members’. Let us start by adding an edit icon to the table in ‘index.html’. <td><a href=”{% url ‘edit_new’ item.id %}”><span class=”glyphicon glyphicon-pencil”></span></a></td> If you are not using Bootstrap replace the span tags with ‘edit’. <td><a href=”{% url ‘edit_new’…Read More

Part 3: Django CRUD, Display Models

Continued from Part 2: Setting up Django, URL’s & Views Full code on https://github.com/shanegibney/djangoCRUD Add to the crudapp/models.py file from django.db import models In the same file create a model called ‘Members’ with columns for ‘first_name’, ‘last_name’ and ‘description’. This is equivalent to a table called ‘Members’ with fields for ‘first_name’, ‘last_name’ and ‘description’. class Members(models.Model): first_name =…Read More