Reputation: 950
If I have an app which stores and displays pizza and topping data, and I want to create a function which creates pizzas (using some complex logic), where is the best place to put it?
Should I create a separate file in the app called create_pizza.py, or is there some sort of best practice for adding this to the pizza model?
I feel like it should be in a separate file, as it will be used by other apps within my project.
Thanks for your advice.
Upvotes: 0
Views: 34
Reputation: 814
you could/should put in a separate file since you are saying it isn't related to view/model/admin and is used by other apps too. it'll help you manage the project easily and easily understandable with less confusion.
Upvotes: 0
Reputation: 599610
A function that is concerned with acting on pizzas should go in the models.py file.
In particular, since it is about creating pizzas, it should probably be a method on a custom Manager class for pizzas. See the docs for more information.
Upvotes: 2