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.