Skip to content

Examples with larger models #138

@eddielu

Description

@eddielu

Thanks for this amazing style guide. I just started following.

Quick question: the examples used in this guide all have very tiny models with <=5 fields. In real life, it feels like most production models grow up to 20+ fields easily.

This is problematic since the guide seems to suggest that fields are retyped out for service functions. For example,

def course_create(*, name: str, start_date: date, end_date: date) -> Course:
    obj = Course(name=name, start_date=start_date, end_date=end_date)

    obj.full_clean()
    obj.save()

    return obj

Is the recommendation really to type out all field names again inside service functions? It feels like this leads to cases where one makes a model change but forgets to add the parameter in service functions. Also it leads to obscenely long function definitions that are difficult to maintain.

I'm curious what you all have done here in your development. Thanks again. Wishing you blessings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions