Django's select_related
results in an SQL JOIN.
It's very useful when fetching a one-to-one relation:
class User(Model):
from .extensions import ObjectTypeExtension | |
class OrderWithEvents(ObjectTypeExtension): | |
class Meta: | |
base_type = Order | |
events = graphene.Field( | |
graphene.List( | |
OrderEvent, description="List of events associated with the order." |
export HISTFILE=$HOME/.zsh_history | |
HISTSIZE=50000 | |
SAVEHIST=10000 | |
setopt extended_history | |
setopt hist_expire_dups_first | |
setopt hist_ignore_dups | |
setopt hist_ignore_space | |
setopt hist_verify | |
setopt inc_append_history | |
setopt share_history |
import datetime | |
from graphql import GraphQLObjectType, GraphQLScalarType, GraphQLSchema, graphql, parse | |
from graphql.execution.base import ResolveInfo | |
from graphql.utils.build_ast_schema import build_ast_schema | |
def build_schema(schema_description: str): | |
ast_schema = parse(schema_description) | |
return build_ast_schema(ast_schema) |
/* ~/.themes/YourTheme/gnome-shell/gnome-shell.css */ | |
stage { | |
font-family: "System Font"; | |
} | |
#panel { | |
font-weight: normal; | |
} | |
#panel .panel-button { | |
color: #ffffff; | |
font-weight: normal; |
from django.contrib.auth.decorators import login_required | |
from django.template.response import TemplateResponse | |
from django.utils.decorators import method_decorator | |
from django.views.generic import View | |
class MyClassBasedView(View): | |
@method_decorator(login_required) | |
def dispatch(self, *args, **kwargs): | |
return super().dispatch(*args, **kwargs) |
from django.views.generic import View | |
from django.template.response import TemplateResponse | |
def get(request): | |
return TemplateResponse(request, 'index.html') | |
my_class_based_view = View.as_view(dispatch=get, __init__=7, as_view=None) |
from django.views.generic import View | |
from django.template.response import TemplateResponse | |
def get(request): | |
return TemplateResponse(request, 'index.html') | |
my_class_based_view = View.as_view(dispatch=get) |
from django.views.generic import View | |
from django.template.response import TemplateResponse | |
def get(request): | |
return TemplateResponse(request, 'index.html') | |
my_class_based_view = View.as_view(http_method_not_allowed=get) |
from django.views.generic import View | |
from django.template.response import TemplateResponse | |
def get(request): | |
return TemplateResponse(request, 'index.html') | |
my_class_based_view = View.as_view(get=get) | |
# TypeError: You tried to pass in the get method name as a keyword argument to View(). Don't do that. |