unable to validate and save modelform data into mysql database...

32 views
Skip to first unread message

Gourab Mahapatra

unread,
Oct 21, 2019, 8:49:01 AM10/21/19
to Django users
Traceback:

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\core\handlers\exception.py" in inner
  34.             response = get_response(request)

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\core\handlers\base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\core\handlers\base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
  21.                 return view_func(request, *args, **kwargs)

File "C:\Users\Admin\PycharmProjects\autotask\autotask\dashboard\views.py" in add_job
  41. if form.is_valid():

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\forms\forms.py" in is_valid
  185.         return self.is_bound and not self.errors

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\forms\forms.py" in errors
  180.             self.full_clean()

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\forms\forms.py" in full_clean
  381.         self._clean_fields()

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\forms\forms.py" in _clean_fields
  402.                     value = getattr(self, 'clean_%s' % name)()

File "C:\Users\Admin\PycharmProjects\autotask\autotask\dashboard\forms.py" in clean_job
  46. job_db = Job.objects.get(job_name=job)

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\db\models\manager.py" in manager_method
  82.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "C:\Users\Admin\PycharmProjects\autotask\AutoTaskVenv\lib\site-packages\django\db\models\query.py" in get
  408.                 self.model._meta.object_name

Exception Type: DoesNotExist at /dashboard/add_job/
Exception Value: Job matching query does not exist.

but when i use the query on cmd prompt then it works fine.
How to fix this? plz help

forms.py file.png

lemme smash

unread,
Oct 21, 2019, 11:08:13 AM10/21/19
to Django users
it's quite expected behavior. if you want to check if job exists, you better use Job.objects.filter(name=job_name).exists()

Gourab Mahapatra

unread,
Oct 22, 2019, 1:54:41 AM10/22/19
to Django users
sir/madam,

when I replace the particular statement with the one which you have
adviced me to use. then, this gives me an error something like:

Exception Type: NameError
Exception Value:     name 'job_name' is not defined

please help me in fixing  this issue

Thanks & Regards
Gourab Mahapatra

Gourab Mahapatra

unread,
Oct 22, 2019, 1:59:18 AM10/22/19
to Django users
and also I tried to use statements as shown in the attached file.
But still I get an error like the above thread:

Exception Type: NameError
Exception Value:     name 'job_name' is not defined

On Monday, 21 October 2019 20:38:13 UTC+5:30, lemme smash wrote:
form.py file screenshot2.png

Gourab Mahapatra

unread,
Oct 22, 2019, 2:03:23 AM10/22/19
to Django users
and now this error shows, something related to the job instance, i don't know but if you want then i can share with you my models.py file code and views.py file code
please help me in this regard,
I am stuck here since 2 weeks.
I have attached the screenshot of the error please find attached ..

Thanks & Regards,
Gourab Mahapatra


On Monday, 21 October 2019 20:38:13 UTC+5:30, lemme smash wrote:

Gourab Mahapatra

unread,
Oct 22, 2019, 2:03:48 AM10/22/19
to Django users
form.py file screenshot3.png

lemme smash

unread,
Oct 22, 2019, 9:01:37 AM10/22/19
to Django users
okay, man. seems like you need to read and repeat everything you know about python and django. i highly recommend you to go through django tutorial.


On Monday, October 21, 2019 at 3:49:01 PM UTC+3, Gourab Mahapatra wrote:
Reply all
Reply to author
Forward
0 new messages