In the website I currently have I display a number of articles, and at the end I display a porfolio of client’s images, all on one landing page.
Is the same functionality achievable in Django out of the box?
Would I have two different views for the articles, and the portfolio of images both linking to one Url? Or would they both be combined into one view with one url? If so how do I break views up into smaller items.
Newbie here…trying to get my head around it.
Ideally, I want to convert my website https://umsiko.co.nz/
take a look if you need a reference to the challenge I need to do.
Not sure what you mean by out-of-the-box in this context.
Can Django do this? Sure.
But, keep in mind that Django is not Wordpress or Drupal or any other CMS. It might be better to think of Django not as a CMS but as a lego set, from which you can make a CMS, or many other types of sites.
In terms of building a page, the most basic perspective is that a view create a page. Django receives a request (url). The url is used to locate the view that will process that request. The view gathers the data to be displayed on the page. The view calls the render function to render a template. The view passes a context containing the data to be rendered to create a page.
So, it’s one view. The view collects whatever data to be used, adding it to the context to be supplied to the template in the render function.
Thanks for the heads-up. Given in a one-page website, you have several different sections not related to each other, do you have any suggestions about breaking the view down into those sections rather than having tons of code in one view?
Sorry if this sounds ridiculous, I’m new to python as well
Normally, what I would do in a class, is have some dependency injection happening, for example. Is that a thing in Django?
Nope, not ridiculous at all.
However, if you’re coming from a different framework, you should consciously work to forget 90% of the patterns you’ve learned from those other frameworks.
If you haven’t worked your way all the way through the Django Tutorial, I suggest you do so before starting anything substantial. If you’re looking for a second source, I can also highly recommend the Django Girls tutorial.
Briefly, the Django Models are the classes that map to your database tables. You’ll find that typically, you’ll retrieve a set of models (known as a QuerySet in Django terms), and build what’s known as a context as being one or more QuerySets.
Even with multiple queries, a view naturally tends toward being small. You don’t need to work to break things apart.
And with that, there’s not much I think I can say that is going to add to this until you’ve worked your way through a tutorial to see what Django does.