0

I am trying to get 'date' which can be eg 2023/01/29 to print in my template file.

def time_booking(request):
    if 'date' in request.COOKIES:
        context = {
            'date':request.COOKIES['date'],
        }
        print("Run Run")
        return render(request, "path_to_file.html", context)
        <h1>Date will be here here</h1>
        {% if date != -1 or null %}
        <h1> Date is real {{date}}</h1>
        {% else %}
        <h1> Date is not real{{date}} </h1>
        {% endif %}
        <h1> complete run </h1>

The code currently check if the variable 'date' exists and isn't -1 but I then go to print it and the content doesn't come out.

I tried using a single set of {} as well as using print(content[date]), but again the variable was not output. I am trying to get it to output the date which has been entered before hand.

Any help would be greatly apricated.

hw777644
  • 13
  • 3
  • At first you should filter `null` in views itself as `None`, it can't be done in templates, they are not meant for these things, and did you set cookie `date` using some js code? Or python? – Sunderam Dubey Jan 29 '23 at 17:04

0 Answers0