Django: rest_framework

ModelSerializer

data

retrieve lookup

Override APIView

permission

HyperlinkedIdentityField

MethodField

    發表留言

    Django Staticfiles

    urls.py

    settings.py

    collectstatics: add internal statics to external(dev) statics

    Direcotry

     

    發表留言

    Django User Model

    Extent User Model

    User login

    Third Part Packages

    • Django Registration Redux
    • Django All Auth
    • Python Social Auth

     

    發表留言

    Django Forms

    Cross Site Request Forgery

    Html form vs Django form

    Validation

    Initial data

    ModelForm

    Setting fields in a model form

    Render field manually

    Include Snippet

    Formset

    Model Formset

    Management

    Query

     

    發表留言

    Django Class Base View

    Template View

    doc: base.py

    • View: Intentionally simple parent class for all views. Only implements dispatch-by-method and simple sanity checking.
    • TemplateView: Render a template. Pass keyword arguments from the URL conf to the context
    • TemplateResponseMixin: A mixin that can be used to render a template
    • ContextMixin: A default context mixin that passes the keyword arguments received by get_context_data() as the template context

    Custom Mixin

    Generic display views: Detail View

    Reverse

    Generic display views: Create View

    Handle MultipleObjectReturned

    SuccessMessageMixin

    FormMixin

     

    發表留言