Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Nursultan Bolatbayev
Nursultan Bolatbayev
16,774 Points

Im creating a website for my final project based on Django. But I dont know how to organize my Django project layout?

I will have a website which collects data from end nodes (sensors) and store the data in postresql. At "home" page there will be static file, which just shows general information and diagrams, pictures. At page "settings", will have system to send commands to end nodes (to change configurations of sensors). There are 4 nodes and each node will have a separate page to visualize and graph stored data. So I suggest that 'setting' page is standalone app, and each node will have own app or under common nodes app? Any ideas and advices are appreciated!

2 Answers

This sounds like an interesting project.

I would avoid calling an app in your project "settings". Django uses a python file called settings.py and maybe you or it would get confused down the road. Maybe sensor_configation?

I would write down what tables/models there are and try to see if they fall into some clear groups, then make each of those groups an app. If they all are going to be related and you would never use them in another django project, put them in the same app.

Nursultan Bolatbayev
Nursultan Bolatbayev
16,774 Points

Thank you for reply. Yes, it seems reasonable not to name app "settings". Good point!

I suggest that I will create one app ("nodes") for end nodes. In that app there will be class "Node" which has attributes as nodeID, timestamp (when added this node), updated (when it was the last time updated), location (GPS location, though end nodes will be fixed and wont change location, not sure yet).

And also in that app I will have another class "Parameters" with attributes (collected data from sensors): ACI, humidity, temperature, pressure, light, datetime(when each parameter received) and foreignkey with "nodeID" from "Node" class. But Im not sure do I need to create app for "sensor_configuration", because at this page I wont do anything related to database, configuration will be sent direcrtly to end nodes, as I understand app is created for function if it works with database, right?

Overall am I on right way?

Have you ever hear this quote:

There are only two hard things in Computer Science: cache invalidation and naming things.

-- Phil Karlton

Just my opinion: nodes is often used computer term, as is Parameters. Is there some name more meaningful in the remote sensing field for what you are modeling?

do I need to create app for "sensor_configuration", because at this page I wont do anything related to database

Will you store the settings the user of the web app wants to send to the sensors? Perhaps you need to know what the settings are to understand the data coming back from the sensors?

I think you are on the right way.

Nursultan Bolatbayev
Nursultan Bolatbayev
16,774 Points

First time) Ok, got this point. I will think about renaming it to more meaningful.

So u mean if I wont store sent configurations(commands) to remote sensor then no need to create app for it? If I want to store sent configurations like "current configuration" then I need to create app for this, right?

Secondly, u mean the data coming back from the sensors it is the response message like "applied/OK/confirmed" meaning successfully applied to sensors? If yes then to handle these responses or based on unsuccessful response to re-send my commands I will need app anyway, right?

Thank you)