Update Django Application Date?

0

I have an application in Django in which users enter a date by means of a calendar but the date shown on the calendar is always the same as the day I started the Django server.

I explain if I start the server on 5/19/2018, the schedule of the html template shows the same date always and does not update, for that I have to restart the server so that it takes the date of the day.

I would like to know if you excised a way for Django to update the date without having to restart the server.

I enclose the parts where I use the date in my application

thanks

models.py

from future import unicode_literals from django.db import models from django.db import models from django.forms import ModelForm from datetime import datetime from django import forms from django.forms import extras from django.forms.extras.widgets import SelectDateWidget from django.utils import timezone from django.core.validators import RegexValidator from datetime import date import datetime

class DataFolder (models.Model):       date = models.DateTimeField (['% Y-% m-% d'])       def get_absolute_url (self):         return reverse ('newdate', kwargs = {'pk': self.pk})  

forms.py

from django import forms from oficios.models import DatosCarpeta import datetime import time from datetime import datetime from django.forms.extras.widgets import SelectDateWidget from django.utils import timezone from functools import partial from django.conf import settings from datetimewidget.widgets import DateTimeWidget from django.forms.extras.widgets import SelectDateWidget

DateInput = partial (forms.DateInput, {'class': 'datepicker'}) time_widget = forms.widgets.TimeInput (attrs = {'class': 'timepicker'}) valid_time_formats = ['% H:% M', '% I:% M% p', '% I:% M% p', '% H:% M% p', '% H:% M% p' ]

class UploadForm (forms.Form):     date = forms.DateField (label = ("Start date"),                                     initial = datetime.now (),                                     input_formats = ['% Y-% m-% d'],                                     widget = forms.DateInput (format = '% Y-% m-% d'))

Template html Code

{% load static from staticfiles %} Ingreso De Oficios

<script>
     $( function() {
        $( "#id_fecha" ).datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true,
        changeYear: true });
    } );
     $( function() {
        $( "#id_fechaa" ).datepicker({ dateFormat: 'yy-mm-dd', changeMonth: true,
        changeYear: true });
    } );
</script>
<script>
    function clicked(e)
    {
        if(!confirm('Desea Ingresar El Oficio'))e.preventDefault();
    }
</script>


<script src="//widget.time.is/es.js"></script>
<script>
    time_is_widget.init({Colombia_z11b:{template:"TIME<br>DATE", date_format:"year-monthnum-daynum"}});
</script>

<script type="text/javascript">
    $(function() {
        $('#id_hora').timepicker({ 'timeFormat': 'H:i a' , 'step': '1'});
    });
</script>

 <style>
        body{font:14px/1.5 "Times New Roman", Georgia, Serif; padding:0 10px;}
        a:link, a:visited{text-decoration:none; color:#416CE5; border-bottom:1px solid #416CE5;}

</style>

<title>Infreso De Oficios</title>

<form action="{%  url 'carpetas' %}" method="POST" enctype="multipart/form-data">{% csrf_token %}
<h1><a target="_blank"><p style="color:black;">MANEJO DE OFICIOS CESPA</p></a></h1>

<section id="uno">

    <div class="content">
        <div class="admin-panel"><label for="toggle" class="admin-text">INGRESO DE OFICIOS</label></div>
        <input type="checkbox" id="toggle">
        <label class="cog octicon octicon-gear" for="toggle"></label>
        <div class="menu">

            <div class="arrow" align="center"></div>

            <table class="table table-hover" align="center" border="1">        
            <thead>

                    <th><h2><p style="color:black;"><b>Fecha De Ingreso</b></p></h2></th>

                </tr>

            </thead>

    
asked by mikey 24.07.2018 в 15:46
source

0 answers