Help needed

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Help needed

neha bhurke
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

Omkar Parab
datetime=models.DateTimeField(auto_now=False) ?
Or remove "auto_now"
datetime=models.DateTimeField()

On Tue, Feb 23, 2021, 11:34 AM neha bhurke <[hidden email]> wrote:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJY8mfxi-bxtyMVWiOWCESK969Ok6nZaoyhWNSLvFO_0tEGp1Q%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

neha bhurke
I have done all these codes but it is saving only the current date .
Any other method 
Regard,
Neha Bhurke

Precise Industrial Solutions Private Limited

Mob: +91 7738946067 I O: +91 22 28943214

Add: 115, 1st Floor, Hari Om Plaza, Behind Omkareshwar Mandir, Near National Park, Borivali (E), Mumbai-400066




On Tue, Feb 23, 2021 at 12:10 PM Omkar Parab <[hidden email]> wrote:
datetime=models.DateTimeField(auto_now=False) ?
Or remove "auto_now"
datetime=models.DateTimeField()

On Tue, Feb 23, 2021, 11:34 AM neha bhurke <[hidden email]> wrote:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJY8mfxi-bxtyMVWiOWCESK969Ok6nZaoyhWNSLvFO_0tEGp1Q%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEwf5Q2k2Ah3j_eSmCpjZSkfDEFKDqRySULc8Wb5kOQSwJaTRg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

Danny Gho
Maybe it is not related to the model definition, but rather the .save() object?

On Tuesday, February 23, 2021 at 1:52:04 PM UTC+7 [hidden email] wrote:
I have done all these codes but it is saving only the current date .
Any other method 
Regard,
Neha Bhurke

Precise Industrial Solutions Private Limited

Mob: <a href="tel:+91%2077389%2046067" value="+917738946067" target="_blank" rel="nofollow">+91 7738946067 I O: <a href="tel:+91%2022%202894%203214" value="+912228943214" target="_blank" rel="nofollow">+91 22 28943214

Add: 115, 1st Floor, Hari Om Plaza, Behind Omkareshwar Mandir, Near National Park, Borivali (E), Mumbai-400066




On Tue, Feb 23, 2021 at 12:10 PM Omkar Parab <[hidden email]> wrote:
datetime=models.DateTimeField(auto_now=False) ?
Or remove "auto_now"
datetime=models.DateTimeField()

On Tue, Feb 23, 2021, 11:34 AM neha bhurke <[hidden email]> wrote:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c98c61c4-f767-4917-88e2-aed03c91c7can%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

neha bhurke
I have created the form 
this is my views.py.
def newdata(request):
if request.method == "POST":
MyDataform = Dataform(request.POST)
if MyDataform.is_valid():
MyDataform.save()
results = machinelist.objects.all()
#result = data.objects.all()
return redirect('/', {'data': results})
else:
MyDataform=Dataform()
results = machinelist.objects.all()
result = insert.objects.all()
return redirect('/',{'data': results},{'record':result})
else:
results = machinelist.objects.all()
result = insert.objects.all()
return redirect('/', {'data': results},{'record':result})
This is my forms.py
class Dataform(forms.ModelForm):
class Meta:
model = insert
fields = "__all__"
Regard,
Neha Bhurke

Precise Industrial Solutions Private Limited

Mob: +91 7738946067 I O: +91 22 28943214

Add: 115, 1st Floor, Hari Om Plaza, Behind Omkareshwar Mandir, Near National Park, Borivali (E), Mumbai-400066




On Tue, Feb 23, 2021 at 12:35 PM Danny <[hidden email]> wrote:
Maybe it is not related to the model definition, but rather the .save() object?

On Tuesday, February 23, 2021 at 1:52:04 PM UTC+7 [hidden email] wrote:
I have done all these codes but it is saving only the current date .
Any other method 
Regard,
Neha Bhurke

Precise Industrial Solutions Private Limited

Mob: <a href="tel:+91%2077389%2046067" value="+917738946067" rel="nofollow" target="_blank">+91 7738946067 I O: <a href="tel:+91%2022%202894%203214" value="+912228943214" rel="nofollow" target="_blank">+91 22 28943214

Add: 115, 1st Floor, Hari Om Plaza, Behind Omkareshwar Mandir, Near National Park, Borivali (E), Mumbai-400066




On Tue, Feb 23, 2021 at 12:10 PM Omkar Parab <[hidden email]> wrote:
datetime=models.DateTimeField(auto_now=False) ?
Or remove "auto_now"
datetime=models.DateTimeField()

On Tue, Feb 23, 2021, 11:34 AM neha bhurke <[hidden email]> wrote:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c98c61c4-f767-4917-88e2-aed03c91c7can%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEwf5Q2ZhT%2BSPP%2BQrEy-8VYswxNqSE5FmTX-%2BPR6H_bMXw-bAw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

John

I think you are misunderstanding the use of `auto_now=True`. It will always set that field to the time when the object was last saved; it's not meant to be a form field. See https://docs.djangoproject.com/en/3.1/ref/models/fields/#datefield. What are you trying to do? Have a date field that is preset to today's date? If it's that, then the next paragraph in the docs explains how to set `default=`.

