Skip to content

Instantly share code, notes, and snippets.

View Tobi-De's full-sized avatar
๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ
Trade-offs everywhere!

Tobi Tobi-De

๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ
Trade-offs everywhere!
View GitHub Profile
pg_dump "sslmode=require host=<host> dbname=leerming user=leerming" --data-only -f leerming.sql
psql "host=<host> dbname=leerming user=leerming" < leer.sql
@Tobi-De
Tobi-De / filters.py
Created February 15, 2023 11:15
filter in multiple fields with django-filter
class LocationFilter(django_filters.FilterSet):
q = django_filters.CharFilter(method='my_custom_filter', label="Search")
class Meta:
model = Location
fields = ['q']
def my_custom_filter(self, queryset, name, value):
return queryset.filter(
Q(loc__icontains=value) |
@Tobi-De
Tobi-De / detail.md
Last active October 11, 2022 10:53
This not explains the reason behind the get_price method needed by dj-shop-cart

Ok first of all, what is the get_price method ?

The get_price is a method required by the dj-shop-cart package that you must implement on your django model representing the products that you are adding to the cart. The signature is as follow:

class Product(models.Model):
 price = models.DecimalField(decimal_places=2, max_digits=10)
{
"data": [
{
"type": "hotel-offers",
"hotel": {
"type": "hotel",
"hotelId": "MCLONGHM",
"chainCode": "MC",
"dupeId": "700031300",
"name": "JW Marriott Grosvenor House London",
def decorator(arg1, arg2):
def wrapper(func):
def inner(*args, **kwargs):
...
@decorator(1, 2) # my_func = decorator(my_func)(1,2)
def my_func():
@Tobi-De
Tobi-De / GitCommitEmoji.md
Created May 10, 2022 14:52 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji

Inspired by dannyfritz/commit-message-emoji

See also gitmoji.

Commit type Emoji
Initial commit ๐ŸŽ‰ :tada:
Version tag ๐Ÿ”– :bookmark:
New feature โœจ :sparkles:
Bugfix ๐Ÿ› :bug:
@Tobi-De
Tobi-De / utils.py
Last active July 6, 2023 11:07
Some django utils I usually have in my projects
# render pdf using weasyprint
# depends on: weasyprint
import weasyprint
from django.template.loader import render_to_string
def render_to_pdf(template_src, context_dict=None):
html = render_to_string(template_src, context_dict)
try:
pdf = weasyprint.HTML(string=html).write_pdf()
except Exception as e:
@Tobi-De
Tobi-De / base.html
Last active July 6, 2023 10:48
soft ui dashboard django
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>{% block title %}izimanage{% endblock title %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="accountancy software">
<meta name="author" content="Tobi DEGNON">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
@Tobi-De
Tobi-De / htmx.md
Last active March 27, 2025 20:15
Simple django CBV using django-htmx

Django-htmx guide setup

Simple guide to setup django-htmx in a django project. In this guide we assume that you already have a django project setup in a virtualenv and you only wish to add django-htmx to your project.

  1. Install the django-htmx package

     pip install django-htmx
    
  2. Add django-htmx to your INSTALLED_APPS:

@Tobi-De
Tobi-De / sheet.md
Last active March 20, 2021 06:46
Typescript cheat sheet