0

Have a little problem, tried to google it, but get nothing. What I need: Configure a URL for app in Django, like this:

/myproject/myapp/models.py
class MyApp(models.Model):
    name = models.CharField()
    ....

/myproject/myapp/views.py
def make_something_with_app(app_id):
    # will make smthing cool

Let's think, my site has a "example.com" address, and we have two objects in DB from MyApp model - app1(id=0), app2(id=1). So, what I need? When we go to the app1.example.com, we call make_something_with_app(0), and when we go to the app2.example.com, we call make_something_with_app(1)

Is there a way to make it? Thanks.

Pavya
  • 6,015
  • 4
  • 29
  • 42
  • You want to to run this models from different host names? Or You will use one host name and want to run this models? –  Apr 15 '16 at 07:22
  • I`m not see here any problem. –  Apr 15 '16 at 07:24
  • 1
    I want to use one host name, and run different models with prefixes. @Sayse link me to the multi-tenancy link, I think that's what I need, I'll try django-tenant-schemas and the will close this question, if everything ok. – Nikolay Babych Apr 15 '16 at 07:25
  • You want to use single url for 2 views? For Why? –  Apr 15 '16 at 07:42
  • Nope, I want few urls to 1 views. For example, when we ask for app1.example.com, we get our index view with app1 parameters, and for app2.example.com we get index with app2 parameters – Nikolay Babych Apr 15 '16 at 08:13
  • You question is marked as duplicate, and i can`t to write a script for example. –  Apr 15 '16 at 08:38

0 Answers0