I'm new to Django framework and currently working on an ecommerce website. Not sure what would be better, when creating new project and new app in Django, does a single app is enough and fine for whole website functionally(all HTML pages, user login/registration etc) or should I use separate apps in my project?
one app for one purpose.
don't describe your app with 'and'.
like: my_app_name' to manage students and exams.
just create 'students' app to manage students and 'exams' to manage exams
According to the great book on django 'Two scoops of django' we should create an app for only one purpose. If the work of an app is beyond a topic we should create another one.
So I think you should create separate apps for various tasks of your web-application like:
accounts : app for user model
products : app for product model
orders : app for managing orders
payments : app for the order payments
...
and many more.
As far I have used Django in my profession about four years, I think Django and python is comprehensive kit for building e-commerce web app.
Related
Let's say I have 1 Django project where I want host multiple websites on with different domains. I managed to set it up but progressing further is where I get confused.
We'll call them store1.com, store2.com
I can route to both sites through a custom middleware that checks the url where the request comes from and that is working fine.
Both stores have it's own apps like cart, category, product, account and so forth.
What would be the best practice to structure this?
Do I put everything from a store inside 1 app or is it better to have all these models and views in a separate app and keep checking the request so that the app knows which URL to serve?
IMHO the best way is to create an app for all the different functionalities and then use Django Sites framework to manage multiple sites.
You can read more on the Django documentation
I'm new to Django and trying to understand the preferred means of operation when building an application
Let's say i'm making an e-commerce application that allows sellers to sign up, upload their products etc and allows buyers to sign up, add products to their cart and place orders. They're all part of the same "web application". So there's the shop, buyer and sellers and ofcourse the site admin.
Would this mean I have a shop app, buyer app and seller app? since they'll all have their profile pages. Or they can all be together a single app?
Apps structure must contain similar group of models ans behaviours. It' something subjective and on little details it can change a little bit, but you must try to make it most simple and intuitive for everyone. For example, for a shop project, i would create these apps: configuration, users, products, orders, discounts...
So ... No. Not every model in Django has to have a correspondind reusable app.
I'm new to Django and am currently struggling with how to structure the apps.
The site is one with a public frontend, in which you can login to enter a dashboard. I've created a separate app for this dashboard.
Now I want to display a list of employees on one page of this dashboard, however I've created another app for these employees.
Should I create this new page/view, in the employees app? Or should I delete this employee app, and include that model in the dashboard app?
What is considered good practice?
It currently looks like this:
-site
-- dashboard app
-- employee app
Source: Two Scoops of Django: Best Practices for Django 1.8 p-35
I've developing in django for the past few months and I find it extremely great.
My next project is a price-comparing site for local businesses - where each user can add business and comment on each.
The admin of the site won't be a programmer, but with basic knowledge in web and python.
Should I stick to the old familiar django or should I try it out?
Thanks :)
Matan.
django CMS is built on top of Django and meant to be integrated into existing Django applications or extended with new ones. So your question is flawed.
So instead ask yourself if you need CMS functionality (pages managed by your admins). It sounds like your main app (the compare bit) is better handled by a Django application, but maybe you want the site admin to be able to easily edit the About Us page etc, this is where django CMS could come in handy.
I am migrating an existing small business admin system that uses a variety of spreadsheets and access databases to a Linux server to provide both intranet and internet access to our own office staff, to external partners and to customers.
There is some fairly complex database work which will be using postgreSQL and python.
There needs to be a professional looking public website which can access some of the database content both to generic "customers" and tailored data visibility to actual clients.
None of the traditional CMS offerings like wordpress, drupal, joomla etc seemed flexible enough, so I found my way to django.
I've built models, populated data tables, built some basic views to manipulate the data and started to play a bit with html layout tags and css, and I've started looking at forms including crispy-forms.
I need to work with pdf files - scanning, uploading, splitting into single pages, displaying on the site alongside form data entry etc.
I was hoping that I could use django-cms to handle the aspects of the public facing words and pictures and dealing with the jpgs pdfs etc, and to do the page layout stuff, while using django models and python to simplify the database access and provide the intelligence.
When I read the django-cms docs around integrating models I get the impression that there is not really a proper integration - that you can build a site that switches between cms pages and django pages or maybe embeds a django view into a cms page, but I'm not sure if I can do the look and feel and static bits in cms and the dynamic bits on the same page in django without still having to do the work in django as well.
the django system revolves around the models, the django-cms docs read as if models are some sort of extra bit you might want to use.
There's talk of the different ways to integrate django models but they all treat the django model as a foreign item that can be added.
I've found other people who've asked "how does django-cms work with django models" and the answers seem to be no different from those that ask "how do I ad a django model to a drupal site"
So my question really is - does django-cms integrate with django to provide ease of building sites with good integration between cms features and model features or are they really two separate systems that can share space on the same page with a bit of work but don't play nice together in any useful way?
Is there another tool I can use for my static stuff and page formatting and navigation to integrate with my models and python code?
Yes
Yes, it does integrate with django and it does provide ease of building sites with good integration between cms features and model features. Like comment by Simeon Visser hinted - you can create your own plugins to add managing different features into django cms part. And most often - most things will not need such integration - simple django admin views and models will suffice.