John

On 23/02/2021 07:14, neha bhurke wrote:
I have created the form 
this is my views.py.
def newdata(request):
    if request.method == "POST":
        MyDataform = Dataform(request.POST)
        if MyDataform.is_valid():
            MyDataform.save()
            results = machinelist.objects.all()
            #result = data.objects.all()
            return redirect('/', {'data': results})
        else:
            MyDataform=Dataform()
            results = machinelist.objects.all()
            result = insert.objects.all()
            return redirect('/',{'data': results},{'record':result})
    else:
        results = machinelist.objects.all()
        result = insert.objects.all()
        return redirect('/', {'data': results},{'record':result})
This is my forms.py
class Dataform(forms.ModelForm):
    class Meta:
        model = insert
        fields = "__all__"
Regard,
Neha Bhurke

Precise Industrial Solutions Private Limited

Mob: +91 7738946067 I O: +91 22 28943214

Add: 115, 1st Floor, Hari Om Plaza, Behind Omkareshwar Mandir, Near National Park, Borivali (E), Mumbai-400066




On Tue, Feb 23, 2021 at 12:35 PM Danny <[hidden email]> wrote:
Maybe it is not related to the model definition, but rather the .save() object?

On Tuesday, February 23, 2021 at 1:52:04 PM UTC+7 [hidden email] wrote:
I have done all these codes but it is saving only the current date .
Any other method 
Regard,
Neha Bhurke

Precise Industrial Solutions Private Limited

Mob: <a href="tel:+91%2077389%2046067" value="+917738946067" rel="nofollow" target="_blank" moz-do-not-send="true">+91 7738946067 I O: <a href="tel:+91%2022%202894%203214" value="+912228943214" rel="nofollow" target="_blank" moz-do-not-send="true">+91 22 28943214

Add: 115, 1st Floor, Hari Om Plaza, Behind Omkareshwar Mandir, Near National Park, Borivali (E), Mumbai-400066




On Tue, Feb 23, 2021 at 12:10 PM Omkar Parab <[hidden email]> wrote:
datetime=models.DateTimeField(auto_now=False) ?
Or remove "auto_now"
datetime=models.DateTimeField()

On Tue, Feb 23, 2021, 11:34 AM neha bhurke <[hidden email]> wrote:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c98c61c4-f767-4917-88e2-aed03c91c7can%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEwf5Q2ZhT%2BSPP%2BQrEy-8VYswxNqSE5FmTX-%2BPR6H_bMXw-bAw%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3f5b9342-8b8d-d01e-5216-0cd7226718cd%40martinhome.org.uk.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

FIRDOUS BHAT
In reply to this post by neha bhurke
You definitely have to remove, auto_now=True

On Tue, Feb 23, 2021 at 11:34 AM neha bhurke <[hidden email]> wrote:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFB6YJqT46%3DfA_fZ%2BLGK7LmVCU3jsdbvZFh5W0BWEx3Oxh0_tg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

Chelsea Fan
In reply to this post by neha bhurke
Replace auto_now to auto_add_now


On Tue, 23 Feb 2021, 9:04 am neha bhurke, <[hidden email]> wrote:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJwZndeAx%2BLoEKiVNogcE-M2FV-zjd97Vk2j2j6LaqZDE7xSoQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

FIRDOUS BHAT
In reply to this post by neha bhurke
Why don't you change field type to Char and save the datetimestamp by your side?

On Tue, Feb 23, 2021 at 12:21 PM neha bhurke <[hidden email]> wrote:
I have done all these codes but it is saving only the current date .
Any other method 
Regard,
Neha Bhurke

Precise Industrial Solutions Private Limited

Mob: +91 7738946067 I O: +91 22 28943214

Add: 115, 1st Floor, Hari Om Plaza, Behind Omkareshwar Mandir, Near National Park, Borivali (E), Mumbai-400066




On Tue, Feb 23, 2021 at 12:10 PM Omkar Parab <[hidden email]> wrote:
datetime=models.DateTimeField(auto_now=False) ?
Or remove "auto_now"
datetime=models.DateTimeField()

On Tue, Feb 23, 2021, 11:34 AM neha bhurke <[hidden email]> wrote:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJY8mfxi-bxtyMVWiOWCESK969Ok6nZaoyhWNSLvFO_0tEGp1Q%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEwf5Q2k2Ah3j_eSmCpjZSkfDEFKDqRySULc8Wb5kOQSwJaTRg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFB6YJpvoNNhVhgZe_Te0M4UU%2BSuS2Xdvp52BirasdJhoX-LcA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Help needed

Rodrigo Delfino
In reply to this post by neha bhurke
Such as others have said, you should remove ```auto_now=True```, after that, you cant  forget to run ```makemigrantions``` and ```migrate```

Em terça-feira, 23 de fevereiro de 2021 às 03:04:24 UTC-3, [hidden email] escreveu:
Hello everyone,

I am trying to select the custom date but datetime=models.DateTimeField(auto_now=True)
is only taking current date ....
Please help me 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a7e3f5bd-e65a-4f06-9d82-0183929376can%40googlegroups.com.