Question: My django app displays the objects from database in table view. The problem is that these objects (models) are pretty complex: the have 50+ fields. Nearly for each field I have to do some formatting:

* conver phone numbers from int 71234567689 to "+7 (123) 456789"
* display long prices with spaces: "7 000 000" instead of "7000000"
* construct full address from several fields like "street", "house" and so on (logic if pretty complex with several if-else-s)
* and so on

Django templating language has several useful tags for simple cases but I guess is not suitable in general case (like mine) for serious formatting.

Create the @property-s in model class is also not an option because the question is about rendering and is not related to model.

So I guess I should do my conversions in view: create dict for each obj, fill with converted data and pass to template. 

But! The model has a lot of fields and I don't want to copy them all :) Moreover, it would be great to preserve model structure to use it in django template (say, regroup) and query set laziness.

**So the greatest way would be to instruct django "how to render". Is it possible?**

Answer: 
A third option which can be useful if you don't want to use EAGER mode and load up everything is to use Hibernate::initialize and only load what you need.

```
Session session = sessionFactory.openSession();
Catalog catalog = (Catalog) session.load(Catalog.class, catalogId);
Hibernate.initialize(shelf);

```

[More information](http://learningviacode.blogspot.be/2012/11/forcefully-initializing-proxies-in.html?_sm_au_=iHVJVsMjr7q61qjJ)
Using FetchType.LAZY , if still getting the error "Could not write content: failed to lazily initialize a collection of role" , that may be probably caused by somewhere in the logic (perhaps in a controller) , Catalog is being tried to be deserialized that contains list of catalog items which is a proxy but the transaction has already ended to get that. 
So create a new model ('CatalogResource' similar to catalog but without the list of items).
Then create a catalogResource object out of the Catalog (which is returned from the query) 

```html
public class CatalogResource {
    private int catalog_id;
    private String name;
    private List<Order> orders;
} 
```