Some parts of my form is rendering correctly but some arent Django

I am creating a ticket app in my django project. When I create a ticket and submit, parts of the form render correctly in the frontend except three fields. These are the ticket.name, category.name and ticket.description, in the frontend these fields display as 'None' but everything else renders as its supposed to in the frontend. I also checked my admin page and i see that neither the Ticket nor the Category get created properly. I'm not quite sure how to proceed.

Here's what i have so far

models.py

class Category(models.Model):
    name = models.CharField(max_length=200, null=True)
    
    def __str__(self):
        return self.name or ''
    
class Ticket(models.Model):
    STATUS = (
        (True, 'Open'),
        (False, 'Closed')
    )
    
    PRIORITIES = (
        ('None', 'None'),
        ('Low', 'Low'),
        ('Medium', 'Medium'),
        ('High', 'High')
    )
    
    TYPE = (
        ('Misc', 'Misc'),
        ('Bug', 'Bug'),
        ('Help Needed', 'Help Needed'),
        ('Concern', 'Concern'),
        ('Question', 'Question')
    )
    
    host = models.ForeignKey(CustomUser, on_delete=models.SET_NULL, null=True, related_name='host')
    category = models.ForeignKey(Category, on_delete=models.SET_NULL, null=True, related_name='category')
    name = models.CharField(max_length=200, null=True)
    status = models.BooleanField(choices=STATUS, default=True)
    priority = models.TextField(choices=PRIORITIES, default='None', max_length=10)
    type = models.TextField(choices=TYPE, default='Misc', max_length=15)
    description = RichTextField(null=True, blank=True)
    # description = models.TextField(null=True, blank=True)
    participants = models.ManyToManyField(CustomUser, related_name='participants', blank=True)
    updated = models.DateTimeField(auto_now=True)
    created = models.DateTimeField(auto_now_add=True)
    
    class Meta:
        ordering = ['-updated', '-created']
        
    def __str__(self):
        return self.name or ''

views.py

view for creating a ticket

def createTicket(request):
    form = TicketForm()
    
    categories = Category.objects.all()
    if request.method == 'POST':
        category_name = request.POST.get('category')
        category, created = Category.objects.get_or_create(name=category_name)
        
        ticket = Ticket.objects.create(
            host = request.user,
            category=category,
            name=request.POST.get('name'),
            status=request.POST.get('status'),
            priority=request.POST.get('priority'),
            type=request.POST.get('type'),
            description=request.POST.get('description'),
        )
        
        return redirect('ticket', pk=ticket.id)
    
    context = {'form': form, 'categories': categories}
    return render(request, 'projects/ticket_form.html', context)

view for ticket page

def ticket(request, pk):
    ticket = Ticket.objects.get(id=pk)
    ticket_messages = ticket.message_set.all()
    participants = ticket.participants.all()
    
    if request.method == 'POST':
        message = Message.objects.create(
            user=request.user,
            ticket=ticket,
            body=request.POST.get('body')
        )
        ticket.participants.add(request.user)
        return redirect('ticket', pk=ticket.id)
    
    context = {'ticket': ticket, 'ticket_messages': ticket_messages, 
               'participants': participants}
    return render(request, 'projects/ticket.html', context)

here is part of the template for the ticket page

<div class="column-layout">
                    <div class="main-column">
                        <h1>{{ticket.name}}</h1>
                        {{ticket.description|safe }}
                    </div>
                    
                    
                    <div class="sidebar-two">
                        <span style="white-space: pre-line"><label for="room_topic">Enter a Category</label>
                            <input required type="text" value="{{ticket.category.name}}" name="topic" list="topic-list" />
                            <datalist id="topic-list">
                            <select id="room_topic">
                              {% for category in categories %}
                              <option value="{{category.name}}">{{category.name}}</option>
                              {% endfor %}
                            </select>
                            </datalist>
                            </span>
                          <div class="form__group">
                            <span style="white-space: pre-line"><label for="room_name">Assigned to</label>
                              {{ticket.assigned}}</span>
                          </div>
                          <div class="form__group">
                            <span style="white-space: pre-line"><label for="room_name">Ticket Status</label>
                              {{ticket.status|yesno:'Open,Closed'}}</span>
                          </div>
                          <div class="form__group">
                            <span style="white-space: pre-line"><label for="room_name">Ticket Priorities</label>
                              {{ticket.priority}}</span>
                          </div>
                          <div class="form__group">
                            <span style="white-space: pre-line"><label for="room_name">Ticket Type</label>
                              {{ticket.type}}</span>
                          </div>
                    </div>
                </div>

This is what it looks like in the admin page. The Ticket database looks the same

enter image description here

Back to Top