Thank you so much!! El lunes, 24 de octubre de 2016, 14:29:16 (UTC+2), Thomas Rega escribió: > > Hi, > > if you use a custom plugin, wich could be inserted into a page, you > could call your method within the render method of your custom plugin > and extend the context with your data. You will have it then available > in the template > > > http://docs.django-cms.org/en/release-3.3.x/how_to/custom_plugins.html#storing-configuration > > > Small example: > > class FooPlugin(CMSPluginBase): > allow_children = False > cache = False > model = FooModel > module = 'Foo Bar' > name = 'Example of Custom Plugin' > render_template = "foo/bar.html" > > def render(self, context, instance, placeholder): > request = context['request'] > context.update({ > 'instance': instance, > 'your_data': get_datos(request) > }) > > return context > > > Hope that helps - good luck > > 2016-10-24 13:30 GMT+02:00 Carlos García <[email protected] <javascript:>>: > > > I have a function recives data form a API: > > > > from django.template import Template, Context > > from django.http import HttpResponse > > import requests, json > > > > def get_datos(requests): > > datos = { > > "Credentials": { > > 'UserName': '********', > > 'Languaje': 'es', > > 'Password': '********' > > }, > > 'GetAvailAndRatesRQ': { > > 'NotGetCancellationInfoCollection': False, > > 'GetMultiGroupRates': True, > > 'RQRec':[{ > > 'HotelCode': 'ROL01', > > 'RQID': 1, > > 'RoomRQ': [{ > > 'PaxAgeList':[30, > > 30,], > > 'CH': 0, > > 'RQID': 1, > > 'AD': 2, > > 'RoomCode': 'FAM', > > 'CU': 0, > > 'NoRooms': 1, > > 'BoardCode': 'TI' > > }] > > }], > > 'NotGetChargeInfoCollection': False, > > 'PromotionCodeList': [], > > 'GetPromotionsCollection': True, > > 'DateTo': '2016-11-5', > > 'IncludedPromotionsInOnlyBar': False, > > 'DateFrom': '2016-10-30', > > 'GetHotelRS': False, > > 'Languaje': 'es', > > 'GetHotelDetails': False, > > 'GetHotelsWithoutAllotment': True, > > 'OnlyBar': False, > > 'NotGetDailyPriceCollection': True, > > 'ExactRoomMatch': False, > > 'GroupRateList': [], > > 'CustomerCode': 'WEB', > > 'Criteria': [] > > } > > } > > > > datos = json.dumps(datos, ensure_ascii=False) > > > > cabeceras = { > > 'Content-Type': 'application/json', > > 'action': 'getavailandrates', > > 'format': 'json', > > 'Accept-Encoding': 'gzip' > > } > > url = > > 'http://connectivity.dingus-services.com/services/v4/hotelservice.ashx' > > response = requests.post(url, data=datos, headers=cabeceras) > > > > if response.status_code == 200: > > results = response.json() > > else: > > resutls = 'Error code %s' % response.status_code > > > > return results > > > > > > I want to show this resuts in my main template. > > > > -- > > Message URL: > > > https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id > > Unsubscribe: send a message to > > [email protected] <javascript:> > > --- > > You received this message because you are subscribed to the Google > Groups > > "django CMS developers" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] > <javascript:>. > > To view this discussion on the web, visit > > > https://groups.google.com/d/msgid/django-cms-developers/02da3916-dc7c-4722-804a-6add7ae04a82%40googlegroups.com. > > > > > > For more options, visit https://groups.google.com/d/optout. >
-- Message URL: https://groups.google.com/d/msg/django-cms-developers/topic-id/message-id Unsubscribe: send a message to [email protected] --- You received this message because you are subscribed to the Google Groups "django CMS developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web, visit https://groups.google.com/d/msgid/django-cms-developers/f4a380e6-d521-412e-8c79-8853eaa798f4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
