On Fri, May 13, 2022 at 09:27:48AM -0700, 'dtdave' via Django users wrote:
> I have the following code:
> from django.conf import settings
> from django.db import models
> 
> class AccountManager(models.Model):
>     account_manager = models.ForeignKey(
>         settings.AUTH_USER_MODEL, on_delete=models.PROTECT, null=True, 
> blank=True
>     )
> 
>     class Meta:
>         verbose_name = 'Account Manager'
>         verbose_name_plural = 'Account Managers'
> 
>     def __str__(self):
>         return str(self.account_manager)
> The view for this, effectively a profile, is as follows
> 
> from django.contrib.auth import get_user_model
> from django.shortcuts import render
> from django.views.generic import DetailView
> from django.contrib.auth.mixins import LoginRequiredMixin
> 
> from .models import AccountManager
> 
> User = get_user_model()
> 
> 
> class AccountManagerDetailView(LoginRequiredMixin, DetailView):
>     model = AccountManager
>     template_name = "accountmanagers/dashboard.html" 
>  
>     def get_object(self, *args, **kwargs):
>         return self.request.user
> 
> And the url:
> urlpatterns = [
>     path('detail/', views.AccountManagerDetailView.as_view(), 
> name='accountmanagers'),
> ]
> The template then shows the relevant user details but my problem is that I 
> am stuck allocating the clients to the specific account manager. I know 
> that I am missing the point in implementing a queryset and tieing it to 
> that user.
> Any help would be appreciated.

What would you like the relationship between client and account manager
to be?  One to one?  One to many?  Many to many?

- Ryan N

-- 
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/20220523140201.GC10089%40fattuba.com.

Reply via email to