Helli Anne, Authirization is automatical implemented in django. You need a login page and ggf. A Registration page.
https://ordinarycoders.com/blog/article/django-user-register-login-logout This has nothing to do with a relationship from article to a User or a node. Regards Regards 'AnneVerm' via Django users <django-users@googlegroups.com> schrieb am Do., 24. März 2022, 11:54: > Hello, > > Thanks for your reply. > > I have a Postgres database, node, organization, person and thing are > modelled like this: > > CREATE TABLE public.ntw_node > ( > id integer NOT NULL DEFAULT nextval('ntw_node_id_seq'::regclass), > CONSTRAINT ntw_node_pkey PRIMARY KEY (id) > ) > > CREATE TABLE public.ntw_organization > ( > id integer NOT NULL DEFAULT > nextval('ntw_organization_id_seq'::regclass), > nodeid integer NOT NULL, > -- organization specific fields > CONSTRAINT ntw_organization_nodeid_fkey FOREIGN KEY (nodeid) > REFERENCES public.ntw_node (id) MATCH SIMPLE > ON UPDATE CASCADE > ON DELETE CASCADE > ) > > CREATE TABLE public.ntw_person > ( > id integer NOT NULL DEFAULT nextval('ntw_person_id_seq'::regclass), > nodeid integer NOT NULL, > -- person specific fields > CONSTRAINT ntw_person_nodeid_fkey FOREIGN KEY (nodeid) > REFERENCES public.ntw_node (id) MATCH SIMPLE > ON UPDATE CASCADE > ON DELETE CASCADE > ) > > CREATE TABLE public.ntw_thing > ( > id integer NOT NULL DEFAULT nextval('ntw_thing_id_seq'::regclass), > nodeid integer NOT NULL, > -- thing specific fields > CONSTRAINT ntw_thing_nodeid_fkey FOREIGN KEY (nodeid) > REFERENCES public.ntw_node (id) MATCH SIMPLE > ON UPDATE CASCADE > ON DELETE CASCADE > ) > > > I am not sure how to get from the relational model to the object oriented > model so that I can use > Django's ORM. > > An organization could be a rugby club, a bakkery, an accountants office, a > person could be a consultant, > a trainer, an athlete. > > At the moment nodes and users are related one-to-one: > > CREATE TABLE public.auth_user > ( > id integer NOT NULL DEFAULT nextval('auth_user_id_seq'::regclass), > nodeid integer, > ... > CONSTRAINT auth_user_nodeid_fkey FOREIGN KEY (nodeid) > REFERENCES public.ntw_node (id) MATCH SIMPLE > ON UPDATE CASCADE > ON DELETE CASCADE > ) > > However, in reality nodes are not necessarily related to users one-to-one, > there are nodes managed > by a root or admin user, as in the django admin they have access to all > data related to a node. > > In the Django tutorials I've done sofar for example an article is modelled > like this: > > class Article(models.Model): > title = models.CharField(max_length=255) > ... > author = models.ForeignKey( > settings.AUTH_USER_MODEL, > on_delete = models.CASCADE, > ) > > So the question is_authorized is answered using settings.AUTH_USER_MODEL. > In my case article would > be modelled like this: > > class Article(models.Model): > title = models.CharField(max_length=255) > ... > node = models.ForeignKey( > Node, > on_delete = models.CASCADE, > ) > > Here I'm stuck at how to authorize a user. I hope I provided you with > sufficient information > to point me in right direction. > > Anne > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/36bbdfeb-3d27-4b64-860c-048460458a5dn%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/36bbdfeb-3d27-4b64-860c-048460458a5dn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKGT9my9L2VjURck3fwyYfp5AGEamCHfuZCTSgBLwHufxgLWVw%40mail.gmail.com.