-----8<--
class Node(models.Model):
name = models.CharField(maxlength=20, core=True, blank=False)
def __str__(self):
return self.name
class Admin:
pass
class Path(models.Model):
source = models.ForeignKey(Node, core=True, related_name='source_set')
sink = models.ForeignKey(Node, core=True, related_name='sink_set')
def __str__(self):
return "from %s to %s" % (self.source, self.sink)
class Admin:
list_display = ['source', 'sink']
-->8-----
that works very nicely. Or does it? The link on the sink column in the
admin interface sorts by source :(
What am I missing? Oh, python2.4, django from svn, linux.
--
John Lenton (jle...@gmail.com) -- Random fortune:
The trouble with a lot of self-made men is that they worship their creator.
have a look at the Meta options order_with_respect_to and ordering:
http://www.djangoproject.com/documentation/model_api/#order-with-respect-to
Hope it helps,
G
no, that's not it. Or I didn't understand how to use it; at any rate,
it didn't work. Let me explain a little better the situation: Here is
the admin screen as it comes up:
Source | Sink
Cnode | Bnode
Anode | Cnode
Xnode | Anode
Mnode | Anode
if you click on "Source", it sorts by the source's name, as expected:
Source v | Sink
Anode | Cnode
Cnode | Bnode
Mnode | Anode
Xnode | Anode
this is as expected; but if you click on "Sink", you get
Source | Sink v
Anode | Cnode
Cnode | Bnode
Mnode | Anode
Xnode | Anode
i.e., it still sorts by Source instead of Sink. Is this a bug in
django, or am I forgetting something?
I couldn't help but notice that in your example, it is also sorted by
Sink *descending*. What happens if you click on "Sink" again? If I'm
not mistaken, it should sort *ascending*. Then again, this just may be
a coincidence of a poorly written example in which case you can ignore
me.
--
----
Waylan Limberg
way...@gmail.com
sorry, just a poor example. The real table has rather long names and
over 15k entries, so I can't exactly paste it here.
Well, I just copy and paste the first few rows... yeah. Here goes:
when it first comes up, it starts like this:
====
Source Sink
ALDENE 13 KV SK NUG AECO
ELRAMA 13 KV UNIT1 HREA - AP
ALDENE 13 KV SK NUG APS
MITCHELL 24 KV GEN 3 DUQ
ALDENE 13 KV SK NUG BGE
====
then I click on Source, and I get
====
Source Sink
ALDENE 13 KV SK NUG WILLIAMSPORT - AP
ALDENE 13 KV SK NUG WESTERN HUB
ALDENE 13 KV SK NUG WEST INT HUB
ALDENE 13 KV SK NUG WELLSBORO
====
and I click on Sink, and get
====
Source Sink
ALDENE 13 KV SK NUG WILLIAMSPORT - AP
ALDENE 13 KV SK NUG WESTERN HUB
ALDENE 13 KV SK NUG WEST INT HUB
ALDENE 13 KV SK NUG WELLSBORO
====
which is exactly the same as the previous one, if you look :(