Experienced Python / Django developers only.
Python / Django: Rewrite 2 views to sort 8 data models. Write new view to display companies with a coupon associated with their account.
Currently my ‘search_page’ view sorts 8 data models, but I need my ‘main_page’ and ‘tag_page’ views to be rewritten to sort these data models as well. You’ll use the same HTML the ‘search_page’ uses to render the views, so no need to write new HTML.
Also I want a new view which displays and sorts companies that have a coupon associated with their account. Again the coupon model is already built-in so you’ll just write a view for it.
So 2 rewrites, and 1 new view. The HTML is already done, so you’ll just use the same HTML as the ‘search_page’.
Below are main and tag page views:
def main_page(request):
data = search_data_model(Q()).order_by(‘-date’)[:10]
variables = RequestContext(request, {‘data’: data})
return render_to_response(‘main_page.html’, variables)
def tag_page(request, tag_name):
tag = get_object_or_404(Tag, name=tag_name)
data = tag.data.order_by(‘-id’)
variables = RequestContext(request, {‘data’: data, ‘tag_name’: tag_name, ‘show_tags’: True, ‘show_user’: True})
return render_to_response(‘tag_page.html’, variables)
PM for more code samples.