T
T
tetafro2015-09-04 16:17:25
Django
tetafro, 2015-09-04 16:17:25

How to organize authorization in Django with multiple applications?

There is a project with two applications - for issuing pages (browser view) and for api (mobile application). Both must use the same user model. What is the (ideologically) correct way to do this? Start a separate application for users? But what to insert into it besides the actual model?
I know that you can simply add users to the model of one of the first two applications, and simply import it in the second, but it seems that this is somehow ugly - after all, the applications are equal, and the model will be in one of them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2015-09-04
@tetafro

#myuserapp/models.py
class MyUser(AbstractUser):
....


#app1/models.py
from myuserapp.models import MyUser

class MyThingInApp1(models.Model):
     user = models.ForeignKey(MyUser)
....


#app2/models.py

from myuserapp.models import MyUser

class MyThingInApp2(models.Model):
     user = models.ForeignKey(MyUser)

Z
zelsky, 2015-09-04
@zelsky

REST full API if you understand the question correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question