I checked it and it was year not year string. I also tried deleting the
whole year field and that had not effect i still got the same error. So i
don't think this is an issue with my field. What is the next step i should
take?
-Brandon
On Monday, May 21, 2012 1:54:01 PM UTC-6, Jim S wrote:
>
> This may be way off-base, but can you check your model to make sure the
> line you have below as:
>
> Field('year', 'string', requires=IS_NOT_EMPTY()),
>
> is not mistakenly typed as:
>
> Field('yearstring', requires=IS_NOT_EMPTY()),
>
> Also, for string fields you don't need to specify the type ('string'),
> that is the default. I typically add a length to it as follows:
>
> Field('year', length=4, requires=IS_NOT_EMPTY()),
>
> -Jim
>
> On 5/21/2012 2:40 PM, Brandon Reynolds wrote:
>
> How do I insert the value into that yearstring field? I understand i got
> the key error because of the field not being defined. I was trying that
> only as a troubleshooting step to see what happened. Should i make a
> yearstring field in the db and then just assing it a default value? Or how
> else to i get the value into that field? I also have another form that
> works fine on the site and it doesn't have yearstring field. Please advise.
>
> On Monday, May 21, 2012 12:07:42 PM UTC-6, Anthony wrote:
>>
>> In your model, there is no "yearstring" field defined (there is a "year"
>> field, though) -- so that's why you get a key error when trying to set
>> db.home.yearstring.default. You might be getting the integrity error
>> because the database itself does include a "yearstring" field (with a
>> notnull requirement), and you are not inserting any value for that field.
>>
>> Anthony
>>
>> On Monday, May 21, 2012 1:08:25 PM UTC-4, Brandon Reynolds wrote:
>>>
>>> Hello,
>>>
>>> I am new to web2py and pretty new to programming in general. I am
>>> getting the following error when trying to insert a new record with a form
>>> made with crud.create:
>>>
>>> <class 'sqlite3.IntegrityError'> home.yearstring may not be NULL
>>>
>>> I have nothing in my model/view/controllers at all that mentions the
>>> year string. I tried to set yearstring a default value
>>> with db.home.yearstring.default = "0" but then got a key error that year
>>> string was not defined. Here is my controller for this view:
>>>
>>> @auth.requires_membership('Admin')
>>> def new_home():
>>> db.home.pid.default = request.args(0) or redirect(URL('parks'))
>>> db.home.price.default = "$0000.00"
>>> form = crud.create(db.home, next='home/[id]')
>>> return locals()
>>>
>>> Here is the model for this controller:
>>>
>>> db.define_table('home',
>>> Field('pid', notnull=True),
>>> Field('lot', 'string'),
>>> Field('year', 'string', requires=IS_NOT_EMPTY()),
>>> Field('make', 'string'),
>>> Field('model', 'string'),
>>> Field('for_sale', 'boolean', default=True),
>>> Field('beds', 'string', requires=IS_NOT_EMPTY()),
>>> Field('baths', 'string', requires=IS_NOT_EMPTY()),
>>> Field('fridge', 'boolean'),
>>> Field('stove', 'boolean'),
>>> Field('dishwasher', 'boolean'),
>>> Field('microwave', 'boolean'),
>>> Field('washer', 'boolean'),
>>> Field('dryer', 'boolean'),
>>> Field('photo1', 'upload'),
>>> Field('photo2', 'upload'),
>>> Field('photo3', 'upload'),
>>> Field('photo4', 'upload'),
>>> Field('photo5', 'upload'),
>>> Field('price', 'string' , requires=IS_NOT_EMPTY()),
>>> Field('description', 'text', requires=IS_NOT_EMPTY()))
>>>
>>> Also here is the traceback.
>>>
>>> Traceback (most recent call last):
>>> File "gluon/restricted.py", line 205, in restricted
>>> File
>>> "/Applications/web2py.app/Contents/Resources/applications/pages/controllers/view.py"
>>> <http://127.0.0.1:8000/admin/default/edit/pages/controllers/view.py>, line
>>> 110, in <module>
>>> File "gluon/globals.py", line 173, in <lambda>
>>> File "gluon/tools.py", line 2575, in f
>>> File
>>> "/Applications/web2py.app/Contents/Resources/applications/pages/controllers/view.py"
>>> <http://127.0.0.1:8000/admin/default/edit/pages/controllers/view.py>, line
>>> 88, in new_home
>>> File "gluon/tools.py", line 3172, in create
>>> File "gluon/tools.py", line 3115, in update
>>> File "gluon/sqlhtml.py", line 1274, in accepts
>>> File "gluon/dal.py", line 6829, in insert
>>> File "gluon/dal.py", line 928, in insert
>>> IntegrityError: home.yearstring may not be NULL
>>>
>>>
>>> What is this error ad how can i get around it?
>>>
>>