Building an online store with Django: Python backend and frontend integration

I’m trying to create an online store and I’ve decided to use Django for the backend. I’m pretty comfortable with HTML, CSS, and JavaScript for the frontend. I’m also thinking about using Bootstrap to make things look nice.

For the database, I’m leaning towards MongoDB. But I’m not sure how to put all these pieces together.

Can someone give me a rundown of the basic steps I need to take? I’m especially confused about:

  1. What files and folders I need to set up in my project
  2. How to connect the frontend to the Django backend
  3. Setting up the database with MongoDB

I’ve looked at some tutorials, but they all seem to do things differently. Any advice on the best way to structure an e-commerce project like this would be super helpful. Thanks!

hey there! i’ve built a few online stores with django. here’s my advice:

stick with django’s default sqlite database for now. mongodb can be tricky to integrate.

for structure, use django’s built-in template system. create a ‘templates’ folder for your HTML files and a ‘static’ folder for CSS/JS.

django handles frontend-backend connections automatically. Just use template tags to display data.

hope this helps get u started!

While Django is a solid choice for e-commerce, integrating MongoDB might complicate things unnecessarily. Consider using PostgreSQL instead - it’s robust and works seamlessly with Django.

For project structure, follow Django’s conventions. Create apps for different functionalities like ‘products’, ‘cart’, and ‘orders’. Use Django’s ORM for database interactions.

To connect frontend and backend, leverage Django’s template language. It allows you to embed Python-like code in your HTML.

For styling, Bootstrap is a good choice. Include it in your base template and extend from there.

Remember to set up your urls.py files properly to route requests correctly. Also, look into Django REST framework if you plan on building an API later.