djongo icon indicating copy to clipboard operation
djongo copied to clipboard

error making admin form for EmbeddedField

Open hypy13 opened this issue 5 years ago • 4 comments

the EmbeddedField got error when displaying form in admin panel

Python script

venv/lib/python3.8/site-packages/django/forms/models.py", line 86, in model_to_dict

class MetaData(models.Model):
    src_url = models.CharField(max_length=200)
    sp_data = models.CharField(max_length=200)
    dir = models.CharField(max_length=200)

    class Meta:
        abstract = True

class Artist(models.Model):
    _id = models.ObjectIdField()
    name = models.CharField(max_length=200)
    meta_data = models.EmbeddedField(model_container=MetaData, model_form_class=MetaDataForm)
    status = models.SmallIntegerField(default=None)

Traceback

the complete traceback

Error during template rendering In template /home/hossy/Documents/projects/noteabi/venv/lib/python3.8/site-packages/django/contrib/admin/templates/admin/includes/fieldset.html, error at line 19

'dict' object has no attribute '_meta'

hypy13 avatar Oct 21 '20 03:10 hypy13

Do you solve your issue?

brunowego avatar Nov 01 '20 18:11 brunowego

Hi, I'm facing the same problem. I embed the same way as described above (author on blogpost) and I run in the same error.

vindevoy avatar Jun 12 '22 07:06 vindevoy

Do you solve your issue?

No i haven't

But I think we can override the admin/templates/admin/includes/fieldset.html template and solve the error

hypy13 avatar Jun 30 '22 08:06 hypy13

Maybe a bit late, but a very smart person did a fork and fixed it! https://github.com/bslocombe/djongo

Tok3nexe avatar Sep 11 '23 15:09 Tok3nexe