Hi,
I am new to django,
I have field1 as dropdown with mentioned months name
filed2 is none and excluded in forms
I want while inserting the data , if I select month , it should insert the same value in field2
request your support
Ex:
field1 .value('JAN')
field2 is excluded from froms.py
want the value to be inserted in field2 from field 1 in db
update / delete /insert functions are fine, no issues but field2 is not getting value from field 1
Thank You
update / delete /insert functions are fine, no issues but field2 is not getting value from field 1 Thank You --
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/61f44948.1c69fb81.9ac1a.ad93%40mx.google.com.
Hi,
Thanks for your support below are the views and models, plz guide, no errors but no success
Views.py (cmonth is none value and excluded in form) month is insertable from form template
def insert(request):
form=StudentForm()
if request.method=="POST":
form=StudentForm(request.POST)
cmonth=request.GET.get('month')
if form.is_valid():
form.save()
return redirect('/home1')
return render(request,'enroll/insert.html',{'form':form})
------------------------------------------------------------------------------------------------------
Models.py
class student(models.Model):
month = models.CharField(max_length=64, choices=COLOR_CHOICES, default='plz')
cmonth=models.CharField(max_length=64)
name= models.CharField(max_length=64)
salary= models.CharField(max_length=64)
#def student(month = request.GET['value'], cmonth=cmonth)
def fm(request):
fm =student.objects.create(month=request.GET['month'],cmonth=cmonth)
---------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Here I want CMonth data from Month
From:
django...@googlegroups.com [mailto:django...@googlegroups.com] On
Behalf Of Bernard Mallala
Sent: 29 January 2022 01:57
To: Django users
Subject: Re: Django users
I am thinking about skiing this afternoon
On Friday, January 28, 2022 at 12:18:08 PM UTC-7 Kasper Laudrup wrote:
On 28/01/2022 10.12, Anil Choudhari wrote:
> How to connect hive in Django ?
>
You can't. Better find something else to do.
Kind regards,
Kasper Laudrup
--
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/6ccddcdb-67d7-4cd4-a20a-9d1f41a95194n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/51d615fc-43dd-4250-8d04-101c06ad3bf8%40Spark.
From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf Of Ammar Mohammed
Sent: 29 January 2022 01:32
To: 'Rahul Chauhan' via Django users
Subject: Re: copy value from field1 to field2
Hello
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/51d615fc-43dd-4250-8d04-101c06ad3bf8%40Spark.
Hi, Thanks for your support below are the views and models, plz guide, no errors but no success Views.py (cmonth is none value and excluded in form) month is insertable from form templatedef insert(request): form=StudentForm() if request.method=="POST": form=StudentForm(request.POST) cmonth=request.GET.get('month') if form.is_valid(): form.save() return redirect('/home1') return render(request,'enroll/insert.html',{'form':form})------------------------------------------------------------------------------------------------------ Models.pyclass student(models.Model): month = models.CharField(max_length=64, choices=COLOR_CHOICES, default='plz') cmonth=models.CharField(max_length=64) name= models.CharField(max_length=64) salary= models.CharField(max_length=64) #def student(month = request.GET['value'], cmonth=cmonth) def fm(request): fm =student.objects.create(month=request.GET['month'],cmonth=cmonth) --------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------Here I want CMonth data from Month<image002.jpg> From: django...@googlegroups.com [mailto:django...@googlegroups.com] On Behalf Of Ammar MohammedSent: 29 January 2022 01:32To: 'Rahul Chauhan' via Django usersSubject: Re: copy value from field1 to field2
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/61f4656c.1c69fb81.f300.d6d5%40mx.google.com.
Sent: 29 January 2022 03:42
To: 'Rahul Chauhan' via Django users
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a0b7392e-0477-4533-b026-5171879dbc93%40Spark.
formentry = form.save(commit=False)
formentry
.field2 = formentry
.cleaned_data['field1']
formentry
.save()
This is untested but i am very sure that this works....
Regards
--
Hi,
I did change as per your advise,, no errors , but no changes field 2 (cmonth) not got value from field1 (month) below is my views.py
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKGT9mwczssa%3D%3DP%3Dxp8rC2cbwkQx%3DoRb%2BRXHGc_NfQOd05824Q%40mail.gmail.com.
Hi,
thanks for syntax code:
it works I made added the instance the value copied from field2 (cmonth) into field1 (month) ,, below is the updated code.
form.save(commit=False)
form.instance.cmonth=form.cleaned_data['month']
form.save()
From: Feroz Ahmed
[mailto:feroz...@gmail.com]
Sent: 29 January 2022 06:15
To: 'django...@googlegroups.com'
Subject: RE: copy value from field1 to field2
Hi,
I did change as per your advise,, no errors , but no changes field 2 (cmonth) not got value from field1 (month) below is my views.py
From: django...@googlegroups.com
[mailto:django...@googlegroups.com] On Behalf Of Sebastian Jung
Sent: 29 January 2022 05:03
To: django...@googlegroups.com
Subject: Re: copy value from field1 to field2
Hello,
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAKGT9mwczssa%3D%3DP%3Dxp8rC2cbwkQx%3DoRb%2BRXHGc_NfQOd05824Q%40mail.gmail.com.