0

I have class Dimension and Feature. ( Want to create an Embedded Model from Feature to Dimension)

Documentation: bottom of page

I keep getting the error:

dimension = models.EmbeddedModel

AttributeError: module 'djongo.models' has no attribute 'EmbeddedModel'

class Dimension(models.Model):

    dimensionName = models.CharField(max_length=20)
    def __str__(self):
        return self.dimensionName


class Feature(models.Model):

    featureName = models.CharField(max_length=20)
    dimension = models.EmbeddedModel(
        model_container=Dimension,
    )
    def __str__(self):
        return self.featureName

Any leads would be appreciated!

Lazaron Shyta
  • 67
  • 1
  • 6
  • Were you able to solve it? – Victor Mar 29 '20 at 16:40
  • No, it doesn't work. It accepts the syntax and it successfully create the migrations, but when I try to migrate, I get an error that it fails to migrate and warns that EmbeddedField might be a badly written custom field. :( – Lazaron Shyta Mar 30 '20 at 18:44
  • actually, solved it!! using models.EmbeddedField and adding a default=None – Lazaron Shyta Mar 31 '20 at 08:01
  • Glad to hear that. Though the `default=None` wasn't provided in my answer, if my answer helped with the original question and pointed you to the right direction, a vote up would be appreciated https://meta.stackoverflow.com/help/someone-answers – Victor Mar 31 '20 at 10:20

1 Answers1

2

Use djongo.models.EmbeddedField (for djongo==1.3.1) or djongo.models.EmbeddedModelField for (djongo==1.2.23)

Victor
  • 2,864
  • 1
  • 12
  • 20