-2

I'm just starting with django even if i'm no new to python, so i'm creating a testing project just to explore django features, workflow and so on.

I already made apps (like the usual polls, books, etc), but now i would like to make an app that gives only functionality with no model nor pages (views and templates): a simple app with some function to be called from the main django project or other apps.

I used the startapp command to crete all the boilerplate, but i cannot understand where to write my code, since it's not a model nor a template etc.

Anyone has already faced this scenario?

Thanks in advance to anyone who can point me in the right direction.

EDIT 1:

I start to think that maybe an app is not exactly what i need, to explain better let's think about an app that provide functionality for e.g.

  • simple interface to web rest api
  • interact with local installed software
  • manipulate custom file format
  • etc

So in fact is much more a library, but every django tutorial i found were about basic books/polls apps, so maybe there is a dedicated approach to my use case but i never stumbled upon it.

fudo
  • 2,254
  • 4
  • 22
  • 44
  • Well typically "*functionality*" means interactiving with models. A very common design pattern is the model-view-controller (MVC). – Willem Van Onsem Jun 07 '18 at 13:03
  • 1
    https://stackoverflow.com/questions/4479901/django-shared-library-classes – Emin Bugra Saral Jun 07 '18 at 13:06
  • Hard to see what is your intent/requirements, but for exporing really minimal django you might want to use https://github.com/syntarsus/minimal-django and – Evgeny Jun 07 '18 at 13:07

1 Answers1

0

usually in every project we have some utility code. Some reusable functions, custom configurations of our project. I prefer to create a core app (Click here to see a example project), and just create a few files in there, something like: utils.py or snippets.py, you decide. If you can contextualize your code inside some folder it should be even better for understanding. But the Django itself doesn't care for how many files you create inside your apps.

Luan Fonseca
  • 1,467
  • 1
  • 13
  • 22