I am creating a simple pyramid CMS that uses bypass. There is a class called Collectionthat has some type subclasses NewsCollection, GalleriesCollectionetc.
I need two kinds of views to display these collections. Representation of frontent, html and backend, json view (the admin panel uses dgrid to display data). The backend view can be shared - it uploads json data in each case. The appearance of the interface should not - a custom template will be created for each data type.
The problem is this: when I adjust the view as follows:
@view_config(context=Collection, xhr=True, renderer='json', accept='application/json')
It works correctly. However, as soon as I add any view configured for NewsCollection, this takes precedence. Even if I put predicates specifically for conflict with the above configuration (for example accept='text/html'), still the above view will not be called. Instead, I get a predicate mismatch.
My question is: can I do anything to make the view configured for Collectioninvoked when there are also views for NewsCollection? Or do I need to use a different design (e.g. sending a URL or adding the same view multiple times for different types of resources)
source
share