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 trialChris Howell
Python Web Development Techdegree Graduate 49,702 PointsDjango Project Structure
So I know we haven't begun the Python Django framework yet. I am hoping maybe there are some other students or staff such as Mr. Kenneth Love, that could provide some insight into this.
So I was having a hard time explaining the first time I wrote it so I had to map it out visually. Here is a Link to the picture
The way I am currently building my project is on the LEFT. My main idea is to have the MySite project be a sort of generic "wrapper" and "face" of the web app containing more subprojects that then contain apps. The generic MySite project would contain the Links to navigate around to each separate project and that project would have its own apps and would even use a separate database than MySite.
But the way django is structured by default is to have only 1 main project that contains as many apps as you want which is how I am building my current one. Apps inside Apps inside Apps.
1 Answer
Kenneth Love
Treehouse Guest TeacherApps inside apps inside apps isn't the Django default for a reason :) It's generally more confusing than it's worth. If you really feel like you need this, I'd suggest creating your nested apps as stand-alone apps that you can install into your project. It's more work, but things will be cleaner and you'll be able to keep track of where you are a lot better.
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsChris Howell
Python Web Development Techdegree Graduate 49,702 PointsWell let me give you an example, maybe you could tell me how you might approach it. I have fried my brain a few times trying to figure out how I want to go about making this.
I built a web app similar to that of a combination of Pandora/Netflix. My first go at making this it worked out fine because the Media was my only concern until I got it all working. But then I wanted to make it do more and I wanted my Media models to do more, have more functionality and inherit more. This is where the problems start. You start abstracting more generic models like 'Video' so 'movies' app and 'clips' app can inherit. But with this one inheritance you just created an immediate dependence of these two apps on Video. Unless I repeat my code, which of course im not going to do. Then what happens if I want to abstract a little more, like make a Media model to have all models inherit certain properties from? This is starting to look like its own project in its own. My folder structure is getting bigger so I would have to come up with less generic names, names that would let me know which apps are dependent. The only solution seems to be apps inside apps. Like building a "media" app inside and having subfolders named 'movies', 'music', 'images' with models.py files which then import from media. Then as you look at your code it feels messy and wrong. And then you start seeing sad faces in the console from Python> :( :(