You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How do I get this logic available to DRF instead of the tradition django way?
def render_ads_zone(context, zone):
# Retrieve random ad for the zone based on weight
ad = Ad.objects.random_ad(zone)
if ad is not None:
request = context['request']
if request.session.session_key:
impression, created = Impression.objects.get_or_create(
ad=ad,
session_id=request.session.session_key,
defaults={
'impression_date': timezone.now(),
'source_ip': get_client_ip(request),
})
context.update({
'ad': ad,
'google_adsense_client': settings.ADS_GOOGLE_ADSENSE_CLIENT,
'zone': settings.ADS_ZONES.get(zone, None)
})
return context
The text was updated successfully, but these errors were encountered:
Its not an issue per say, but using Django Rest Framework for this app, I couldn't just serialize this logic in my views.py so that my urls.py can calls this render_ads_zone logic in views.py
How do I get this logic available to DRF instead of the tradition django way?
The text was updated successfully, but these errors were encountered: