On Fri, Jan 5, 2018 at 1:52 PM, Ketul Suthar <k2lsut...@gmail.com> wrote:

> class Profile(models.Model):
>         user = models.OneToOneField(User, on_delete=models.CASCADE)
>         is_manager  = models.BooleanField(default=False)
>         manager = models.ForeignKey(User,related_name='user_manager',
> on_delete=
> models.CASCADE, blank=True,null=True)
>         def __str__(self):  # __unicode__ for Python 2
>                 return self.user.username
>
> Is it right ?


Seems so

how can i create form ?
>

One way:
https://simpleisbetterthancomplex.com/tutorial/2016/11/23/how-to-add-user-profile-to-django-admin.html


>
> On 1/5/18, Ketul Suthar <k2lsut...@gmail.com> wrote:
> > Can you give me example?
> >
> > On Jan 5, 2018 10:09 PM, "Jani Tiainen" <rede...@gmail.com> wrote:
> >
> >> Hi,
> >>
> >> There are numerous ways to achieve what you're asking for, I've been
> >> using
> >> following two:
> >>
> >> You can (and if this a new project, should) create custom user,
> >> regardless
> >> of which one approaches you use.
> >>
> >> 1) For a custom manager add user type field to a custom user model which
> >> says is user a manager or ordinary user. And then add foreign key (or
> >> many
> >> to many if user can have multiple managers) to custom user model to
> self.
> >>
> >> 2)  Have so called "profile", a model with one to one relation to user
> >> model where you put all the same attributes as above.
> >>
> >> Admin can work with both approaches, it's up to you to decide which one
> >> approach suits for you.
> >>
> >> On Fri, Jan 5, 2018 at 6:26 PM, Ketul Suthar <k2lsut...@gmail.com>
> wrote:
> >>
> >>> I am beginner to djnago.
> >>>
> >>>
> >>> I want to create app in which admin can create User and Manager and
> >>> manager is assign to user ?
> >>>
> >>> so how can i achieve ? For  that I have to extend user class bacause
> >>> user
> >>> and manager and admin all three can login in system
> >>>
> >>> --
> >>> 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 post to this group, send email to django-users@googlegroups.com.
> >>> Visit this group at https://groups.google.com/group/django-users.
> >>> To view this discussion on the web visit
> https://groups.google.com/d/ms
> >>> gid/django-users/810439c8-6515-4dc6-808d-643b0f1e38d0%40
> googlegroups.com
> >>> <https://groups.google.com/d/msgid/django-users/810439c8-
> 6515-4dc6-808d-643b0f1e38d0%40googlegroups.com?utm_medium=
> email&utm_source=footer>
> >>> .
> >>> For more options, visit https://groups.google.com/d/optout.
> >>>
> >>
> >>
> >>
> >> --
> >> Jani Tiainen
> >>
> >> - Well planned is half done, and a half done has been sufficient
> >> before...
> >>
> >> --
> >> 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 post to this group, send email to django-users@googlegroups.com.
> >> Visit this group at https://groups.google.com/group/django-users.
> >> To view this discussion on the web visit https://groups.google.com/d/
> >> msgid/django-users/CAHn91oeYGMRN0PcxPHUYtu1k8HheW
> FzwNru5FK%2BmcPZGOkCf8Q%
> >> 40mail.gmail.com
> >> <https://groups.google.com/d/msgid/django-users/
> CAHn91oeYGMRN0PcxPHUYtu1k8HheWFzwNru5FK%2BmcPZGOkCf8Q%
> 40mail.gmail.com?utm_medium=email&utm_source=footer>
> >> .
> >> For more options, visit https://groups.google.com/d/optout.
> >>
> >
>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CANuqdaXN3oFWBPifvfX5ZS-baU6wNVcORp1Jg9dsBp%3Du9Bf0FA%
> 40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BFDnhK8mQFZPHadTRCV1zd5tqKJLydQ9s5SsUrDXDS3YtESgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to