Against service layers in Django - Deepstash
Metaverse

Learn more about computerscience with this collection

Find out the challenges it poses

Learn about the potential impact on society

Understanding the concept of Metaverse

Metaverse

Discover 76 similar ideas in

It takes just

11 mins to read

Business logic

Business logic

  • Business logic refers to common queries and operations that are performed repeatedly on models.
  • Views should contain little business logic and rely on models for that.
  • Logic that involves one model instance should go on the model class; logic that involves multiple or all instances should go on the model's QuerySet or manager.

4

34 reads

Model recommendations

Model recommendations

  • Alternate/complex constructors for model instances should be implemented as manager methods. (e.g.Ā User.objects.create_user)
  • Custom, complex or often-used queries on the entire table should be implemented as QuerySet or manager methods.
  • Table-level queries should be implemented as a QuerySet method when they need to be chained, and as a manager method otherwise.
  • Complex fetching of related objects from a model instance should be implemented as a model method.

3

14 reads

Limit model access

Limit model access

For code outside of the model class:

  • Access to model fields for reading should be discouraged --> Instead define model methods that implement the logic you need
  • Access to model fields for writing should be forbidden --> Instead define model methods that change the state of the object
  • Access to save() and delete() should be forbidden --> Same as above
  • Access to query methods other than all() should be discouraged --> Instead define QuerySet or manager methods

3

15 reads

IDEAS CURATED BY

ocpodariu

Alt account of @ocp. I use it to stash ideas about software engineering

Other curated ideas on this topic:

Read & Learn

20x Faster

without
deepstash

with
deepstash

with

deepstash

Personalized microlearning

ā€”

100+ Learning Journeys

ā€”

Access to 200,000+ ideas

ā€”

Access to the mobile app

ā€”

Unlimited idea saving

ā€”

ā€”

Unlimited history

ā€”

ā€”

Unlimited listening to ideas

ā€”

ā€”

Downloading & offline access

ā€”

ā€”

Supercharge your mind with one idea per day

Enter your email and spend 1 minute every day to learn something new.

Email

I agree to receive email updates