Wednesday, February 26, 2014

Re: generic.UpdateView and readonly ForeignKeys

Ok, I worked it quick and dirty. Do not try this at home, kids.

The field isn't strictly read only anymore, but I no longer mention
the field in question in forms.py

In the template, I've replaced the {{ forms.fk_model }} with {{
object.fk_model }}.

And now the field is plain text (the fk_model.__unicode__ ) instead of
a ModelChoiceField.

Cheers
L.

On 27 February 2014 09:17, Lachlan Musicman <datakid@gmail.com> wrote:
> I'm looking for a quick and easy way to implement readonly ForeignKeys
> when using the generic.UpdateView.
>
> I can't see anything that looks simpler than just ditching the
> UpdateView and writing a function based view that sets the FK queryset
> to a single object.
>
> Or have I missed something?
>
> cheers
> L.
>
> --
> From this perspective it is natural that anarchism be marked by
> spontaneity, differentiation, and experimentation that it be marked by
> an expressed affinity with chaos, if chaos is understood to be what
> lies outside or beyond the dominant game or system. Because of the
> resistance to definition and categorisation, the anarchist principle
> has been variously interpreted as, rather than an articulated
> position, "a moral attitude, an emotional climate, or even a mood".
> This mood hangs in dramatic tension between utopian hope or dystopian
> nihilism...
> -----
> http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos



--
From this perspective it is natural that anarchism be marked by
spontaneity, differentiation, and experimentation that it be marked by
an expressed affinity with chaos, if chaos is understood to be what
lies outside or beyond the dominant game or system. Because of the
resistance to definition and categorisation, the anarchist principle
has been variously interpreted as, rather than an articulated
position, "a moral attitude, an emotional climate, or even a mood".
This mood hangs in dramatic tension between utopian hope or dystopian
nihilism...
-----
http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiPOBK02UgCDVQb-ED%3DsyXOK2PUQsrkrtrg0iQ%2Bkve2k0g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment