Django 3: Unable to generate dynamic object view

I have successfully created the expected structure for my model and in the error variables I can see that the DB object was returned but I am not able to resolve the page. I am getting error " TypeError at /ticket-edit/2 - init() got an unexpected keyword argument 'instance' " - am I referencing the object incorrectly? I want to use the existing TicketForm but populate the result with the field values from the URL.

In the error the local var shows that the expected ticket was retrieved:

Variable: Value 
  • aTicketID: '2'
  • context: {}
  • obj: <Ticket: 2 2021-10-06 Ticket Title Ticket Desc> request
  • <WSGIRequest: GET '/ticket-edit/2'>
  • Exception Location: /, line 118, in ticket_edit
  • line 118 is: updateform=TicketForm(instance=obj) (I use URL instead of path to generate the ID link)

urlpatterns = [
    url(r'^ticket-edit/(?P<aTicketID>\d+)', views.ticket_edit, name='ticket-edit')

class Ticket(models.Model):
    #---Base Meta-----------------------------------------
    appTicketID = models.AutoField(primary_key=True)
    date_submitted = models.DateTimeField(
    issue_title = models.CharField(max_length=90)
    issue_description = models.CharField(max_length=1000)
    def __str__(self):
        return (f"{self.appTicketID} "
                f"{self.date_submitted} "
                f"{self.issue_title} "
                f"{self.issue_description} "

    def get_absolute_url(self):
        return reverse_lazy('ticket-edit', kwargs={'aTicketID': self.appTicketID}

def ticket_edit(request, aTicketID):
    context = {}
    if aTicketID == None:
        aTicketID = 1
    aticket = Ticket.objects.filter(appTicketID=aTicketID)
    print('TicketFiltered: ', aticket)
    context = {
        "has_error": False,
        "updateform": updateform,
        "aticket": aticket
    return render(request,'appname/ticket-edit.html', context)

Answers: 0