How to add Django Object Models to A Separate List

I am creating an app for a school schedule using Django. Admin users can currently add classes to a list. Student users can view that list but I want to create a button/link that will add that class object to a separate list that will act as their applied classes.

Models.py

class Class(models.Model):
def __str__(self):
    return self.name

name = models.CharField(max_length=50)
crn = models.CharField(max_length=5, validators=[RegexValidator(r'^\d{1,10}$')])
grade_mode = models.CharField(max_length=50)
subject = models.CharField(max_length=3)
course_num = models.CharField(max_length=4, validators=[RegexValidator(r'^\d{1,10}$')])
section_num = models.CharField(max_length=3, validators=[RegexValidator(r'^\d{1,10}$')])
credit_hours = models.FloatField(validators=[MinValueValidator(0.0), MaxValueValidator(5.000)])
teacher = models.CharField(max_length=50)

Views.py

@login_required
@dec.student_required
def index(request):
class_list = Class.objects.all().order_by("-name")

# Allow for Posting of New Classes to Schedule.
if request.method == "POST":
    form = ClassesForm(request.POST)
    if form.is_valid():
        form.save()
        form = ClassesForm()
        messages.success(request, "Class Added to Registry!")
else:
    form = ClassesForm()

context_dict = {'classes': class_list,
                'form': form}
return render(request, 'index.html', context=context_dict)

Index.HTML Add Button

<table>
            <tbody>
                {% if classes %}
                    {% for class in classes %}
                    <tr>
                        <td>Class Name: </td>
                        <td>Subject: </td>
                        <td>CRN: </td>
                        <td>Course Number: </td>
                        <td>Section Number: </td>
                        <td>Credit Hours: </td>
                        <td>Teacher: </td>
                        <td>Grade Mode: </td>
                        <td>Add Class</td>
                    </tr>
                    <tr>
                        <td>{{ class.name }}</td>
                        <td>{{ class.subject }}</td>
                        <td>{{ class.crn }}</td>
                        <td>{{ class.course_num }}</td>
                        <td>{{ class.section_num }}</td>
                        <td>{{ class.credit_hours }}</td>
                        <td>{{ class.teacher }}</td>
                        <td>{{ class.grade_mode }}</td>
                        <td>
                            <form method="GET">
                                {% csrf_token %}
                                <button class="addToSchedule" type="submit" value="add" name="Add Class">
                                    Add Class
                                </button>
                            </form>
                        </td>
                    </tr>
                    {% endfor %}
            </tbody>
                {% else %}
                    <strong>There are no classes added.</strong>
                {% endif %}
        </table>

Image on Website. Class List So Far

So far I can print out the models on their own separate list as shown above but I don't know where to go in regards to the button or if a button is even the correct way of doing it. I want to click on a button and that model will be added and saved to the Added Classes section above.

Back to Top