On my HTML page, I have a list of Agent's (Agent is my custom User model).  
Beside each agent is a 'Send Invite' button.  To create a `TeamInvitation`, 
I need to specify which Agent is attached to its `receiver_agent` field (a 
OneToOneField with Agent)

There are multiple Agents displayed on the HTML page, and they are listed 
in order with template tags.  I need to input something after `pk` at 
`receiver_agent = Agent.objects.get(pk = ???)`, but I don't know what to 
input.

*views.py*

    class InviteAgentSearchResults(ListView):
        model = Agent
        form_class = AgentSearchForm
        template_name = 'invite_agent_search_results.html'
        
        def get_queryset(self):
            # ... Code to find correct list of agents
        
        def post(self, request, *args, **kwargs):
            invite = TeamInvitation.objects.create(receiver_agent = 
Agent.objects.get(pk = ???))
            return HttpResponse('Invite successfully sent.')

*HTML:*

    {% for agent in agent_list %}
    <div class="agent">
    # ... Some code here

            <form method="post">  # The "Send Invite" button
                {% csrf_token %}
                <button class="button1"><span>Send Invite</span></button>
            </form>
    </div>
    {% endfor %}

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/bd0439e2-7fdd-4f7c-b6ce-4847d4a877c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to