Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is create_or_update generating manager attribute error?

Tags:

django

I receiving an error AttributeError: 'Manager' object has no attribute 'create_or_update' in my views.py upon using create_or_update below. My code is shown below:

SlotFilling.objects.create_or_update(
                    originator=textobject.originator,
                    defaults = {empty_slot: True,
                    relevant_intent: intent_rank1,
                    ner_entities_list: ner_entities,}
                )

I'm not sure how to resolve this error. I'm using Django 1.11.2, so create_or_update should be supported. The only thing I can think of is that I must have missed something in my model.py. I've included that below. Any insights into what might be happening?

My models.py:

from django.db import models
class SlotFilling(models.Model):
    originator = models.CharField(max_length=20, primary_key=True)
    empty_slot = models.BooleanField(default=False)
    relevant_intent = models.CharField(max_length=20)
    slotted_entity = models.CharField(max_length=20)
    ner_entities_list = models.CharField(max_length=40)
like image 477
hackerman Avatar asked Sep 24 '17 03:09

hackerman


Video Answer


1 Answers

It is update_or_create and not create_or_update.

like image 54
Astik Anand Avatar answered Oct 01 '22 04:10

Astik Anand