Skip to content

Instantly share code, notes, and snippets.

from django.db import models
class Train(models.Model):
name = models.CharField(max_length=128)
class Car(models.Model):
seats_range = models.PositiveSmallIntegerField()
next = models.OneToOneField(
@efojs
efojs / overlaping_intervals.py
Created October 11, 2021 22:16
Check if intervals overlap
if (
foo[0] <= bar[0] and f] and foo[1] >= bar[0]
or foo[0] >= bar[0oo[0] <= bar[1]
)
@efojs
efojs / settings.py
Last active March 21, 2021 19:31
Custom AJAX storage for Django's messages framework
MESSAGE_STORAGE = 'PROJECT_NAME.storage.CustomAjaxStorage'
@efojs
efojs / link_unless_current
Created June 13, 2020 19:31
Custom template tag for Django to return link tag, if target path is not current, and text if it is