Похожие чаты

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 ответов

11 просмотров

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

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

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

Ready for some fun AND a chance to win TKO Tokens? Join us for exciting minigames in our Telegram group! 🕒 Don’t miss out—games start on today 25 October 2024, at 8 PM! Ge...
Milkyway | Tokocrypto
255
Мужики и девушки, привет) в Вelphi xe7 в настройках во вкладке "Editor Options" далее " Color" есть список: "Elements", открыв который мы можем настраивать отображение разных...
Kraszx
14
VIP-392 [zkSync] New native USDC market in the Core pool Summary If passed, following the Community proposal “Support native USDC on Venus Core Pool of ZKSync Era” and the a...
Venus Announcements
1
is that okay?
Samurai 🇯🇵
21
Добрый вечер. Есть вопрос, а может и предложение. Был у меня диалог в другой группе о делфи и я задался вопросом: "А нельзя ли в делфи цвет //коментария и {комментария} сде...
Kraszx
24
How about the project bro Likes the community not that active ?
🅿️abby_FX
19
Я вот подумал. SSE выполняет операции максимум с 64-битной точностью. А FPU - всегда с 80-битной. Разве не должно быть FPU точнее тогда?
The Bird of Hermes
13
Guys, Donald Trump or Kamala Harris? It does not matter for Bitcoin in the long run!! 2020 Election: After Joe Biden's victory in November 2020, Bitcoin steadily rose from...
Sabah Shabu
3
как быть с принтером? такой подход прокатит?
zamtmn
12
Мдя, прикол, боевая сборка запускается (именно под отладчиком) после F9 примерно полторы минуты (97 секунд если быть точным). Начал копать - проблема детектится сразу - зависа...
Александр (Rouse_) Багель
38
Карта сайта