Using a foreign key id value triggers `refer_to_missing_field` error on migrate

18 views
Skip to first unread message

Peter Coles

unread,
Nov 6, 2014, 7:21:28 PM11/6/14
to django...@googlegroups.com
I had an inline AdminModel that I was ordering by the id of a foreign key value, e.g.,

class ThingAdmin(admin.TabularInline):
    model
= models.Thing
    ordering
= ('rel_id',)

Where "rel_id" references the actual db column vs the object "rel".

This worked like a charm in the admin interface, but when I tried to generate migration scripts it raised an error:

The value of 'ordering' refers to 'rel_id', which is not an attribute of 'app.Thing'.

Seems like django should allow me to reference 'rel_id' instead of 'rel' in this interface. Would this be considered a bug?

Btw, switching it to `ordering = ('rel',)` worked just fine and appeared to still be ordering by the actual id.


Collin Anderson

unread,
Nov 12, 2014, 3:32:48 PM11/12/14
to django...@googlegroups.com
Hello,

You could try: ordering = ('rel__id',)

Collin

Reply all
Reply to author
Forward
0 new messages