djongo
djongo copied to clipboard
EmbeddedModelField in a ArrayModelField Model
When using EmbeddedModelField in a ArrayModelField Model Admin Panel form is not validating the EmbeddedModelField model.
Python script
from djongo import models
from django import formsfrom datetime import datetime
# Create your models here.
class Identity(models.Model):
identity_no = models.IntegerField()
feature = models.CharField(max_length=1024)
def __str__(self):
return str(self.id)
class IdentityForm(forms.ModelForm):
class Meta:
model = Identity
fields = [
'identity_no',
'feature',
]
class Blog(models.Model):
name = models.CharField(max_length=100)
tagline = models.TextField()
class Meta:
abstract = True
class BlogForm(forms.ModelForm):
class Meta:
model = Blog
fields = [
'name',
'tagline',
]
class MetaData(models.Model):
pub_date = models.DateField(default=datetime.now())
mod_date = models.DateField(default=datetime.now())
n_pingbacks = models.IntegerField()
rating = models.IntegerField()
class Meta:
abstract = True
class MetaDataForm(forms.ModelForm):
class Meta:
model = MetaData
fields = [
'pub_date',
'mod_date',
'n_pingbacks',
'rating',
]
class Author(models.Model):
name = models.CharField(max_length=200)
email = models.EmailField()
ident = models.EmbeddedModelField(
model_container=Identity,
model_form_class=IdentityForm,
)
def __str__(self):
return self.name
class AuthorForm(forms.ModelForm):
class Meta:
model = Author
fields = [
'name',
'email',
'ident'
]
class Entry(models.Model):
blog = models.EmbeddedModelField(
model_container=Blog,
model_form_class=BlogForm,
)
meta_data = models.EmbeddedModelField(
model_container=MetaData,
model_form_class=MetaDataForm,
)
headline = models.CharField(max_length=255)
body_text = models.TextField()
authors = models.ArrayModelField(
model_container=Author,
model_form_class=AuthorForm,
)
n_comments = models.IntegerField()
def __str__(self):
return self.headline
Traceback

@nesdis Could you please help about this issue, I want to use djongo but it is some painful now :) I spent 4 hours for it, maybe it is simple but I have no such experience in web side.
By the way, here is my package info: dataclasses==0.5 Django==2.0.4 django-crispy-forms==1.7.2 djongo==1.2.23 Pillow==5.1.0 pymongo==3.6.1 pytz==2018.3 sqlparse==0.2.4
HI
Please attach the traceback as well.
Just pushed a fix. This should be working now
@nesdis Still does not work if the nested models are abstract models.