cfoch: if you're using a form (and you should), then just output form.as_p
cfoch
tbaxter: it is a model
tbaxter
Even better. Then use a modelform
bradfordtoney joined the channel
Oh wait. "field" confused me. You're not outputting a form at all. You're trying to dump out all your model attributes.
munichlinux has quit
No, there is no shortcut, as it's almost always a bad idea.
bmac joined the channel
cfoch
tbaxter: what is a bad idea?
datakid joined the channel
tbaxter
Although there have been some conversations on here about whipping up a model outputter similar to how modelforms work, in which you would specify safe-to-output fields and then be able to do something like that. But I don't think anyone has been motivated to do anything like that.
blindly dumping model attributes
Tjati has quit
thepeculiarform has quit
And even aside from the fact that many attributes shouldn't be dumped, there's the problem of how to format dates, how to dump relationships. It's all a big ball of not-worth-it.
cfoch
is there a way to get the data of the model as a dict? So I can do something like
{% for key, value in data.iteritems %} <p>{{ key }}: {{ value }}</p>{% endfor %}
my task would be easiest: i think
mattmcc
cfoch: Build the dict that you want in your view.
bradfordtoney has quit
tbaxter
cfoch: you're trying to do something that is not a good idea. There is an underlying problem here. Maybe it's that the model has too many fields. Maybe you're trying to output too much, maybe you're not paying attention to HOW things are being output. Without having a better idea of what you're working with, I can't say.
mattmcc
Or write a model method that returns the dict.
tbaxter
Both of mattmcc's suggestions will work. But I still think you're trying to work over another problem.
tbaxter: It's Application... before Application, Check, Paypal and BanTransfer where in an only one model called Application
livingstn joined the channel
oubiga joined the channel
FunkyBob
cfoch: small tip -- don't import models just to use them in relation fields... e.g. Persona
instead, use the string form... in this case, user = models.ForeignKey('userprofile.Persona')
yofel has quit
same for Event
it helps to avoid circular imports
tbaxter
OK, model-wise I think you're on the right track. There are a few things I could quibble about, but it's not bad at all. Looking at your model, though, I think you *really* need to take the time to output your details by hand carefully. You have quite a few M2Ms you'll need to output as a list, or FKs that you wont want the unicode() from. I also think you won't want to output a lot of those fields all the time.