brsbilgic
brsbilgic

Reputation: 11833

Formatting strings with python in django

I have a question list for a questionnaire which are stored in database but some questions has to be modified by certain parameters.

For example, if someone selects an employer name from previous page, some questions should have employer's name "Do you like to work for ........ company ?".

One solution might be savinf question like "Do you like to work for {0}" and formatting it but I am not sure how I can implement it with python.

But how can I detect which questions need to be modified ?

Is there any easy way to do it in django ?

Thanks

Upvotes: 1

Views: 215

Answers (1)

DrTyrsa
DrTyrsa

Reputation: 31951

The most flexible way - is to create custom template filter. If string needs formatting, it will do that, if it doesn't - just output it.

Upvotes: 1

Related Questions