Weills
Weills

Reputation: 11

Django : on_delete=models.SET.NULL gives error

Why attribute in my model class where

class Tour_Cart(models.Model):

tours=models.ForeignKey(Tours,on_delete=models.SET_NULL,blank=True,null=True)

Throws error:

AttributeError: 'function' object has no attribute 'NULL'

Why so?

Any help will be appreciated?

Upvotes: 0

Views: 445

Answers (2)

binpy
binpy

Reputation: 4194

I think you just missing on SET.NULL, it should be on_delete=models.SET_NULL

Upvotes: 2

Anthony
Anthony

Reputation: 959

Why not use on_delete=models.CASCADE?

Also you're missing (models.Model) from your class declaration.

Upvotes: 0

Related Questions