Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#1578 closed enhancement (fixed)

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

Reported by: mir@… Owned by: adrian
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: UI/UX:

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@… 8 years ago.
get_validation_errors must check edit_inline attribute

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by mir@…

get_validation_errors must check edit_inline attribute

comment:1 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:2 Changed 8 years ago by anonymous

  • Cc malcolm@… added
  • Resolution fixed deleted
  • Status changed from closed to reopened

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 Changed 8 years ago 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.

comment:4 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from reopened to closed

(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 Changed 8 years ago by anonymous

  • Component changed from django-admin.py to Template system
  • milestone set to Version 1.1
  • priority changed from high to low
  • Severity changed from normal to major
  • Type changed from defect to enhancement
  • Version magic-removal deleted

comment:6 Changed 7 years ago by anonymous

Milestone Version 1.1 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.