Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6574523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:16:19+00:00 2026-05-25T15:16:19+00:00

It is design problem. Let’s assume that we have this kind of model in

  • 0

It is design problem.

Let’s assume that we have this kind of model in Django:

class Payment(models.Model):
  purchase = ForeignKeyField(Purchase)
  net_price = DecimalField()
  is_accepted = BooleanField()

  def set_accept(self):
    # there will be some logic, which touch purchase, send emails etc.

  def price_with_tax(self):
    return net_price * (1. + TAX)

We have also another file called actions.py and we implement
there others actions.
Our problem is to determine which kind of methods should be placed in models.py,
which in actions.py.
Do you know any common approach, guide or something like that?
I want to use existing solutions as much as possible.

Thanks

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:16:19+00:00Added an answer on May 25, 2026 at 3:16 pm

    The overall convention in MVC frameworks (like Django) is to place as much logic as possible into your models. This serves a lot of purposes:

    • It binds your logic to your data (good thing).
    • Makes it easy to look to one place in the code for all data manipulation methods.
    • Allows you to run the methods on your models directly without relying on views (makes testing simpler).
    • Gives you a really ‘clean’ API to use in your templates, eg: {{ object.price_with_tax }}, as opposed to rendering different views for different behaviors.

    For your project layout, you should try to keep any code that works on models in your models.py file, and try to avoid using an actions.py or helpers.py unless you really need it. If you do have long amounts of code that aren’t appropriate to put into your models.py (maybe you’re implementing algorithms or something), the convention is to use a helpers.py.

    There’s a lot more stuff you can do later on to keep your app hierarchy clean and organized, but that is the basic gist of it all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a design problem I am facing. Let's say I have a cars
I'm facing a problem which is probably extremely common in game-design. Let's assume that
I don't know how to design this rdbms problem: Let's say, I have a
Let's say I have a class that implements the IDisposable interface. Something like this:
I have a design problem: Question class: have a question and answer (String) TextQuestion
Updated Problem solved, I have some design problem here. The directory looks like that:
Before describing the problem, let me first point out that this is a distinct
I have this concrete problem, but if You find my initial design idea crazy
The problem is mostly OOP design problem. I have a class which handles the
I have this problem where I need to design a Java package which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.