Skip to content

Instantly share code, notes, and snippets.

View AndreasDickow's full-sized avatar
🎯
Focusing

BIZ Factory GmbH AndreasDickow

🎯
Focusing
View GitHub Profile
@AndreasDickow
AndreasDickow / base.py
Last active December 5, 2019 09:58
Set default schema for Postgresql DB in django
# with this trick it is possible to install django on schema access restricted databases
# within project root create folders like
# -app
# -pg
# |
# - __init__.py
# - base.py
from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper
@AndreasDickow
AndreasDickow / views.py
Last active May 12, 2024 17:25
Fix object has no attribute 'object_list' when post create duplicate in Django-Tables2 ListView
class mylist(SingleTableMixin, FilterView):
...
def get_context_data(self, **kwargs):
queryset = kwargs.pop('object_list', None)
if queryset is None:
self.object_list = self.model.objects.all()
...
return super().get_context_data(**kwargs)
@AndreasDickow
AndreasDickow / gist:efbbed745cb5e441ede92024a60fd70f
Created February 28, 2023 15:00
deployment from gitlab-ci with password protected ssh private key file
deploy to staging:
image: ${CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX}/alpine:3.17.2
stage: deploy
before_script:
- "apk add openssh-client"
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo '#!/bin/sh' > ~/.ssh/tmp
- echo 'echo $SSH_PRIV_KEY_PASS' >> ~/.ssh/tmp && chmod 700 ~/.ssh/tmp
@AndreasDickow
AndreasDickow / tests.py
Created March 29, 2023 09:12
Django Unit Test Templatetags: how to circumvent the WSGIRequest has no attribute 'request' Problem
class CustomTagTestCase(BaseTestCase):
"""_summary_: includes tests of custom templatetags from templatetags/custom_tags.py
Args:
BaseTestCase (_type_): _description_
"""
def test_count_session_time(self):
"""_summary_: test clean_text