Skip to content

Instantly share code, notes, and snippets.

@bahiamartins
bahiamartins / pagination.html
Created November 21, 2019 12:54
Django Pagination in HTML
<div class="text-center">
{% if pages.has_other_pages %}
<ul class="pagination">
{% if pages.has_previous %}
<li>
<a href="?page=1{% querystring request %}">&laquo;&laquo;</a>
</li>
<li>
<a href="?page={{ pages.previous_page_number }}{% querystring request %}">&laquo;</a>
@bahiamartins
bahiamartins / call_celery_post_deploy_aws.config
Created May 15, 2019 00:23
call celery in AWS Elastic Beanstalk via post deploy. Process of Daemonization using Supervisord
{
"container_commands": {
"celery_configure": {
"command": "mv /tmp/100_celery_worker.sh /opt/elasticbeanstalk/hooks/appdeploy/post && chmod 774 /opt/elasticbeanstalk/hooks/appdeploy/post/100_celery_worker.sh",
"leader_only": true
}
}
}
@bahiamartins
bahiamartins / celery_daemon.config
Created May 15, 2019 00:21
Daemonization process of Celery and Celery Beat using Supervisord in AWS Elastic Beanstalk
files:
"/tmp/100_celery_worker.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/sh
# for_log_and_pid
mkdir -p /var/log/celery/ /var/run/celery/
@bahiamartins
bahiamartins / next_previous.py
Created February 5, 2017 10:17 — forked from dokterbob/next_previous.py
Django template tag to efficiently get the next or previous object in the Django queryset, with regards to the item specified.
from django import template
register = template.Library()
from templatetag_sugar.register import tag
from templatetag_sugar.parser import Constant, Variable, Name
from .utils import get_next_or_previous
"""
Efficient and generic get next/previous tags for the Django template language,