--
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 django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b1c53101-c7c6-403f-9b43-6713d7f66c07n%40googlegroups.com.
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
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJY8mfxi-bxtyMVWiOWCESK969Ok6nZaoyhWNSLvFO_0tEGp1Q%40mail.gmail.com.
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})
class Dataform(forms.ModelForm):
class Meta:
model = insert
fields = "__all__"
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
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c98c61c4-f767-4917-88e2-aed03c91c7can%40googlegroups.com.
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
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.
--
--
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEwf5Q2k2Ah3j_eSmCpjZSkfDEFKDqRySULc8Wb5kOQSwJaTRg%40mail.gmail.com.