Python Forum

Full Version: coding error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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
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.
Pages: 1 2