dotfiles/vscode/.vscode/extensions/batisteo.vscode-django-1.15.0/completions/snippets/views/methods.toml
2024-08-19 17:03:43 -06:00

55 lines
1.1 KiB
TOML

[[snippets]]
prefix = "dispatch"
detail = "dispatch(self, request, *args, **kwargs)"
body = """
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
"""
[[snippets]]
prefix = "get_context_data"
detail = "get_context_data(self, **kwargs)"
body = """
def get_context_data(self, **kwargs) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
context["$1"] = $2
return context
"""
[[snippets]]
prefix = "get_queryset"
detail = "get_queryset(self)"
body = """
def get_queryset(self):
${1:return} super().get_queryset()$0
"""
[[snippets]]
prefix = "get_template_names"
detail = "get_template_names(self)"
body = """
def get_template_names(self) -> list[str]:
if ${1:condition}:
return ["$2"]
return super().get_template_names()
"""
[[snippets]]
prefix = "form_valid"
detail = "form_valid(self, form)"
body = """
def form_valid(self, form):
${1:form}
return super().form_valid(form)
"""
[[snippets]]
prefix = "form_invalid"
detail = "form_invalid(self, form)"
body = """
def form_invalid(self, form):
response = super().form_invalid(form)
${1:response}
"""