Opened 18 years ago

Closed 18 years ago

Last modified 17 years ago

#1578 closed enhancement (fixed)

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

Reported by: mir@… Owned by: Adrian Holovaty
Component: Template system Version:
Severity: major Keywords: validation edit_inline
Cc: malcolm@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (1)

validate-edit-inline.diff (1.1 KB ) - added by mir@… 18 years ago.
get_validation_errors must check edit_inline attribute

Download all attachments as: .zip

Change History (7)

by mir@…, 18 years ago

Attachment: validate-edit-inline.diff added

get_validation_errors must check edit_inline attribute

comment:1 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: newclosed

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

comment:2 by anonymous, 18 years ago

Cc: malcolm@… added
Resolution: fixed
Status: closedreopened

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.

comment:3 by Malcolm Tredinnick, 18 years ago

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.

comment:4 by Malcolm Tredinnick, 18 years ago

Resolution: fixed
Status: reopenedclosed

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

comment:5 by anonymous, 18 years ago

Component: django-admin.pyTemplate system
milestone: Version 1.1
priority: highlow
Severity: normalmajor
Type: defectenhancement
Version: magic-removal

comment:6 by (none), 17 years ago

Milestone Version 1.1 deleted

Note: See TracTickets for help on using tickets.
Back to Top