Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
coding error
#11
from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone
from django.utils.text import slugify
##from django.contrib.auth.models import User
##from datetime import datetime

##from core.models import Product

class Product(models.Model):
  pass

myProduct=Product()
myproduct.name=models.CharField(max_length=100)
myProduct.description=models.TextField(max_length=500)
myProduct.condition=models.CharField(max_length=100)
myProduct.price=models.DecimalField(max_digits=10,decimal_places=5)
myProduct.created=models.DateTimeField()

NameError: name 'myproduct' is not defined
Reply
#12
myproduct.name=models.CharField(max_length=100) should be myProduct.name=models.CharField(max_length=100)

Next time, try and fix it yourself. This is a very easy error to fix, especially in a short script like yours.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Coding error. xflyerwdavis 2 486 Oct-07-2023, 07:08 PM
Last Post: deanhystad
  Coding error. Can't open directory EddieG 6 1,062 Jul-13-2023, 06:47 PM
Last Post: deanhystad
  Coding Error EddieG 2 509 Jul-09-2023, 02:59 AM
Last Post: EddieG
  python coding error isntitzee 1 2,175 Oct-17-2020, 06:30 AM
Last Post: buran
  Coding error- Not sure where I have put error markers against the code that is wrong Username9 1 1,691 Sep-28-2020, 07:57 AM
Last Post: buran
  coding error iro a menu Rollo 2 2,034 Sep-27-2020, 04:17 PM
Last Post: deanhystad
  Adafruit LIS3DH coding error FitDad73 1 1,970 Aug-30-2020, 01:37 AM
Last Post: bowlofred
  Coding error- help FatherYeals 3 30,037 Mar-27-2020, 02:11 PM
Last Post: deanhystad
  name undefined Coding Error Ewilliam51 2 2,098 Feb-06-2020, 12:19 AM
Last Post: Ewilliam51
  Pyhton Coding Help Needed (very small error) friduk 2 2,404 Oct-23-2019, 08:41 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020