BronzoDev
BronzoDev

Reputation: 47

What is the right way to create projects in Django ? (Folders)

Sorry for the weird question.

I am creating a MMORPG Text browser game, and I feel like my project is wrong. I am creating a new app for everything I need (Account app, Menu app, Fight app). And when I browse Github, people only have like 5/6 folders while I'm at 20 currently.

Where should I put my classes/forms/things normally ? Like, where should I have my fight system placed ?

Thanks ! (Sorry for bad english)

Upvotes: 1

Views: 27

Answers (1)

Laurynas Tamulevičius
Laurynas Tamulevičius

Reputation: 1579

I think, it's completely up to you how you structure your project. But the common thinking is to make Django app reusable (check this out) and separate concerns.

For instance, when creating a Django project I follow these steps:

  1. For every new feature, start a new app, which has its own models, views, templates, static content etc.
  2. Create a separate app called core, to store some general functionality and static files.
  3. Create a test folder instead of a single test.py. This folder has separate modules test_views.py, test_models, test_forms.py.
  4. Create a settings folder which contains base settings general to all environments (i.e. development, testing, production) and then specific settings file for every environment.

I noticed, that this basic structure helps to maintain the order and decouples logic even though the project sometimes contains 15+ apps. If you configure your settings.py properly (e.g. add new apps to INSTALLED_APPS) Django will be able to put your project together nicely, hence I would say don't worry about the number of folders but look at the reusability and separation of concerns.

Also, it is difficult to say where your fight system should reside without seeing project architecture but I would guess that it will be split among these different apps and could be connected in the core app.

Upvotes: 3

Related Questions