Error in trying to connect Model to ModelForm in Django

I'm learning Django and am trying to make a request form to fill by using Django and an MySQL database and i am encountering issues trying to connect models.py to forms.py making a ModelForm with a database and table i have already created. It returns this error specifically

(envworld) C:\Seen\Documents\envworld\myweb>python manage.py makemigrations
Traceback (most recent call last):
  File "C:\Seen\Documents\envworld\myweb\manage.py", line 22, in <module>
    main()
  File "C:\Seen\Documents\envworld\myweb\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Seen\Documents\envworld\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line      
    utility.execute()
  File "C:\Seen\Documents\envworld\lib\site-packages\django\core\management\__init__.py", line 420, in execute
    django.setup()
  File "C:\Seen\Documents\envworld\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Seen\Documents\envworld\lib\site-packages\django\apps\registry.py", line 124, in populate
    app_config.ready()
  File "C:\Seen\Documents\envworld\lib\site-packages\django\contrib\admin\apps.py", line 27, in ready
    self.module.autodiscover()
  File "C:\Seen\Documents\envworld\lib\site-packages\django\contrib\admin\__init__.py", line 50, in autodiscover
    autodiscover_modules("admin", register_to=site)
  File "C:\Seen\Documents\envworld\lib\site-packages\django\utils\module_loading.py", line 58, in autodiscover_modules
    import_module("%s.%s" % (app_config.name, module_to_search))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Seen\Documents\envworld\myweb\formsite\admin.py", line 2, in <module>
    from .forms import RequestForm
  File "C:\Seen\Documents\envworld\myweb\formsite\forms.py", line 12, in <module>
    request = Request_Form.objects.get(pk=1)
  File "C:\Seen\Documents\envworld\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "C:\Seen\Documents\envworld\lib\site-packages\django\db\models\query.py", line 650, in get
    raise self.model.DoesNotExist(
formsite.models.Request_Form.DoesNotExist: Request_Form matching query does not exist.

here is also the file directory for the Django project and app

Django project & app path

I'm assuming that the problem is with the Request_Form.objects.get(pk=1) since i defined the primary key while django automatically creates a field/column when its not declared through AutoField() but i am also asking in advance if there are any issues from the code

here is the code and what i did

models.py

from django.db import models

class Request_Form (models.Model):
    No_Permintaan = models.IntegerField(primary_key=True)
    Nama_Aplikasi = models.CharField(max_length=30)
    Departemen = models.CharField(max_length=50)
    Description = models.TextField(max_length=2000)
    TanggalReq = models.DateTimeField
    Nama_Atasan = models.CharField(max_length=30, unique=True)

    def __str__(self):
        return self.Nama_Aplikasi
    
class Serah_Terima (models.Model):
    Kode_Permintaan = models.ForeignKey(Request_Form, on_delete=models.CASCADE)
    TanggalApproval = models.DateField
    Atasan = models.ForeignKey(Request_Form, on_delete=models.CASCADE,to_field='Nama_Atasan' ,related_name='Kode_Permintaan')
    Comment = models.TextField

    def __str__(self):
        return self.name

forms.py

from django.db import models
from django.forms import ModelForm
from formsite.models import Request_Form
from formsite.models import Serah_Terima


class RequestForm(ModelForm):
        class Meta:
                model = Request_Form
                fields = ['Nama_Aplikasi', 'Departemen', 'Description', 'Nama_Atasan']
form = RequestForm()
request = Request_Form.objects.get(pk=1)
form = RequestForm(instance=request)

""""
class SerahTerima(ModelForm):
   class Meta:
        model = Serah_Terima
        fields = ['Tanggal_Approval','Nama_Atasan','Comment']

form = SerahTerima()
serah = SerahTerima.objects.get(pk=1)
form = SerahTerima(instance=request)
"""

i have commented the Serah_Terima part of the form as i am still testing the Request_Form modelform but here is also the rest of the code

views.py

from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from .forms import RequestForm
def welcome(request):
    return HttpResponse("Welcome to the Home Page")

def formpage(request):
    submitted = False
    if request.method == 'POST':
        form= RequestForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('myweb/formpage?submitted=True')
        else:
            form = RequestForm
            if 'submitted' in request.GET:
                submitted = True
            return render(request, 'myweb/formpage.html', {'form':form,'submitted':submitted})

urls.py myweb/formsite/urls.py

from django.urls import path
from formsite import views

urlpatterns = [
    path('form/', views.formpage, name = 'formpage'),
    path('', views.welcome, name='welcome'),
]

urls.py myweb/urls.py

from django.contrib import admin
from django.urls import path
from formsite import views

urlpatterns = [
    path('', views.welcome, name='home'),
    path('form/', views.formpage, name = 'formpage'),
    path('admin/', admin.site.urls),
]

and then the html codes just in case

formpage.html

{% {% extends 'base.html' %}%}
<h2>For App Request </h2>
<hr>

{%if submitted%}
    Data is Submitted
{% else %}

<form-action="",method="post">
    {% csrf_token %}
    {{ form.as_p }}
    <inpu>
        <input type="Submit" value="Submit">
    </form>
{% endif %}

base.html

<!DOCTYPE !html>

<html lang="en">
<head>
    <link rel="stylesheet" href="style.css">`
    <title>Form Login Page</title>
</head>

<body>
    <div id="sidebar">
        <ul>
            <li><a href="/myweb">Home</a></li>
            <li><a href="myweb/formpage">formpage</a></li>
        </ul>
    </div>
</body>

</html>

your forms.py should look like this

from django import forms
from formsite.models import Request_Form
from formsite.models import Serah_Terima

class RequestForm(forms.ModelForm):
    class Meta:
        model = Request_form
        fields = ['Nama_Aplikasi', 'Departemen', 'Description', 'Nama_Atasan']

This one below is meant to be in your views.py

form = RequestForm()
request = Request_Form.objects.get(pk=1)
form = RequestForm(instance=request)
Back to Top