Open codot-fr opened 4 years ago
logically is correct, because in SQL ForeignKey reference to the table via PrimaryKey ... in this case, VirtualMachineQuote
is abstract=True
mean is not separate collection and you don't have a primary key.
But it was working previously. I omited this code, maybe it's related to a change in the usage of models.ArrayFields ?
` class VirtualMachineQuoteForm(forms.ModelForm): class Meta: model = VirtualMachineQuote fields = 'all'
class Quote(models.Model): STATUS_CHOICES = [ ("draft", "Brouillon"), ("locked", "Verrouillée") ]
status = models.CharField(max_length=50, choices=STATUS_CHOICES, default="draft")
project = models.ForeignKey(
Project,
on_delete=models.SET_NULL,
null=True,
related_name='quotes',
blank=True,
verbose_name="Projet"
)
user = models.ForeignKey(
'users.User',
on_delete=models.SET_NULL,
null=True,
related_name="Estimations",
verbose_name="Utilisateur"
)
creation_date = models.DateTimeField(auto_now_add=True, null=True)
last_edit_date = models.DateTimeField(auto_now=True, null=True)
summary = models.CharField(max_length=250, verbose_name="Descriptif de la demande de devis")
virtual_machines = models.ArrayField(
model_container=VirtualMachineQuote,
model_form_class=VirtualMachineQuoteForm
)
backup_storage = models.ArrayField(
model_container=BackupQuote,
model_form_class=BackupQuoteForm
)
load_balancers = models.ArrayField(
model_container=LoadBalancerQuote,
model_form_class=LoadBalancerQuoteForm
)
def get_absolute_url(self):
return reverse('quote-detail', kwargs={'pk': self.pk})
class QuoteForm(forms.ModelForm): class Meta: model = Quote fields = ( 'project', 'summary' ) `
djongo is an unstable project and has no active comminute and contributor, it's so bad.
Hello,
I was using django 2.2.9 and djongo 1.3.0 and Python 3.6.4. I then upgraded packages to django 3.0.5 and djongo 1.3.3 with Python 3.8.5. I now have a exception raised at startup :
File "C:\Users\pjra835.virtualenvs\iaas_dashboard\lib\site-packages\djongo\models\fields.py", line 120, in _validate_container raise ValidationError( django.core.exceptions.ValidationError: ['Field "reporting.VirtualMachineQuote.region" of model container:"<class \'reporting.models.VirtualMachineQuote\'>" cannot be of type "<class \'django.db.models.fields.related.ForeignKey\'>"']
It comes from djongo models fields :
Why would a "RelatedField" field in a model raise en error ?
Python script
Traceback