Похожие чаты

In a Django project am working on, I need to

have 2 user types. One is an Owner and the other is a Reseller

The superuser creates owners, and the owners create resellers under them. I want to keep track of which Resellers are registered under which Owner by connecting Owners and Resellers table via a Foreign Key. So no reseller can create an account by themselves, their owners should do that for them. How can I accomplish this?

you can find what I have tried so far in the link below

https://www.reddit.com/r/django/comments/rd9o9u/how_to_let_one_type_of_users_create_another_type/

9 ответов

12 просмотров

There are several ways to accomplish this. But the most "Django" way would be using the permissions system.

ᶰᵃᵇʳᵒˡᵉᵒᶰ- Автор вопроса
ᶰᵃᵇʳᵒˡᵉᵒᶰ
Can you expand on that a little?

You can create permissions that allow users to do some action, and then you assign those permissions to either the user directly, or a group.

ᶰᵃᵇʳᵒˡᵉᵒᶰ- Автор вопроса
Gian
You can create permissions that allow users to do ...

Yes I can but how can I keep track which resellers are under which owners?

ᶰᵃᵇʳᵒˡᵉᵒᶰ- Автор вопроса
Gian
Oh, that'd be using Django ORM, of course.

Yeah I got that, what I wanted to say is, I wanted to is that, I was trying to connect the Owner model and the Reseller like this using foreign key, class Reseller(models.Model): user = models.ForeignKey(Owner, on_delete=models.CASCADE) but It don't seem to do the job, I still can't know which reseller is under which owner, I was hoping if you could shed some light on that

ᶰᵃᵇʳᵒˡᵉᵒᶰ
Yeah I got that, what I wanted to say is, I wanted...

Well, both reseller and owner are users, no? So, you make both have a user as foreignkey. But, you also make a one to many relationship between the owner and the reseller (I"m assuming a owner can "own" multiple resellers)

ᶰᵃᵇʳᵒˡᵉᵒᶰ- Автор вопроса
Gian
Well, both reseller and owner are users, no? So, y...

Both Owner and Reseller are users, The superuser add owners and Owners can add multiple resellers

ᶰᵃᵇʳᵒˡᵉᵒᶰ
Both Owner and Reseller are users, The superuser...

Yeah, one to many, as a I said. And you want to cascade that when you delete a owner, it removes all resellers

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта