0

I want to create some websites on a server with one database. my structure is:

main_domain.com/
main_domain.com/website1
main_domain.com/website2
.
.
main_domain.com/website_n

Some contents are common between websites. I use Django 3 What is best practice for doing this.

Darwin
  • 1,695
  • 1
  • 19
  • 29

1 Answers1

0

Just using the django urls sounds to be good enough practice:

from django.urls import path

urlpatterns = [
    path('website1', viwes.website1),
    path('website2', viwes.website2),
    ...
    path('website_n', viwes.websiten),
]

It depends how many websites you have and how different they are. You might want to consider having the 1, 2, ..., n as a query parameter instead if all the pages use the same content with slight alterations based on the number:

path('website/<website_id>/', views.website_view),

Then you can grab the query parameter in your view like this:

def website_view(request, website_id):
     pass

And so pass the website_id to modify the content of your website like you wish. Again it depends on what your project may need, the first approach may be good enough.

Sorin Burghiu
  • 715
  • 1
  • 7
  • 26