Skip to content

Instantly share code, notes, and snippets.

View ryu22e's full-sized avatar

Ryuji Tsutsui ryu22e

View GitHub Profile
@ryu22e
ryu22e / models-1.py
Last active April 3, 2019 08:40
Django 2.2 LTS 主な変更点まとめ(1)
"""CheckConstraintの使用例"""
from django.db import models
class Member(models.Model):
name = models.CharField(verbose_name="名前", max_length=100)
age = models.IntegerField(verbose_name="年齢")
class Meta:
constraints = [
@ryu22e
ryu22e / admin-1.py
Last active March 7, 2019 15:02
Django CSV出力のちょっと面倒くさい話(1)
"""HttpResponseを使う場合"""
import csv
from django.contrib import admin
from django.http.response import HttpResponse
from .models import Book
def export_as_csv(modeladmin, request, queryset):
def reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None):
if urlconf is None:
urlconf = get_urlconf()
resolver = get_resolver(urlconf)
args = args or []
kwargs = kwargs or {}
prefix = get_script_prefix()
if not isinstance(viewname, str):
@ryu22e
ryu22e / signin.html
Last active December 16, 2018 07:13
WebAuthnサインイン(クライアントサイド)
{% load static %}
{# users/signin.html #}
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>サインイン- django_webauthn_example</title>
</head>
<body>
<h2>サインイン</h2>
@ryu22e
ryu22e / backends.py
Last active December 10, 2018 12:49
WebAuthnサインイン(サーバーサイド)
"""users/backends.py"""
from django.conf import settings
from fido2.server import Fido2Server, RelyingParty
from .models import User, WebAuthnPublicKey
rp = RelyingParty(settings.RELYING_PARTY_DOMAIN, settings.RELYING_PARTY_NAME)
server = Fido2Server(rp)
@ryu22e
ryu22e / signup.html
Last active December 16, 2018 07:13
WebAuthnサインアップ(クライアントサイド)
{% load static %}
{# users/signup.html #}
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>サインアップ- django_webauthn_example</title>
</head>
<body>
<h2>サインアップ</h2>
@ryu22e
ryu22e / forms.py
Last active December 10, 2018 12:55
WebAuthnサインアップ(サーバーサイド)
"""users/forms.py"""
from django import forms
from .models import User
class SignUpForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ryu22e
ryu22e / models.py
Last active December 11, 2018 01:36
users/models.py
"""users/models.py"""
import pickle
from django.contrib.auth import models as auth_models
from django.db import models
class User(auth_models.AbstractUser):
"""ユーザー(AUTH_USER_MODELにこれを設定する)"""
display_name = models.CharField(max_length=50, verbose_name="表示名")
@ryu22e
ryu22e / .gcloudignore
Last active December 30, 2018 04:59
Responder==1.0.1( http://python-responder.org/ )で作ったアプリをGAE/Python3.7で動かすサンプル
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files