Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There's a difference between an object's string representation, and what it actually is. It seems likely that your <code>state</code> property returns an object whose unicode representation is <code>InProgress</code>, but that doesn't make it actually equal to <code>"InProgress"</code>. This would be true for example if <code>state</code> is a ForeignKey to another model - in which case you could just add another level to the lookup to get to the actual field that returns that status.</p> <p><strong>Edit after update</strong> I think you've coded yourself into a corner, unfortunately. Since there's no actual instance attribute that contains the state as a string, there's no way to get it via string comparison.</p> <p>A couple of possibilities spring to mind. One is to pass all possible <code>State</code> subclasses to the template context (perhaps via a context processor), after which you'll be able to compare your <code>state</code> with the actual objects. This is pretty horrible.</p> <p>An alternative would be to add a function, either on the <code>State</code> class or possibly on the model, which gets the state as a string. This could be as simple as the existing <code>__unicode__</code> method (you can't actually use that, because the template language forbids accessing attributes that begin with underscores). Then you can do <code>ifequal foo.bar.0.state.as_string "InProgress"</code> or whatever, and that will call the <code>as_string()</code> method and your comparison will succeed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload