Pulling data to the template from an external database with django

前端 未结 3 467

I\'m going to attempting to build a web app where users can visit a url, login and view reports and other information. However the data for the reports are stored in an exte

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 03:57

    There is going to be no problem if the data is being updated.

    Now for retrieving the data from database you first have to import the concerned model in your views

    from app_name.models import model_name
    def view_report(request):
        r_name=request.POST.get('r_name','default_value')
        r=model_name.objects.get(report_name=r_name)
        return render_to_response('url',{'r':r})
    

    In your template

    {{r.report_desc}}
    

提交回复
热议问题