Skip to content

Instantly share code, notes, and snippets.

View gabrielfgularte's full-sized avatar
🎯
Focusing

Gabriel Gularte gabrielfgularte

🎯
Focusing
View GitHub Profile
from __future__ import annotations
import random
from datetime import datetime
from django.contrib.auth import get_user_model
from django.utils import timezone
from django.utils.translation import gettext as _
from pydantic import BaseModel
@gabrielfgularte
gabrielfgularte / base_views.py
Created May 30, 2019 14:09
Django InlineFormView - handle multiple formsets in Class Based Views
class InlineFormView():
formsets = []
def get_formsets(self):
if not self.formsets:
raise ValueError('InlineFormView needs a "formsets" property.')
return self.formsets
def get_context_data(self, **kwargs):
data = super(InlineFormView, self).get_context_data(**kwargs)
Verifying that +gabrielfgularte is my blockchain ID. https://onename.com/gabrielfgularte
// When using angular-translate it's impossible to make two-way data binding translations yet,
// and this sometimes can be a headache. So I've developed this directive to save some time.
// The view goes like this: <TAG data-bind-translate="scopeObjToTranslate.item.text"></TAG>.
angular.module('myApp', ['pascalprecht.translate']).directive('bindTranslate', [
'$translate',
'$parse',
function($translate, $parse) {