Skip to content

TypeError: __init__() missing 1 required positional argument: 'on_delete‘ #59

@flyonok

Description

@flyonok

python 3.5 ubuntu18.4
my code:
`class Task(models.Model):

STATUS_CHOICES = (
    ("New", "New"),
    ("In Progress", "In Progress"),
    ("Completed", "Completed")
)

PRIORITY_CHOICES = (
    ("Low", "Low"),
    ("Medium", "Medium"),
    ("High", "High")
)

# xiaowy
# title = models.CharField(_("title"), max_length=200)
# status = models.CharField(
#     _("status"), max_length=50, choices=STATUS_CHOICES)
# priority = models.CharField(
#     _("priority"), max_length=50, choices=PRIORITY_CHOICES)
# due_date = models.DateField(blank=True, null=True)
# created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
# account = models.ForeignKey(
#     Account, related_name='accounts_tasks', null=True, blank=True, on_delete=models.SET_NULL)

# contacts = models.ManyToManyField(
#     Contact, related_name="contacts_tasks")

# assigned_to = models.ManyToManyField(
#     User, related_name='users_tasks')
# end
name = models.CharField(_('name'), max_length=200, null=True)
contact = models.CharField(_('contact'), max_length=50, null=True, blank=True)
phone = PhoneNumberField(null=True)
email = models.EmailField(null=True, blank=True)
weixin = models.CharField(_('wechat'), max_length=50, null=True, blank=True)
qq = models.CharField(_('qq'), max_length=26, null=True, blank=True)
website = models.URLField(_("Website"), blank=True, null=True)
effective  = models.IntegerField(choices=PARTNER_IS_EFFECTIVE, default=1)
partner_type = models.IntegerField(choices=PARTNER_TYPE, default=1)
# description = models.CharField(_('description'), max_length=255, null=True, blank=True)
description = models.TextField(blank=True, null=True)
address = models.CharField(_('address'), max_length=255, null=True, blank=True)
created_on = models.DateTimeField(_("Created on"), auto_now_add=True)

created_by = models.ForeignKey(
    User, related_name='task_created', blank=True, null=True, on_delete=models.SET_NULL)
# xiaowy
# teams = models.ManyToManyField(Teams, related_name='tasks_teams')


def __str__(self):
    return self.name

@property
def created_on_arrow(self):
    return arrow.get(self.created_on).humanize(locale='zh_CN')

class Meta:
    # ordering = ['-due_date']
    ordering = ['-created_on']

xiaowy

import eav
eav.register(Task)`

exception:
(env) xiaowy@ubuntu:~/django-crm/django-crm$ python manage.py migrate
No local settings file found
Traceback (most recent call last):
File "manage.py", line 24, in
execute_from_command_line(sys.argv)
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/core/management/init.py", line 381, in execute_from_command_line
utility.execute()
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/core/management/init.py", line 357, in execute
django.setup()
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/xiaowy/django-crm/env/lib/python3.5/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/home/xiaowy/django-crm/env/lib/python3.5/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 665, in exec_module
File "", line 222, in call_with_frames_removed
File "/home/xiaowy/django-crm/django-crm/tasks/models.py", line 79, in
eav.register(Task)
File "/home/xiaowy/django-crm/env/src/django-eav/eav/init.py", line 30, in register
from .registry import Registry
File "/home/xiaowy/django-crm/env/src/django-eav/eav/registry.py", line 35, in
from .managers import EntityManager
File "/home/xiaowy/django-crm/env/src/django-eav/eav/managers.py", line 34, in
from .models import Attribute, Value
File "/home/xiaowy/django-crm/env/src/django-eav/eav/models.py", line 109, in
class Attribute(models.Model):
File "/home/xiaowy/django-crm/env/src/django-eav/eav/models.py", line 186, in Attribute
verbose_name=
(u"content type"))
TypeError: init() missing 1 required positional argument: 'on_delete'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions