make big
rivers :)
Eric
From: django-users@googlegroups.com on behalf
of treyd
Sent: Saturday, November 11, 2017 20:49
To: Django users
Subject: Re: Django Templates and Conditional CSS classes
Omar (and everybody else who responded),
Thanks for that ideas
Omar (and everybody else who responded),
Thanks for that ideas and putting a method on the model to return the
appropriate CSS class based on the state. I think that would be the
cleanest solution if I am going to bite the bullet and put this
template-specific logic on the model.
It got me th
Hi treyd,
I think idea of updating the model and storing it in the db is a bit
overkill, however you could create an @propery on the model that will do
that logic for you and return the css class for you.
e.g.
@property
def css_class(self):
if self.state is SUCHANDSUCH:
return "label-soan
Thanks, all, for the info. Looks like the best way to clean this up is to
make the model have some knowledge of the CSS class I want to use and make
a method to get it. I like that, but I was unsure about sticking view
information into the model. Probably the best solution is javascript logic
You can also add a "state_css_class" (or something) method to your object
class and just call
...
the method should be quite simple
On Fri, Nov 10, 2017 at 7:01 PM, Adam Simon wrote:
>
> You can pass the class from either the model or the view into the
> template. For example, you can assign
You can pass the class from either the model or the view into the
template. For example, you can assign a class to a button with a variable:
<|button>
And then the class would have to be defined in your style somewhere
On Fri, Nov 10, 2017 at 1:37 PM treyd wrote:
> At some point I plan on fig
At some point I plan on figuring out how to do more intelligent front-end
in-browser stuff (Angular, etc) which yeah would definitely help me here
but I was wondering if there was a Django-only way of doing this.
On Friday, November 10, 2017 at 3:51:09 PM UTC-5, Adam wrote:
>
>
> Are you open to
Are you open to using JavaScript in the front end? It would make it really
easy
On Fri, Nov 10, 2017 at 12:40 PM treyd wrote:
> Hello,
>
> I am trying to render a model field in a django template, and, based on
> the value of the field, I want to specify a different CSS class. Right
> now, my s
8 matches
Mail list logo