They aren't bad, but they could be a little more verbose
FunkyBob
yeah
only wrote the app last week... c'mon! :P
v0lksman
he says to the guy in the $6000 suit ... C'MON!
RoboHak
Does it work for views that are not forms?
FunkyBob
RoboHak: well, for that I'd normally use sniplates...
RoboHak
My original problem was that django-crispy-forms does not work for detail views
FunkyBob: What are those?
FunkyBob
same idea, but not form specific
I took the work I did in sniplates [which has a different form tags approach] and came up with formulation last week
phildini joined the channel
RoboHak
I'm surprised there isn't something built into django to handle this
Is the standard way either custom templates or custom widgets?
FunkyBob
standard way to control form rendering?
widgets in code
AIUI, the core devs agree it's not good enough, but so far all the alternatives were too slow
I haven't tested yet, but I believe formulation should be quite fast
gbel joined the channel
ustunozgur joined the channel
sayd joined the channel
sayd
what would be a good name for this function that took n as a parameter? return "abcdefghijklmnopqrstuv"[int(n)]
domino14 has left the channel
with wxyz added obviously..
FunkyBob
huh?
sayd
plucking the letter of the alphabet by numerical index
FunkyBob
ah
so it's like chr(ord('a') + int(n)) ?
Raisins has left the channel
volk_ joined the channel
sayd
yeah looks to be
def letter_from_int(n):
?
FunkyBob
get_letter()?
hypolin joined the channel
theneb
On using a RadioSelect it returns the __str__ value for a given Model. Whats the best path with a custom widget based on RadioSelect to choose a different field from the input QuerySet?
KristianDK joined the channel
sayd
that code is good FunkyBob . it does what i need quite nicely
FunkyBob
theneb: actually ,as the docs and the tutorial say, it uses __unicode__
theneb: but if that's not present, Python will fall back to __str__
byoung joined the channel
theneb
FunkyBob: Okay, if that's within the model I'd like to leave that value alone. It's just for one widget that I wish to return one of the other fields.
mattmcc
theneb: RadioSelect takes a renderer object, check out how RadioFieldRenderer works.
theneb
Yes, have been going through that mattmcc. The Renderer seems to have the __str__ field value and not the direct access to the queryset row
Oddstr13 has left the channel
Adys joined the channel
Brent joined the channel
mattmcc
Oh, it's a ModelChoiceField? That class has a label_from_instance method.
Cromulent joined the channel
byoung joined the channel
gbel joined the channel
ojh joined the channel
samuel_ joined the channel
rideh joined the channel
seanbrant joined the channel
altipard joined the channel
v0lksman
I have a self referencing foreign key. Is there a way to find the related object that doesn't have a self reference?
filtering on null returns all the top level subnets so thats a no go
tdrizzy joined the channel
I need the top level in relation to the subnet I'm looking at
mattmcc
If this is a tree structure, I highly recommend django-mptt or django-treebeard.
Otherwise you're working way too hard.
v0lksman
I guess it could be seen as a tree but I really only need to know the top level parent of a subnet..I never really need to traverse a tree per say
but maybe I am working too hard and should go get a drink... :)
mattmcc
What you're describing _is_ tree traversal. Finding the root given an arbitrary branch. Without storing tree data, you'll have to recursively query every node.
katsh joined the channel
v0lksman
crap. ok...either of the two suggestions easier than the other for this simple traversal type?
volk_
v0lksman tree data structure in a database = nested set model
look into it
mattmcc
It's a single step operation in both apps.
FunkyBob
mmm... nested sets :)
mattmcc
Any given node will have a get_root method.
volk_
:)
ls3 joined the channel
v0lksman
yeah..just realized I can't modify these tables
mattmcc
Well, then you're stuck looping through all the ancestors of your node until you find the root one.
Milossh joined the channel
v0lksman
http://dpaste.org/7E4KP/ any reason obj would return blank? does it get destroyed if the attr doesn't exist?
anth0ny joined the channel
mattmcc
Missing return statement?
BTW, bare excepts are bad.
v0lksman
it should only return if masterSubnetId DoesNotExist
yeah I was going to qualify it once I proved the concept to myself... ;)
FunkyBob
"should" does not mean "will"
mattmcc
But it needs to keep that return value all the way back out your recursion chainn.