Django

Code

Ticket #1578 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

[patch] validation for missing core=True in ForeignKey relations wrong

Reported by: mir@noris.de Assigned to: adrian
Milestone: Component: Template system
Version: Keywords: validation edit_inline
Cc: malcolm@pointy-stick.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

If you have a Foreign Key relation with edit_inline=False, manage.py validate complains if you don't have a core=True in the related model, like this:

email.nextrech: At least one field in Nextrech should have core=True, because it's being edited inline by tarifkunde.Tarifkunde.

It shouldn't: No edit_inline, no core=True needed.

The original version of get_validation_error did not check edit_inline at all, that was the whole problem.

Attachments

validate-edit-inline.diff (1.1 kB) - added by mir@noris.de on 04/03/06 11:05:47.
get_validation_errors must check edit_inline attribute

Change History

04/03/06 11:05:47 changed by mir@noris.de

  • attachment validate-edit-inline.diff added.

get_validation_errors must check edit_inline attribute

06/18/06 20:51:32 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

This has been fixed at some point since it was filed. The error is only raised if edit_inline = True.

06/29/06 11:58:14 changed by anonymous

  • cc set to malcolm@pointy-stick.com.
  • status changed from closed to reopened.
  • resolution deleted.

Nope.

I get this message:

popkern.nextrech: At least one field in Nextrech should have core=True, because it's being edited inline by tarifkunde.Tarifkunde.

With these models:

class Nextrech(models.Model):
    id = models.IntegerField(primary_key=True)
    tarifkunde = models.ForeignKey(Tarifkunde, db_column='tarifkunde', related_name='nextrech_entry')
    knextrech = models.ForeignKey(Knextrech, db_column='knextrech')
    wann = models.IntegerField()
    beginn = models.IntegerField()
    ende = models.IntegerField()
    anzahl = models.IntegerField()
    timestamp = models.DateTimeField()
    class Meta:
        db_table = 'nextrech'

class Tarifkunde(models.Model):
    id = models.IntegerField(primary_key=True)
    kunde = models.ForeignKey(Kunde, db_column='kunde')
    tarif = models.ForeignKey(Tarif, db_column='tarif')
    tarifname = models.ForeignKey(Tarifname, db_column='tarifname')
    dienst = models.IntegerField()
    anzahl = models.IntegerField()
    beginn = models.IntegerField()
    ende = models.IntegerField()
    ablauf = models.IntegerField()
    notiz = models.IntegerField()
    info = models.ForeignKey(String, db_column='info')
    infotext = models.CharField(maxlength=255)
    rechnung = models.TextField()
    nextrech = models.IntegerField()
    timestamp = models.DateTimeField()
    class Meta:
        db_table = 'tarifkunde'

cc to mtredinnick since he closed this ticket.

07/04/06 05:38:37 changed by mtredinnick

This is a bit subtle. It's triggered by the Tarifkunde.nextrech field -- which is why a related_name is required on Nextrech.tarifkunde. Without that (and after fixing the other fields so that this imports), no error. It's a bug, but triggered by strange circumstances. Fixing it now.

07/04/06 05:48:08 changed by mtredinnick

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [3275]) Fixed #1578 -- fixed a corner-case where we still wanting core=True attributes on a model that was not being edited inline.

07/07/06 14:25:19 changed by anonymous

  • severity changed from normal to major.
  • component changed from django-admin.py to Template system.
  • priority changed from high to low.
  • version deleted.
  • milestone set to Version 1.1.
  • type changed from defect to enhancement.

01/17/07 16:12:34 changed by

  • milestone changed.

Milestone Version 1.1 deleted


Add/Change #1578 ([patch] validation for missing core=True in ForeignKey relations wrong)




Change Properties
Action