How can I scale my application to different teams ?

34 views
Skip to first unread message

Kumar Gaurav

unread,
Nov 30, 2021, 5:11:49 AM11/30/21
to Django users
Hello All,


I have a recognition portal where people can post recognition for their team members. It is being used within one team only at present.
Now I want to scale it to other teams but I want to render only the content specific to their team coming to the portal. Means If I am from Team A , I should see only the posts done by my team member and not others.

I am not using the Django pre defined User model as authentication is done through SSO.

How Can I group the users and show the contents related to them only.  

Can someone show me the correct direction to proceed. Any help is very much appreciated.

Thank You!!

Abhishek Choudhury

unread,
Nov 30, 2021, 6:13:54 AM11/30/21
to django...@googlegroups.com
Hi Gaurav,

This might be a way of solving your situation, You can use customuser model and then add a field like role or group ( choice field of Team A, Team B). Once you have segregated the user in groups, you can check the user.role at the time of log in and then redirect them to their own dashboard/views. 

Thanks and regards, 
Abhishek Choudhury 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d4894e89-18fe-49cd-a40f-718a16c9ac60n%40googlegroups.com.
--
Thanks and regards,
Abhishek Choudhury
Mobile: +91 7903717967

Stijn Verholen

unread,
Nov 30, 2021, 6:51:30 AM11/30/21
to django...@googlegroups.com

Define a method on your queryset that sets up the filter


class RecognitionQuerySet: def allowed(self, user): return self.filter(team=user.team)

Class RecognitionManager: def get_queryset(self): return RecognitionQuerySet(self.model, using=self._db)

Class Recognition: objects = RecognitionManager()

recognitions  = Recognition.objects.all().allowed(user)

Tim Chase

unread,
Nov 30, 2021, 9:03:53 AM11/30/21
to Kumar Gaurav, django...@googlegroups.com
On 2021-11-30 02:11, Kumar Gaurav wrote:
> How Can I group the users and show the contents related to them
> only.

You presumably have some sort of User model and have added some sort
of Group model. Depending on your business logic, either a User can
belong to one-and-only-one group in which case you'd have a
"User.group" foreign key; or a User can belong to multiple groups, in
which case you'd have a many-to-many relationship between users and
groups.

I'd bias towards the latter even if *current* business rules say that
a person can only be a memeber of one group. It's easier to design
for multiple groups now and then only use one. It's much harder to
design for one-group-per-person now and then switch to
a-person-can-be-in-more-than-one-group later.

Similarly, I imagine that Posts get associated with a particular
group. Or maybe they can be broadcast to multiple groups.

Then filter Posts based on Groups associated with the
currently-logged-in User.

-tkc


DJANGO DEVELOPER

unread,
Nov 30, 2021, 9:08:19 AM11/30/21
to Django users
I would like to know about sso. Answer related to your question is you can use tuple before your custom user model and then pass it with choices=created tuple ajd then in your v views just filter the team posts according the given role.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

arpanb...@gmail.com

unread,
Nov 30, 2021, 9:16:08 AM11/30/21
to Django users
The first thing you can do is create a model to save user details. Then, you could create a mapping of users and teams using another model. This model would establish foreign key constraint between user and team entity. Then, the foreign key should help you in accessing team specific data.
Reply all
Reply to author
Forward
0 new messages