Skip to main content

Got an error while coding in django

 error is in an element name "price" in model.py.

error:    return field.get_db_prep_save(self._effective_default(field), self.conne

ction)

  File "C:\Users\Shubrajit Acharjee\PycharmProjects\untitled\lib\site-packag

es\django\db\models\fields\__init__.py", line 823, in get_db_prep_save

    return self.get_db_prep_value(value, connection=connection, prepared=Fal

se)

  File "C:\Users\Shubrajit Acharjee\PycharmProjects\untitled\lib\site-packag

es\django\db\models\fields\__init__.py", line 818, in get_db_prep_value

    value = self.get_prep_value(value)

  File "C:\Users\Shubrajit Acharjee\PycharmProjects\untitled\lib\site-packag

es\django\db\models\fields\__init__.py", line 1776, in get_prep_value

    raise e.__class__(

ValueError: Field 'price' expected a number but got ''.


solution:Go to migrations file and delete all the auto generated migration files related to element "price" and code correctly in models.py file and run python manage.py makemigrations and migrate commands. Problem solved

source:https://www.reddit.com/r/django/comments/ekuv27/valueerror_field_id_expected_a_number_but_got_on/ 

after solving output:

>python manage.py makemigrations

Migrations for 'shop':

  shop\migrations\0003_auto_20200830_2343.py

    - Add field category to product

    - Add field image to product

    - Add field price to product

    - Add field subcategory to product


(untitled) C:\Users\Shubrajit Acharjee\PycharmProjects\ecomsitedjango\mycart

>python manage.py migrate

Operations to perform:

  Apply all migrations: admin, auth, contenttypes, sessions, shop

Running migrations:

  Applying shop.0003_auto_20200830_2343... OK



Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Post a Comment

Popular posts from this blog

Blog #2

Good morning Humans! Its 10:56 AM in the morning, I just wake up and thinking what to do today. Today I am gonna learn flask chapter I.e. basis app structure and templates and do a little bit of coding. Make some files to learn Github after completing flask chapters. Easy enough for today.

Started internship at ONGC

 Started a paid internship at ONGC Tripura asset on August 17 2022. I was Excited first day. New learnings. Thanks to ITI and my big bro who force me to take admission in ITI. Now I'm in the HR-ER room writing this post waiting for my incharge's command to show my word, excel, coding skills.

JSbooks notepad

 file:///C:/Users/Shubrajit%20Acharjee/Downloads/JavaScript%20and%20JQuery_%20Interactive%20Front-End%20Web%20Development%20(%20PDFDrive.com%20).pdf file:///C:/Users/Shubrajit%20Acharjee/Downloads/javascript-closure.pdf https://leanpub.com/understandinges6/read/ https://pepa.holla.cz/wp-content/uploads/2016/08/Learning-JavaScript-3rd-Edition.pdf file:///C:/Users/Shubrajit%20Acharjee/Downloads/thejsway.pdf http://www.r-5.org/files/books/computers/languages/escss/fp/Nicholas_C_Zakas-Understanding_ECMAScript_6-EN.pdf http://java.ociweb.com/mark/STLJS/ES6.pdf http://archive.oreilly.com/oreillyschool/courses/advancedjavascript/Advanced%20JavaScript%20Essentials%20v1.pdf projects: ◾ Spock Rock Game - Confetti.js, Modules ◾ Quote Generator - Fetch, Async/Await, Quote API, CORS ◾ Picture-in-Picture - Picture-in-Picture API, Screen Capture API ◾ Bookmarks App - DOM, localStorage ◾ NASA APOD - Fetch, Async/Await, NASA API, DOM, localStorage ◾ Animated Navigation - CSS Animations ◾ Infinite S...