Re: Help me - Django and python

2021-06-22 Thread avdesh sharma
Here is my View.py code

from django.shortcuts import render
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.contrib.auth import authenticate, logout, login
from django.contrib.auth.decorators import login_required
from student.models import *
from django.views.generic import TemplateView
import datetime, random
from django.contrib.auth.backends import BaseBackend
# Create your views here.


def index_view(request):
if request.method == 'POST':
username = request.POST.get('username')
password = request.POST.get('password')
tab_selected = request.POST.get('tab_selected')

user = authenticate(username=username, password=password)
print(user)
if user:
# if get_user(username):
if user.is_active:
login(request, user)
request.session['username'] = username
request.session['tab_selected'] = tab_selected
if tab_selected == 'student_tab':
return HttpResponseRedirect(reverse('student:stud_home'))
elif tab_selected == 'dept_tab':
if username[:3] == 'hod':
return HttpResponseRedirect(reverse('student:hod_home'))
else:
return HttpResponseRedirect(reverse('student:dep_home'))
elif tab_selected == 'office_tab':
return HttpResponseRedirect(reverse('student:off_home'))
else:
user_login = 'inactive'
return render(request, 'student/index.html',
context={'login': user_login})
else:
user_login = 'invalid'
return render(request, 'student/index.html',
context={'login': user_login})
else:
return render(request, 'student/index.html', context={})


index.html


PASSWORD



{% if login == 'inactive' %}
User Inactive! Contact Admin!
{% elif login == 'invalid' %}
line 32 username or
password Invalid
{% endif%}
{% if tab_error == True %}
Invalid Tab Selected
{% endif %}



On Tue, Jun 22, 2021 at 11:55 AM DJANGO DEVELOPER 
wrote:

> can you please share your login view code?
>
> On Tue, Jun 22, 2021 at 10:12 AM avdesh sharma 
> wrote:
>
>> Hi All,
>>
>> I have an issue coming in my django code, even though the user id and
>> password is present in sqlite3 db still  the user is giving '*None'*
>> value
>> user = authenticate(username=username, password=password)
>>
>> and I am not able to login with user and throwing this error.
>>
>> [image: image.png]
>>
>>
>>
>>
>> --
>> Warm Regards,
>> Avdesh Kumar Sharma
>> 9650031844
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAF5Nfo65s-8c75FRkhF0rN7Sh0aUH6eKNBbQ--OMawNPCVX13w%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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKPY9p%3DSQDqv12b8K52FuG9mp40SM9sLFAQ4meaPM37NJxM4zQ%40mail.gmail.com
> 
> .
>


-- 
Warm Regards,
Avdesh Kumar Sharma
9650031844

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAF5Nfo7JkSetxb-kfGAjnRLJiCBG%2BvOEcgj38Oe0migcXEffvg%40mail.gmail.com.


Re: Help me - Django and python

2021-06-22 Thread DJANGO DEVELOPER
by seeing your code, it seems that only the 'else' part is working. have
you provided value='{{dict_key.model_password_field}} in your html input
element?

On Tue, Jun 22, 2021 at 12:52 PM avdesh sharma 
wrote:

> Here is my View.py code
>
> from django.shortcuts import render
> from django.http import HttpResponseRedirect
> from django.urls import reverse
> from django.contrib.auth import authenticate, logout, login
> from django.contrib.auth.decorators import login_required
> from student.models import *
> from django.views.generic import TemplateView
> import datetime, random
> from django.contrib.auth.backends import BaseBackend
> # Create your views here.
>
>
> def index_view(request):
> if request.method == 'POST':
> username = request.POST.get('username')
> password = request.POST.get('password')
> tab_selected = request.POST.get('tab_selected')
>
> user = authenticate(username=username, password=password)
> print(user)
> if user:
> # if get_user(username):
> if user.is_active:
> login(request, user)
> request.session['username'] = username
> request.session['tab_selected'] = tab_selected
> if tab_selected == 'student_tab':
> return HttpResponseRedirect(reverse('student:stud_home'))
> elif tab_selected == 'dept_tab':
> if username[:3] == 'hod':
> return 
> HttpResponseRedirect(reverse('student:hod_home'))
> else:
> return 
> HttpResponseRedirect(reverse('student:dep_home'))
> elif tab_selected == 'office_tab':
> return HttpResponseRedirect(reverse('student:off_home'))
> else:
> user_login = 'inactive'
> return render(request, 'student/index.html', 
> context={'login': user_login})
> else:
> user_login = 'invalid'
> return render(request, 'student/index.html', context={'login': 
> user_login})
> else:
> return render(request, 'student/index.html', context={})
>
>
> index.html
>
> 
> PASSWORD
>  class="form-control" name="password" placeholder="Enter Password">
> 
> 
> {% if login == 'inactive' %}
> User Inactive! Contact 
> Admin!
> {% elif login == 'invalid' %}
> line 32 username or password 
> Invalid
> {% endif%}
> {% if tab_error == True %}
> Invalid Tab Selected
> {% endif %}
> 
>
>
> On Tue, Jun 22, 2021 at 11:55 AM DJANGO DEVELOPER 
> wrote:
>
>> can you please share your login view code?
>>
>> On Tue, Jun 22, 2021 at 10:12 AM avdesh sharma 
>> wrote:
>>
>>> Hi All,
>>>
>>> I have an issue coming in my django code, even though the user id and
>>> password is present in sqlite3 db still  the user is giving '*None'*
>>> value
>>> user = authenticate(username=username, password=password)
>>>
>>> and I am not able to login with user and throwing this error.
>>>
>>> [image: image.png]
>>>
>>>
>>>
>>>
>>> --
>>> Warm Regards,
>>> Avdesh Kumar Sharma
>>> 9650031844
>>>
>>> --
>>> 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+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAF5Nfo65s-8c75FRkhF0rN7Sh0aUH6eKNBbQ--OMawNPCVX13w%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 django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAKPY9p%3DSQDqv12b8K52FuG9mp40SM9sLFAQ4meaPM37NJxM4zQ%40mail.gmail.com
>> 
>> .
>>
>
>
> --
> Warm Regards,
> Avdesh Kumar Sharma
> 9650031844
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF5Nfo7JkSetxb-kfGAjnRLJiCBG%2BvOEcgj38Oe0migcXEffvg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group

Re: Help me - Django and python

2021-06-22 Thread DJANGO DEVELOPER
your index.html


PASSWORD



{% if login == 'inactive' %}
User Inactive! Contact Admin!
{% elif login == 'invalid' %}
line 32 username or
password Invalid
{% endif%}
{% if tab_error == True %}
Invalid Tab Selected
{% endif %}



changed index.html


PASSWORD



{% if login == 'inactive' %}
User Inactive! Contact Admin!
{% else %}
line 32 username or
password Invalid
{% endif%}
{% if tab_error == True %}
Invalid Tab Selected
{% endif %}


On Tue, Jun 22, 2021 at 2:16 PM DJANGO DEVELOPER 
wrote:

> by seeing your code, it seems that only the 'else' part is working. have
> you provided value='{{dict_key.model_password_field}} in your html input
> element?
>
> On Tue, Jun 22, 2021 at 12:52 PM avdesh sharma 
> wrote:
>
>> Here is my View.py code
>>
>> from django.shortcuts import render
>> from django.http import HttpResponseRedirect
>> from django.urls import reverse
>> from django.contrib.auth import authenticate, logout, login
>> from django.contrib.auth.decorators import login_required
>> from student.models import *
>> from django.views.generic import TemplateView
>> import datetime, random
>> from django.contrib.auth.backends import BaseBackend
>> # Create your views here.
>>
>>
>> def index_view(request):
>> if request.method == 'POST':
>> username = request.POST.get('username')
>> password = request.POST.get('password')
>> tab_selected = request.POST.get('tab_selected')
>>
>> user = authenticate(username=username, password=password)
>> print(user)
>> if user:
>> # if get_user(username):
>> if user.is_active:
>> login(request, user)
>> request.session['username'] = username
>> request.session['tab_selected'] = tab_selected
>> if tab_selected == 'student_tab':
>> return HttpResponseRedirect(reverse('student:stud_home'))
>> elif tab_selected == 'dept_tab':
>> if username[:3] == 'hod':
>> return 
>> HttpResponseRedirect(reverse('student:hod_home'))
>> else:
>> return 
>> HttpResponseRedirect(reverse('student:dep_home'))
>> elif tab_selected == 'office_tab':
>> return HttpResponseRedirect(reverse('student:off_home'))
>> else:
>> user_login = 'inactive'
>> return render(request, 'student/index.html', 
>> context={'login': user_login})
>> else:
>> user_login = 'invalid'
>> return render(request, 'student/index.html', context={'login': 
>> user_login})
>> else:
>> return render(request, 'student/index.html', context={})
>>
>>
>> index.html
>>
>> 
>> PASSWORD
>> > class="form-control" name="password" placeholder="Enter Password">
>> 
>> 
>> {% if login == 'inactive' %}
>> User Inactive! Contact 
>> Admin!
>> {% elif login == 'invalid' %}
>> line 32 username or password 
>> Invalid
>> {% endif%}
>> {% if tab_error == True %}
>> Invalid Tab Selected
>> {% endif %}
>> 
>>
>>
>> On Tue, Jun 22, 2021 at 11:55 AM DJANGO DEVELOPER <
>> abubakarbr...@gmail.com> wrote:
>>
>>> can you please share your login view code?
>>>
>>> On Tue, Jun 22, 2021 at 10:12 AM avdesh sharma <
>>> avdeshsharma...@gmail.com> wrote:
>>>
 Hi All,

 I have an issue coming in my django code, even though the user id and
 password is present in sqlite3 db still  the user is giving '*None'*
 value
 user = authenticate(username=username, password=password)

 and I am not able to login with user and throwing this error.

 [image: image.png]




 --
 Warm Regards,
 Avdesh Kumar Sharma
 9650031844

 --
 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+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAF5Nfo65s-8c75FRkhF0rN7Sh0aUH6eKNBbQ--OMawNPCVX13w%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 django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAKPY9p%3DSQDqv12b8K52FuG9mp40SM9sLFAQ4meaPM37NJxM4zQ%40mail.gmail.com
>>> 
>>> .
>

Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER
according to your code, you're trying to update the product record. right?
If so, then you're doing things the right way.

On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
mayanksandikar191...@gmail.com> wrote:

> hello , sir your mobile no. is not on whatsapp. please assist me  with
> this
>
> On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
> onyemordidan...@gmail.com> wrote:
>
>> Hello, have your problem been solved if no kindly contact me on WhatsApp
>> 08167997730 to assist you better.
>>
>> On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> https://github.com/Mayanksandikar/3-database
>>>
>>>
>>> On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins 
>>> wrote:
>>>
 Post your code on github and provide the link here

 Em sábado, 19 de junho de 2021 às 22:00:24 UTC-3,
 mayanksand...@gmail.com escreveu:

> I have a few errors in my program.
> 1. HTML
> In my front view only my last text box is working and all the upper
> text boxes are unassessable.
> 2. Database
> I am getting only the user quantity in the database but not getting
> the itemname, price and total amount in it.
>
> I don't know where it is going wrong, I've been stuck here for the
> last 4 days. I'm a beginner in django and python. Which logic is used for
> this program?
> Please, please help me.
>
> PFA
>
 --
 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+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/9feed719-8ab5-4523-80a1-ad062fe1999en%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 django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAOS5mPyWASHhqgx947GwftVcmMq9PD9D6PLyHA5Kgv9DqY5GHQ%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 django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CA%2B-W-o66GbpFyKAbGCmeawjndTBUk%3DwqJaV%2B5Nf27siQmnA8Hw%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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAOS5mPxJXuV8vBvtFMYGkiiGqm5%3DZxhyuFBaxF_Q2COhZYWnBw%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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKPY9pmTCn0i63Yb3VLfjpuK6aqyvkg4o2TGKv_rzGwOLiwh3A%40mail.gmail.com.


Re: Help me Please - Django and python program

2021-06-22 Thread mayank sandikar
Hello sir,
I'm trying to insert the data in the table. For example in database
Itemname quantity price user-quantity amount
pen20  5   00
book  20 10  00

in my database I'm getting this result
pen20  5   00
book  20 10  00
 20

I want to take the itemname, quantity, and price in the last row as well.
In my html front view (screenshot 50) only the last text box is active in
the user quantity column.

please help me.
thank you



On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER 
wrote:

> according to your code, you're trying to update the product record. right?
> If so, then you're doing things the right way.
>
> On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> hello , sir your mobile no. is not on whatsapp. please assist me  with
>> this
>>
>> On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
>> onyemordidan...@gmail.com> wrote:
>>
>>> Hello, have your problem been solved if no kindly contact me on WhatsApp
>>> 08167997730 to assist you better.
>>>
>>> On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 https://github.com/Mayanksandikar/3-database


 On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins 
 wrote:

> Post your code on github and provide the link here
>
> Em sábado, 19 de junho de 2021 às 22:00:24 UTC-3,
> mayanksand...@gmail.com escreveu:
>
>> I have a few errors in my program.
>> 1. HTML
>> In my front view only my last text box is working and all the upper
>> text boxes are unassessable.
>> 2. Database
>> I am getting only the user quantity in the database but not getting
>> the itemname, price and total amount in it.
>>
>> I don't know where it is going wrong, I've been stuck here for the
>> last 4 days. I'm a beginner in django and python. Which logic is used for
>> this program?
>> Please, please help me.
>>
>> PFA
>>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9feed719-8ab5-4523-80a1-ad062fe1999en%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 django-users+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAOS5mPyWASHhqgx947GwftVcmMq9PD9D6PLyHA5Kgv9DqY5GHQ%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 django-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CA%2B-W-o66GbpFyKAbGCmeawjndTBUk%3DwqJaV%2B5Nf27siQmnA8Hw%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 django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAOS5mPxJXuV8vBvtFMYGkiiGqm5%3DZxhyuFBaxF_Q2COhZYWnBw%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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAKPY9pmTCn0i63Yb3VLfjpuK6aqyvkg4o2TGKv_rzGwOLiwh3A%40mail.gmail.com
> 

Re: Help me Please - Django and python program

2021-06-22 Thread mayank sandikar
my index.html is



 Edit 

.button {
  border: none;
  color: black;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;

}

.button2 {background-color: #008CBA;}









 


  
ID
Itemname
Quantity

 rate
  amount
  

  {% for displayemp in editupdaterecord%}
  
  {{displayemp.id}}
  {{displayemp.Itemname}}
  {{displayemp.quantity}} 
   {{displayemp.rate}} 
  {{displayemp.basicamount}} 

  
   {% endfor %}
   

  
 {% csrf_token %}


  
ID
Itemname
Quantity

userquantity
amount
  

  {% for displayemp in editupdaterecord%}
  
  {{displayemp.id}}
  {{displayemp.Itemname}}
  {{displayemp.quantity}} 


  

   {% csrf_token %}
  
   {{displayemp.amount2}} 
  
   {% endfor %}


   


Add









On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
mayanksandikar191...@gmail.com> wrote:

> Hello sir,
> I'm trying to insert the data in the table. For example in database
> Itemname quantity price user-quantity amount
> pen20  5   00
> book  20 10  00
>
> in my database I'm getting this result
> pen20  5   00
> book  20 10  00
>  20
>
> I want to take the itemname, quantity, and price in the last row as well.
> In my html front view (screenshot 50) only the last text box is active in
> the user quantity column.
>
> please help me.
> thank you
>
>
>
> On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER 
> wrote:
>
>> according to your code, you're trying to update the product record. right?
>> If so, then you're doing things the right way.
>>
>> On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> hello , sir your mobile no. is not on whatsapp. please assist me  with
>>> this
>>>
>>> On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
>>> onyemordidan...@gmail.com> wrote:
>>>
 Hello, have your problem been solved if no kindly contact me on
 WhatsApp 08167997730 to assist you better.

 On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
 mayanksandikar191...@gmail.com> wrote:

> https://github.com/Mayanksandikar/3-database
>
>
> On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins 
> wrote:
>
>> Post your code on github and provide the link here
>>
>> Em sábado, 19 de junho de 2021 às 22:00:24 UTC-3,
>> mayanksand...@gmail.com escreveu:
>>
>>> I have a few errors in my program.
>>> 1. HTML
>>> In my front view only my last text box is working and all the upper
>>> text boxes are unassessable.
>>> 2. Database
>>> I am getting only the user quantity in the database but not getting
>>> the itemname, price and total amount in it.
>>>
>>> I don't know where it is going wrong, I've been stuck here for the
>>> last 4 days. I'm a beginner in django and python. Which logic is used 
>>> for
>>> this program?
>>> Please, please help me.
>>>
>>> PFA
>>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/9feed719-8ab5-4523-80a1-ad062fe1999en%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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAOS5mPyWASHhqgx947GwftVcmMq9PD9D6PLyHA5Kgv9DqY5GHQ%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 django-users+unsubscr...@googlegr

Re: Help me Please - Django and python program

2021-06-22 Thread mayank sandikar
view.py
def displaydata(request):
   results = editupdaterecord.objects.all()


   if request.method=='POST':
 if request.POST.get('userquantity')  :
 quantity = request.POST.get('userquantity')
 a = editupdaterecord.objects.all()
 print(a)
   #  if results in a < quantity:
 saverecord = editupdaterecord(userquantity = quantity)
 saverecord.save()

   return render(request , 'index.html' ,{"editupdaterecord":results})


On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
mayanksandikar191...@gmail.com> wrote:

> my index.html is
>
> 
> 
>  Edit 
> 
> .button {
>   border: none;
>   color: black;
>   padding: 15px 32px;
>   text-align: center;
>   text-decoration: none;
>   display: inline-block;
>   font-size: 16px;
>   margin: 4px 2px;
>   cursor: pointer;
>
> }
>
> .button2 {background-color: #008CBA;}
>
> 
>
>
> 
> 
>
>
> 
>  
> 
> 
>   
> ID
> Itemname
> Quantity
>
>  rate
>   amount
>   
>
>   {% for displayemp in editupdaterecord%}
>   
>   {{displayemp.id}}
>   {{displayemp.Itemname}}
>   {{displayemp.quantity}} 
>{{displayemp.rate}} 
>   {{displayemp.basicamount}} 
>
>   
>{% endfor %}
>
>
>   
>  {% csrf_token %}
>
> 
>   
> ID
> Itemname
> Quantity
>
> userquantity
> amount
>   
>
>   {% for displayemp in editupdaterecord%}
>   
>   {{displayemp.id}}
>   {{displayemp.Itemname}}
>   {{displayemp.quantity}} 
>
>
>   
>
>{% csrf_token %}
>   
>{{displayemp.amount2}} 
>   
>{% endfor %}
>
>
>
> 
>
> Add
>
>
> 
> 
> 
>
>
>
>
> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> Hello sir,
>> I'm trying to insert the data in the table. For example in database
>> Itemname quantity price user-quantity amount
>> pen20  5   00
>> book  20 10  00
>>
>> in my database I'm getting this result
>> pen20  5   00
>> book  20 10  00
>>  20
>>
>> I want to take the itemname, quantity, and price in the last row as well.
>> In my html front view (screenshot 50) only the last text box is active in
>> the user quantity column.
>>
>> please help me.
>> thank you
>>
>>
>>
>> On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> according to your code, you're trying to update the product record.
>>> right?
>>> If so, then you're doing things the right way.
>>>
>>> On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 hello , sir your mobile no. is not on whatsapp. please assist me  with
 this

 On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
 onyemordidan...@gmail.com> wrote:

> Hello, have your problem been solved if no kindly contact me on
> WhatsApp 08167997730 to assist you better.
>
> On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
> mayanksandikar191...@gmail.com> wrote:
>
>> https://github.com/Mayanksandikar/3-database
>>
>>
>> On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins 
>> wrote:
>>
>>> Post your code on github and provide the link here
>>>
>>> Em sábado, 19 de junho de 2021 às 22:00:24 UTC-3,
>>> mayanksand...@gmail.com escreveu:
>>>
 I have a few errors in my program.
 1. HTML
 In my front view only my last text box is working and all the upper
 text boxes are unassessable.
 2. Database
 I am getting only the user quantity in the database but not getting
 the itemname, price and total amount in it.

 I don't know where it is going wrong, I've been stuck here for the
 last 4 days. I'm a beginner in django and python. Which logic is used 
 for
 this program?
 Please, please help me.

 PFA

>>> --
>>> 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+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/9feed719-8ab5-4523-80a1-ad062fe1999en%40googlegroups.com
>>> 
>>> .
>>>
>> --
>> You rece

Re: Help me Please - Django and python program

2021-06-22 Thread mayank sandikar
models.py

from django.db import models



class editupdaterecord(models.Model):
id = models.IntegerField(primary_key=1)
Itemname =  models.CharField(max_length=100)
quantity = models.IntegerField(blank=True, null=True, default=0)
basicamount = models.IntegerField(blank=True, null=True, default=0)
rate = models.IntegerField(blank=True, null=True, default=20)
userquantity = models.IntegerField(blank=True, null=True, default=0)
amount2 = models.IntegerField(blank=True, null=True, default=0)
class Meta:
db_table ='bill3'

On Tue, Jun 22, 2021 at 3:57 PM mayank sandikar <
mayanksandikar191...@gmail.com> wrote:

> view.py
> def displaydata(request):
>results = editupdaterecord.objects.all()
>
>
>if request.method=='POST':
>  if request.POST.get('userquantity')  :
>  quantity = request.POST.get('userquantity')
>  a = editupdaterecord.objects.all()
>  print(a)
>#  if results in a < quantity:
>  saverecord = editupdaterecord(userquantity = quantity)
>  saverecord.save()
>
>return render(request , 'index.html' ,{"editupdaterecord":results})
>
>
> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> my index.html is
>>
>> 
>> 
>>  Edit 
>> 
>> .button {
>>   border: none;
>>   color: black;
>>   padding: 15px 32px;
>>   text-align: center;
>>   text-decoration: none;
>>   display: inline-block;
>>   font-size: 16px;
>>   margin: 4px 2px;
>>   cursor: pointer;
>>
>> }
>>
>> .button2 {background-color: #008CBA;}
>>
>> 
>>
>>
>> 
>> 
>>
>>
>> 
>>  
>> 
>> 
>>   
>> ID
>> Itemname
>> Quantity
>>
>>  rate
>>   amount
>>   
>>
>>   {% for displayemp in editupdaterecord%}
>>   
>>   {{displayemp.id}}
>>   {{displayemp.Itemname}}
>>   {{displayemp.quantity}} 
>>{{displayemp.rate}} 
>>   {{displayemp.basicamount}} 
>>
>>   
>>{% endfor %}
>>
>>
>>   
>>  {% csrf_token %}
>>
>> 
>>   
>> ID
>> Itemname
>> Quantity
>>
>> userquantity
>> amount
>>   
>>
>>   {% for displayemp in editupdaterecord%}
>>   
>>   {{displayemp.id}}
>>   {{displayemp.Itemname}}
>>   {{displayemp.quantity}} 
>>
>>
>>   
>>
>>{% csrf_token %}
>>   
>>{{displayemp.amount2}} 
>>   
>>{% endfor %}
>>
>>
>>
>> 
>>
>> Add
>>
>>
>> 
>> 
>> 
>>
>>
>>
>>
>> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> Hello sir,
>>> I'm trying to insert the data in the table. For example in database
>>> Itemname quantity price user-quantity amount
>>> pen20  5   00
>>> book  20 10  00
>>>
>>> in my database I'm getting this result
>>> pen20  5   00
>>> book  20 10  00
>>>  20
>>>
>>> I want to take the itemname, quantity, and price in the last row as well.
>>> In my html front view (screenshot 50) only the last text box is active
>>> in the user quantity column.
>>>
>>> please help me.
>>> thank you
>>>
>>>
>>>
>>> On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 according to your code, you're trying to update the product record.
 right?
 If so, then you're doing things the right way.

 On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> hello , sir your mobile no. is not on whatsapp. please assist me
> with  this
>
> On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
> onyemordidan...@gmail.com> wrote:
>
>> Hello, have your problem been solved if no kindly contact me on
>> WhatsApp 08167997730 to assist you better.
>>
>> On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> https://github.com/Mayanksandikar/3-database
>>>
>>>
>>> On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins 
>>> wrote:
>>>
 Post your code on github and provide the link here

 Em sábado, 19 de junho de 2021 às 22:00:24 UTC-3,
 mayanksand...@gmail.com escreveu:

> I have a few errors in my program.
> 1. HTML
> In my front view only my last text box is working and all the
> upper text boxes are unassessable.
> 2. Database
> I am getting only the user quantity in the database but not
> getting the itemname, price and total amount in it.
>

Re: Help me Please - Django and python program

2021-06-22 Thread mayank sandikar
forms.py

from django import forms
from django.forms import fields
from project.models import editupdaterecord

class empforms(forms.ModelForm):
class Meta:
model=editupdaterecord
fields="__all__"


On Tue, Jun 22, 2021 at 3:57 PM mayank sandikar <
mayanksandikar191...@gmail.com> wrote:

> models.py
>
> from django.db import models
>
>
>
> class editupdaterecord(models.Model):
> id = models.IntegerField(primary_key=1)
> Itemname =  models.CharField(max_length=100)
> quantity = models.IntegerField(blank=True, null=True, default=0)
> basicamount = models.IntegerField(blank=True, null=True, default=0)
> rate = models.IntegerField(blank=True, null=True, default=20)
> userquantity = models.IntegerField(blank=True, null=True, default=0)
> amount2 = models.IntegerField(blank=True, null=True, default=0)
> class Meta:
> db_table ='bill3'
>
> On Tue, Jun 22, 2021 at 3:57 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> view.py
>> def displaydata(request):
>>results = editupdaterecord.objects.all()
>>
>>
>>if request.method=='POST':
>>  if request.POST.get('userquantity')  :
>>  quantity = request.POST.get('userquantity')
>>  a = editupdaterecord.objects.all()
>>  print(a)
>>#  if results in a < quantity:
>>  saverecord = editupdaterecord(userquantity = quantity)
>>  saverecord.save()
>>
>>return render(request , 'index.html' ,{"editupdaterecord":results})
>>
>>
>> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> my index.html is
>>>
>>> 
>>> 
>>>  Edit 
>>> 
>>> .button {
>>>   border: none;
>>>   color: black;
>>>   padding: 15px 32px;
>>>   text-align: center;
>>>   text-decoration: none;
>>>   display: inline-block;
>>>   font-size: 16px;
>>>   margin: 4px 2px;
>>>   cursor: pointer;
>>>
>>> }
>>>
>>> .button2 {background-color: #008CBA;}
>>>
>>> 
>>>
>>>
>>> 
>>> 
>>>
>>>
>>> 
>>>  
>>> 
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>>  rate
>>>   amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>{{displayemp.rate}} 
>>>   {{displayemp.basicamount}} 
>>>
>>>   
>>>{% endfor %}
>>>
>>>
>>>   
>>>  {% csrf_token %}
>>>
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>> userquantity
>>> amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>
>>>
>>>   
>>>
>>>{% csrf_token %}
>>>   
>>>{{displayemp.amount2}} 
>>>   
>>>{% endfor %}
>>>
>>>
>>>
>>> 
>>>
>>> Add
>>>
>>>
>>> 
>>> 
>>> 
>>>
>>>
>>>
>>>
>>> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 Hello sir,
 I'm trying to insert the data in the table. For example in database
 Itemname quantity price user-quantity amount
 pen20  5   00
 book  20 10  00

 in my database I'm getting this result
 pen20  5   00
 book  20 10  00
  20

 I want to take the itemname, quantity, and price in the last row as
 well.
 In my html front view (screenshot 50) only the last text box is active
 in the user quantity column.

 please help me.
 thank you



 On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> according to your code, you're trying to update the product record.
> right?
> If so, then you're doing things the right way.
>
> On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> hello , sir your mobile no. is not on whatsapp. please assist me
>> with  this
>>
>> On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
>> onyemordidan...@gmail.com> wrote:
>>
>>> Hello, have your problem been solved if no kindly contact me on
>>> WhatsApp 08167997730 to assist you better.
>>>
>>> On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 https://github.com/Mayanksandikar/3-database


 On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins 
 wrote:

> 

Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER
First of all please remove the for loop from your form.
secondly please add{{displayemp.userquantity_field}}
  {{displayemp.amount_field}} 

On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
mayanksandikar191...@gmail.com> wrote:

> view.py
> def displaydata(request):
>results = editupdaterecord.objects.all()
>
>
>if request.method=='POST':
>  if request.POST.get('userquantity')  :
>  quantity = request.POST.get('userquantity')
>  a = editupdaterecord.objects.all()
>  print(a)
>#  if results in a < quantity:
>  saverecord = editupdaterecord(userquantity = quantity)
>  saverecord.save()
>
>return render(request , 'index.html' ,{"editupdaterecord":results})
>
>
> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> my index.html is
>>
>> 
>> 
>>  Edit 
>> 
>> .button {
>>   border: none;
>>   color: black;
>>   padding: 15px 32px;
>>   text-align: center;
>>   text-decoration: none;
>>   display: inline-block;
>>   font-size: 16px;
>>   margin: 4px 2px;
>>   cursor: pointer;
>>
>> }
>>
>> .button2 {background-color: #008CBA;}
>>
>> 
>>
>>
>> 
>> 
>>
>>
>> 
>>  
>> 
>> 
>>   
>> ID
>> Itemname
>> Quantity
>>
>>  rate
>>   amount
>>   
>>
>>   {% for displayemp in editupdaterecord%}
>>   
>>   {{displayemp.id}}
>>   {{displayemp.Itemname}}
>>   {{displayemp.quantity}} 
>>{{displayemp.rate}} 
>>   {{displayemp.basicamount}} 
>>
>>   
>>{% endfor %}
>>
>>
>>   
>>  {% csrf_token %}
>>
>> 
>>   
>> ID
>> Itemname
>> Quantity
>>
>> userquantity
>> amount
>>   
>>
>>   {% for displayemp in editupdaterecord%}
>>   
>>   {{displayemp.id}}
>>   {{displayemp.Itemname}}
>>   {{displayemp.quantity}} 
>>
>>
>>   
>>
>>{% csrf_token %}
>>   
>>{{displayemp.amount2}} 
>>   
>>{% endfor %}
>>
>>
>>
>> 
>>
>> Add
>>
>>
>> 
>> 
>> 
>>
>>
>>
>>
>> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> Hello sir,
>>> I'm trying to insert the data in the table. For example in database
>>> Itemname quantity price user-quantity amount
>>> pen20  5   00
>>> book  20 10  00
>>>
>>> in my database I'm getting this result
>>> pen20  5   00
>>> book  20 10  00
>>>  20
>>>
>>> I want to take the itemname, quantity, and price in the last row as well.
>>> In my html front view (screenshot 50) only the last text box is active
>>> in the user quantity column.
>>>
>>> please help me.
>>> thank you
>>>
>>>
>>>
>>> On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 according to your code, you're trying to update the product record.
 right?
 If so, then you're doing things the right way.

 On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> hello , sir your mobile no. is not on whatsapp. please assist me
> with  this
>
> On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
> onyemordidan...@gmail.com> wrote:
>
>> Hello, have your problem been solved if no kindly contact me on
>> WhatsApp 08167997730 to assist you better.
>>
>> On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> https://github.com/Mayanksandikar/3-database
>>>
>>>
>>> On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins 
>>> wrote:
>>>
 Post your code on github and provide the link here

 Em sábado, 19 de junho de 2021 às 22:00:24 UTC-3,
 mayanksand...@gmail.com escreveu:

> I have a few errors in my program.
> 1. HTML
> In my front view only my last text box is working and all the
> upper text boxes are unassessable.
> 2. Database
> I am getting only the user quantity in the database but not
> getting the itemname, price and total amount in it.
>
> I don't know where it is going wrong, I've been stuck here for the
> last 4 days. I'm a beginner in django and python. Which logic is used 
> for
> this program?
> Please, please help me.
>
> PFA
>
 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To unsubscribe fr

Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER


 Edit 

.button {
  border: none;
  color: black;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;

}

.button2 {background-color: #008CBA;}









 


  
ID
Itemname
Quantity

 rate
  amount
  

  {% for displayemp in editupdaterecord%}
  
  {{displayemp.id}}
  {{displayemp.Itemname}}
  {{displayemp.quantity}} 
   {{displayemp.rate}} 
  {{displayemp.basicamount}} 

  
   {% endfor %}
   

  
 {% csrf_token %}


  
ID
Itemname
Quantity

userquantity
amount
  


  
  {{editupdaterecord.id}}
  {{editupdaterecord.Itemname}}
  {{editupdaterecord.quantity}} 
{{editupdaterecord.yourquantity}} 
 {{editupdaterecord.youramount}} 

  

   {% csrf_token %}
  
   {{displayemp.amount2}} 
  
   {% endfor %}


   


Add






On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER 
wrote:

> First of all please remove the for loop from your form.
> secondly please add{{displayemp.userquantity_field}}
>   {{displayemp.amount_field}} 
>
> On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> view.py
>> def displaydata(request):
>>results = editupdaterecord.objects.all()
>>
>>
>>if request.method=='POST':
>>  if request.POST.get('userquantity')  :
>>  quantity = request.POST.get('userquantity')
>>  a = editupdaterecord.objects.all()
>>  print(a)
>>#  if results in a < quantity:
>>  saverecord = editupdaterecord(userquantity = quantity)
>>  saverecord.save()
>>
>>return render(request , 'index.html' ,{"editupdaterecord":results})
>>
>>
>> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> my index.html is
>>>
>>> 
>>> 
>>>  Edit 
>>> 
>>> .button {
>>>   border: none;
>>>   color: black;
>>>   padding: 15px 32px;
>>>   text-align: center;
>>>   text-decoration: none;
>>>   display: inline-block;
>>>   font-size: 16px;
>>>   margin: 4px 2px;
>>>   cursor: pointer;
>>>
>>> }
>>>
>>> .button2 {background-color: #008CBA;}
>>>
>>> 
>>>
>>>
>>> 
>>> 
>>>
>>>
>>> 
>>>  
>>> 
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>>  rate
>>>   amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>{{displayemp.rate}} 
>>>   {{displayemp.basicamount}} 
>>>
>>>   
>>>{% endfor %}
>>>
>>>
>>>   
>>>  {% csrf_token %}
>>>
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>> userquantity
>>> amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>
>>>
>>>   
>>>
>>>{% csrf_token %}
>>>   
>>>{{displayemp.amount2}} 
>>>   
>>>{% endfor %}
>>>
>>>
>>>
>>> 
>>>
>>> Add
>>>
>>>
>>> 
>>> 
>>> 
>>>
>>>
>>>
>>>
>>> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 Hello sir,
 I'm trying to insert the data in the table. For example in database
 Itemname quantity price user-quantity amount
 pen20  5   00
 book  20 10  00

 in my database I'm getting this result
 pen20  5   00
 book  20 10  00
  20

 I want to take the itemname, quantity, and price in the last row as
 well.
 In my html front view (screenshot 50) only the last text box is active
 in the user quantity column.

 please help me.
 thank you



 On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> according to your code, you're trying to update the product record.
> right?
> If so, then you're doing things the right way.
>
> On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> hello , sir your mobile no. is not on whatsapp. please a

Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER
is your code working now?

On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER 
wrote:

> First of all please remove the for loop from your form.
> secondly please add{{displayemp.userquantity_field}}
>   {{displayemp.amount_field}} 
>
> On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> view.py
>> def displaydata(request):
>>results = editupdaterecord.objects.all()
>>
>>
>>if request.method=='POST':
>>  if request.POST.get('userquantity')  :
>>  quantity = request.POST.get('userquantity')
>>  a = editupdaterecord.objects.all()
>>  print(a)
>>#  if results in a < quantity:
>>  saverecord = editupdaterecord(userquantity = quantity)
>>  saverecord.save()
>>
>>return render(request , 'index.html' ,{"editupdaterecord":results})
>>
>>
>> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> my index.html is
>>>
>>> 
>>> 
>>>  Edit 
>>> 
>>> .button {
>>>   border: none;
>>>   color: black;
>>>   padding: 15px 32px;
>>>   text-align: center;
>>>   text-decoration: none;
>>>   display: inline-block;
>>>   font-size: 16px;
>>>   margin: 4px 2px;
>>>   cursor: pointer;
>>>
>>> }
>>>
>>> .button2 {background-color: #008CBA;}
>>>
>>> 
>>>
>>>
>>> 
>>> 
>>>
>>>
>>> 
>>>  
>>> 
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>>  rate
>>>   amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>{{displayemp.rate}} 
>>>   {{displayemp.basicamount}} 
>>>
>>>   
>>>{% endfor %}
>>>
>>>
>>>   
>>>  {% csrf_token %}
>>>
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>> userquantity
>>> amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>
>>>
>>>   
>>>
>>>{% csrf_token %}
>>>   
>>>{{displayemp.amount2}} 
>>>   
>>>{% endfor %}
>>>
>>>
>>>
>>> 
>>>
>>> Add
>>>
>>>
>>> 
>>> 
>>> 
>>>
>>>
>>>
>>>
>>> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 Hello sir,
 I'm trying to insert the data in the table. For example in database
 Itemname quantity price user-quantity amount
 pen20  5   00
 book  20 10  00

 in my database I'm getting this result
 pen20  5   00
 book  20 10  00
  20

 I want to take the itemname, quantity, and price in the last row as
 well.
 In my html front view (screenshot 50) only the last text box is active
 in the user quantity column.

 please help me.
 thank you



 On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> according to your code, you're trying to update the product record.
> right?
> If so, then you're doing things the right way.
>
> On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> hello , sir your mobile no. is not on whatsapp. please assist me
>> with  this
>>
>> On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
>> onyemordidan...@gmail.com> wrote:
>>
>>> Hello, have your problem been solved if no kindly contact me on
>>> WhatsApp 08167997730 to assist you better.
>>>
>>> On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 https://github.com/Mayanksandikar/3-database


 On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins 
 wrote:

> Post your code on github and provide the link here
>
> Em sábado, 19 de junho de 2021 às 22:00:24 UTC-3,
> mayanksand...@gmail.com escreveu:
>
>> I have a few errors in my program.
>> 1. HTML
>> In my front view only my last text box is working and all the
>> upper text boxes are unassessable.
>> 2. Database
>> I am getting only the user quantity in the database but not
>> getting the itemname, price and total amount in it.
>>
>> I don't know where it is going wrong, I've been stuck here for
>> the last 4 days. I'm a beginner in django and pyth

Re: Help me Please - Django and python program

2021-06-22 Thread mayank sandikar
Thank you sir, the html problem is solved, but I don't know how to insert
itemname, quantity and rate in the database

On Tue, Jun 22, 2021 at 4:15 PM DJANGO DEVELOPER 
wrote:

> is your code working now?
>
> On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER 
> wrote:
>
>> First of all please remove the for loop from your form.
>> secondly please add{{displayemp.userquantity_field}}
>>   {{displayemp.amount_field}} 
>>
>> On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> view.py
>>> def displaydata(request):
>>>results = editupdaterecord.objects.all()
>>>
>>>
>>>if request.method=='POST':
>>>  if request.POST.get('userquantity')  :
>>>  quantity = request.POST.get('userquantity')
>>>  a = editupdaterecord.objects.all()
>>>  print(a)
>>>#  if results in a < quantity:
>>>  saverecord = editupdaterecord(userquantity = quantity)
>>>  saverecord.save()
>>>
>>>return render(request , 'index.html' ,{"editupdaterecord":results})
>>>
>>>
>>> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 my index.html is

 
 
  Edit 
 
 .button {
   border: none;
   color: black;
   padding: 15px 32px;
   text-align: center;
   text-decoration: none;
   display: inline-block;
   font-size: 16px;
   margin: 4px 2px;
   cursor: pointer;

 }

 .button2 {background-color: #008CBA;}

 


 
 


 
  
 
 
   
 ID
 Itemname
 Quantity

  rate
   amount
   

   {% for displayemp in editupdaterecord%}
   
   {{displayemp.id}}
   {{displayemp.Itemname}}
   {{displayemp.quantity}} 
{{displayemp.rate}} 
   {{displayemp.basicamount}} 

   
{% endfor %}


   
  {% csrf_token %}

 
   
 ID
 Itemname
 Quantity

 userquantity
 amount
   

   {% for displayemp in editupdaterecord%}
   
   {{displayemp.id}}
   {{displayemp.Itemname}}
   {{displayemp.quantity}} 


   

{% csrf_token %}
   >>> "{{editupdaterecord.userquantity}}"   >
{{displayemp.amount2}} 
   
{% endfor %}



 

 Add


 
 
 




 On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> Hello sir,
> I'm trying to insert the data in the table. For example in database
> Itemname quantity price user-quantity amount
> pen20  5   00
> book  20 10  00
>
> in my database I'm getting this result
> pen20  5   00
> book  20 10  00
>  20
>
> I want to take the itemname, quantity, and price in the last row as
> well.
> In my html front view (screenshot 50) only the last text box is active
> in the user quantity column.
>
> please help me.
> thank you
>
>
>
> On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER <
> abubakarbr...@gmail.com> wrote:
>
>> according to your code, you're trying to update the product record.
>> right?
>> If so, then you're doing things the right way.
>>
>> On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> hello , sir your mobile no. is not on whatsapp. please assist me
>>> with  this
>>>
>>> On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
>>> onyemordidan...@gmail.com> wrote:
>>>
 Hello, have your problem been solved if no kindly contact me on
 WhatsApp 08167997730 to assist you better.

 On Mon, 21 Jun 2021, 07:07 mayank sandikar, <
 mayanksandikar191...@gmail.com> wrote:

> https://github.com/Mayanksandikar/3-database
>
>
> On Sun, Jun 20, 2021 at 4:08 PM Luciano Martins <
> zicad...@gmail.com> wrote:
>
>> Post your code on github and provide the link here
>>
>> Em sábado, 19 de junho de 2021 às 22:00:24 UTC-3,
>> mayanksand...@gmail.com escreveu:
>>
>>> I have a few errors in my program.
>>> 

Deploy Django app using cpanel

2021-06-22 Thread Eugene TUYIZERE
Dear Team,

I have an issue. I want to make my app productive. I bought a domain and I
got cpanel credentials. The problem I have now is that I do not know how I
can configure the app in cpanel so that users can start browsing it. I
tried to connect to the database and I loaded the application files. Is
there someone who can tell me all the steps I need to follow to make the
app accessible? for what I have done, I am getting this error message when
browsing:
[image: image.png]

Please assist

-- 
*Eugene*

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABxpZHtN_e%2BknbqEBqwR94fj4VpaTq__%3DombaKZtQ5hqSH1Aew%40mail.gmail.com.


Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER
def insetdata(request):
product_form = your_product_form()
if request.method == 'POST':
product_form = your_product_form(request.POST, request.FILES)
if product_form.is_valid:
product_form.save()
return redirect('put your product's url name value here')
return render(request, 'your template path here',
{'product':product_form})

On Tue, Jun 22, 2021 at 3:59 PM mayank sandikar <
mayanksandikar191...@gmail.com> wrote:

> Thank you sir, the html problem is solved, but I don't know how to insert
> itemname, quantity and rate in the database
>
> On Tue, Jun 22, 2021 at 4:15 PM DJANGO DEVELOPER 
> wrote:
>
>> is your code working now?
>>
>> On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> First of all please remove the for loop from your form.
>>> secondly please add{{displayemp.userquantity_field}}
>>>   {{displayemp.amount_field}} 
>>>
>>> On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 view.py
 def displaydata(request):
results = editupdaterecord.objects.all()


if request.method=='POST':
  if request.POST.get('userquantity')  :
  quantity = request.POST.get('userquantity')
  a = editupdaterecord.objects.all()
  print(a)
#  if results in a < quantity:
  saverecord = editupdaterecord(userquantity = quantity)
  saverecord.save()

return render(request , 'index.html' ,{"editupdaterecord":results})


 On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> my index.html is
>
> 
> 
>  Edit 
> 
> .button {
>   border: none;
>   color: black;
>   padding: 15px 32px;
>   text-align: center;
>   text-decoration: none;
>   display: inline-block;
>   font-size: 16px;
>   margin: 4px 2px;
>   cursor: pointer;
>
> }
>
> .button2 {background-color: #008CBA;}
>
> 
>
>
> 
> 
>
>
> 
>  
> 
> 
>   
> ID
> Itemname
> Quantity
>
>  rate
>   amount
>   
>
>   {% for displayemp in editupdaterecord%}
>   
>   {{displayemp.id}}
>   {{displayemp.Itemname}}
>   {{displayemp.quantity}} 
>{{displayemp.rate}} 
>   {{displayemp.basicamount}} 
>
>   
>{% endfor %}
>
>
>   
>  {% csrf_token %}
>
> 
>   
> ID
> Itemname
> Quantity
>
> userquantity
> amount
>   
>
>   {% for displayemp in editupdaterecord%}
>   
>   {{displayemp.id}}
>   {{displayemp.Itemname}}
>   {{displayemp.quantity}} 
>
>
>   
>
>{% csrf_token %}
>    ="{{editupdaterecord.userquantity}}"   >
>{{displayemp.amount2}} 
>   
>{% endfor %}
>
>
>
> 
>
> Add
>
>
> 
> 
> 
>
>
>
>
> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> Hello sir,
>> I'm trying to insert the data in the table. For example in database
>> Itemname quantity price user-quantity amount
>> pen20  5   00
>> book  20 10  00
>>
>> in my database I'm getting this result
>> pen20  5   00
>> book  20 10  00
>>  20
>>
>> I want to take the itemname, quantity, and price in the last row as
>> well.
>> In my html front view (screenshot 50) only the last text box is
>> active in the user quantity column.
>>
>> please help me.
>> thank you
>>
>>
>>
>> On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER <
>> abubakarbr...@gmail.com> wrote:
>>
>>> according to your code, you're trying to update the product record.
>>> right?
>>> If so, then you're doing things the right way.
>>>
>>> On Tue, Jun 22, 2021 at 9:50 AM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 hello , sir your mobile no. is not on whatsapp. please assist me
 with  this

 On Mon, Jun 21, 2021 at 10:09 PM Onyemordi Daniel <
 onyemordidan...@gmail.com> wrote:

> Hello, have you

Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER
follow this code's pattern but remember one thing that you have to follow
it according to your needs.

On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER 
wrote:

> def insetdata(request):
> product_form = your_product_form()
> if request.method == 'POST':
> product_form = your_product_form(request.POST, request.FILES)
> if product_form.is_valid:
> product_form.save()
> return redirect('put your product's url name value here')
> return render(request, 'your template path here',
> {'product':product_form})
>
> On Tue, Jun 22, 2021 at 3:59 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> Thank you sir, the html problem is solved, but I don't know how to insert
>> itemname, quantity and rate in the database
>>
>> On Tue, Jun 22, 2021 at 4:15 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> is your code working now?
>>>
>>> On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 First of all please remove the for loop from your form.
 secondly please add{{displayemp.userquantity_field}}
   {{displayemp.amount_field}} 

 On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> view.py
> def displaydata(request):
>results = editupdaterecord.objects.all()
>
>
>if request.method=='POST':
>  if request.POST.get('userquantity')  :
>  quantity = request.POST.get('userquantity')
>  a = editupdaterecord.objects.all()
>  print(a)
>#  if results in a < quantity:
>  saverecord = editupdaterecord(userquantity = quantity)
>  saverecord.save()
>
>return render(request , 'index.html' ,{"editupdaterecord":results})
>
>
> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> my index.html is
>>
>> 
>> 
>>  Edit 
>> 
>> .button {
>>   border: none;
>>   color: black;
>>   padding: 15px 32px;
>>   text-align: center;
>>   text-decoration: none;
>>   display: inline-block;
>>   font-size: 16px;
>>   margin: 4px 2px;
>>   cursor: pointer;
>>
>> }
>>
>> .button2 {background-color: #008CBA;}
>>
>> 
>>
>>
>> 
>> 
>>
>>
>> 
>>  
>> 
>> 
>>   
>> ID
>> Itemname
>> Quantity
>>
>>  rate
>>   amount
>>   
>>
>>   {% for displayemp in editupdaterecord%}
>>   
>>   {{displayemp.id}}
>>   {{displayemp.Itemname}}
>>   {{displayemp.quantity}} 
>>{{displayemp.rate}} 
>>   {{displayemp.basicamount}} 
>>
>>   
>>{% endfor %}
>>
>>
>>   
>>  {% csrf_token %}
>>
>> 
>>   
>> ID
>> Itemname
>> Quantity
>>
>> userquantity
>> amount
>>   
>>
>>   {% for displayemp in editupdaterecord%}
>>   
>>   {{displayemp.id}}
>>   {{displayemp.Itemname}}
>>   {{displayemp.quantity}} 
>>
>>
>>   
>>
>>{% csrf_token %}
>>   > value="{{editupdaterecord.userquantity}}"   >
>>{{displayemp.amount2}} 
>>   
>>{% endfor %}
>>
>>
>>
>> 
>>
>> Add
>>
>>
>> 
>> 
>> 
>>
>>
>>
>>
>> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> Hello sir,
>>> I'm trying to insert the data in the table. For example in database
>>> Itemname quantity price user-quantity amount
>>> pen20  5   00
>>> book  20 10  00
>>>
>>> in my database I'm getting this result
>>> pen20  5   00
>>> book  20 10  00
>>>  20
>>>
>>> I want to take the itemname, quantity, and price in the last row as
>>> well.
>>> In my html front view (screenshot 50) only the last text box is
>>> active in the user quantity column.
>>>
>>> please help me.
>>> thank you
>>>
>>>
>>>
>>> On Tue, Jun 22, 2021 at 2:58 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 according to your code, you're trying to update the product record.
 right?
 If so, then you're doing thin

Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER
request.FILES used when we need to insert images as well. if there is no
image field then remove the request.FILES.

On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER 
wrote:

> follow this code's pattern but remember one thing that you have to follow
> it according to your needs.
>
> On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER 
> wrote:
>
>> def insetdata(request):
>> product_form = your_product_form()
>> if request.method == 'POST':
>> product_form = your_product_form(request.POST, request.FILES)
>> if product_form.is_valid:
>> product_form.save()
>> return redirect('put your product's url name value here')
>> return render(request, 'your template path here',
>> {'product':product_form})
>>
>> On Tue, Jun 22, 2021 at 3:59 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> Thank you sir, the html problem is solved, but I don't know how to
>>> insert itemname, quantity and rate in the database
>>>
>>> On Tue, Jun 22, 2021 at 4:15 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 is your code working now?

 On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> First of all please remove the for loop from your form.
> secondly please add{{displayemp.userquantity_field}}
>   {{displayemp.amount_field}} 
>
> On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> view.py
>> def displaydata(request):
>>results = editupdaterecord.objects.all()
>>
>>
>>if request.method=='POST':
>>  if request.POST.get('userquantity')  :
>>  quantity = request.POST.get('userquantity')
>>  a = editupdaterecord.objects.all()
>>  print(a)
>>#  if results in a < quantity:
>>  saverecord = editupdaterecord(userquantity = quantity)
>>  saverecord.save()
>>
>>return render(request , 'index.html' ,{"editupdaterecord"
>> :results})
>>
>>
>> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> my index.html is
>>>
>>> 
>>> 
>>>  Edit 
>>> 
>>> .button {
>>>   border: none;
>>>   color: black;
>>>   padding: 15px 32px;
>>>   text-align: center;
>>>   text-decoration: none;
>>>   display: inline-block;
>>>   font-size: 16px;
>>>   margin: 4px 2px;
>>>   cursor: pointer;
>>>
>>> }
>>>
>>> .button2 {background-color: #008CBA;}
>>>
>>> 
>>>
>>>
>>> 
>>> 
>>>
>>>
>>> 
>>>  
>>> 
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>>  rate
>>>   amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>{{displayemp.rate}} 
>>>   {{displayemp.basicamount}} 
>>>
>>>   
>>>{% endfor %}
>>>
>>>
>>>   
>>>  {% csrf_token %}
>>>
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>> userquantity
>>> amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>
>>>
>>>   
>>>
>>>{% csrf_token %}
>>>   >> value="{{editupdaterecord.userquantity}}"   >
>>>{{displayemp.amount2}} 
>>>   
>>>{% endfor %}
>>>
>>>
>>>
>>> 
>>>
>>> Add
>>>
>>>
>>> 
>>> 
>>> 
>>>
>>>
>>>
>>>
>>> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 Hello sir,
 I'm trying to insert the data in the table. For example in database
 Itemname quantity price user-quantity amount
 pen20  5   00
 book  20 10  00

 in my database I'm getting this result
 pen20  5   00
 book  20 10  00
  20

 I want to take the itemname, quantity, and price in the last row as
 well.
 In my html front view (screenshot 50)

Re: Django Admin: object history not working

2021-06-22 Thread Christian Ledermann
I am not sure what you are asking about.
The history works out of the box, but only when you manipulate entries via
the django admin.
When you change the model instance through your own views, you have to
explicitly create the log entry.

On Tue, 22 Jun 2021 at 00:48, Ryan Kite  wrote:

> Hello,
>
> The issue is when clicking the "History" button on an object from the
> Django admin site, it opens to the template but says "*This object
> doesn't have a change history. It probably wasn't added via this admin
> site."*
>
> From reading the docs it appears that: *history_view*() already exists
> (which is what I want)
>
> /// from the doc page:
> ModelAdmin.history_view(*request*, *object_id*, *extra_context=None*)
> [source]
> 
> ¶
> 
>
>  Django view for the page that shows the modification history for a
> given model instance.
>
> ///
>
> We can see the change history when doing:
>
>  python manage.shell
>
> import django.contrib.admin.models import LogEntry
> from django.contrib.contenttypes.models import ContentType
> from app import MyModel
>
>  results =
> LogEntry.objects.filter(content_type=ContentType.objects.get_for_model(MyModel
> ))
>
> print(vars(results[1]))
>
> .. shows the change details
>
> Please tell me what I'm missing or need to add.
>
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f59bfb29-c5be-459b-a984-ff1492150f92n%40googlegroups.com
> 
> .
>


-- 
Best Regards,

Christian Ledermann

Dublin, IE
Mobile : +353 (0) 899748838

https://www.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABCjzWrJZfk%2BTw0yDovv%3DKYu1SiLe3wrk%3DkS-YG%3DeUnpMhbByQ%40mail.gmail.com.


Re: Help me - Django and python

2021-06-22 Thread avdesh sharma
what will happen if I change from elif to else ?
FYI - I checked it but still getting same error.

On Tue, Jun 22, 2021 at 2:51 PM DJANGO DEVELOPER 
wrote:

> your index.html
>
> 
> PASSWORD
>  class="form-control" name="password" placeholder="Enter Password">
> 
> 
> {% if login == 'inactive' %}
> User Inactive! Contact 
> Admin!
> {% elif login == 'invalid' %}
> line 32 username or password 
> Invalid
> {% endif%}
> {% if tab_error == True %}
> Invalid Tab Selected
> {% endif %}
>
>
>
> changed index.html
>
> 
> PASSWORD
>  class="form-control" name="password" placeholder="Enter Password" 
> value="{{login.password_field}}">
> 
> 
> {% if login == 'inactive' %}
> User Inactive! Contact 
> Admin!
> {% else %}
> line 32 username or password 
> Invalid
> {% endif%}
> {% if tab_error == True %}
> Invalid Tab Selected
> {% endif %}
>
>
> On Tue, Jun 22, 2021 at 2:16 PM DJANGO DEVELOPER 
> wrote:
>
>> by seeing your code, it seems that only the 'else' part is working. have
>> you provided value='{{dict_key.model_password_field}} in your html input
>> element?
>>
>> On Tue, Jun 22, 2021 at 12:52 PM avdesh sharma 
>> wrote:
>>
>>> Here is my View.py code
>>>
>>> from django.shortcuts import render
>>> from django.http import HttpResponseRedirect
>>> from django.urls import reverse
>>> from django.contrib.auth import authenticate, logout, login
>>> from django.contrib.auth.decorators import login_required
>>> from student.models import *
>>> from django.views.generic import TemplateView
>>> import datetime, random
>>> from django.contrib.auth.backends import BaseBackend
>>> # Create your views here.
>>>
>>>
>>> def index_view(request):
>>> if request.method == 'POST':
>>> username = request.POST.get('username')
>>> password = request.POST.get('password')
>>> tab_selected = request.POST.get('tab_selected')
>>>
>>> user = authenticate(username=username, password=password)
>>> print(user)
>>> if user:
>>> # if get_user(username):
>>> if user.is_active:
>>> login(request, user)
>>> request.session['username'] = username
>>> request.session['tab_selected'] = tab_selected
>>> if tab_selected == 'student_tab':
>>> return 
>>> HttpResponseRedirect(reverse('student:stud_home'))
>>> elif tab_selected == 'dept_tab':
>>> if username[:3] == 'hod':
>>> return 
>>> HttpResponseRedirect(reverse('student:hod_home'))
>>> else:
>>> return 
>>> HttpResponseRedirect(reverse('student:dep_home'))
>>> elif tab_selected == 'office_tab':
>>> return HttpResponseRedirect(reverse('student:off_home'))
>>> else:
>>> user_login = 'inactive'
>>> return render(request, 'student/index.html', 
>>> context={'login': user_login})
>>> else:
>>> user_login = 'invalid'
>>> return render(request, 'student/index.html', context={'login': 
>>> user_login})
>>> else:
>>> return render(request, 'student/index.html', context={})
>>>
>>>
>>> index.html
>>>
>>> 
>>> PASSWORD
>>> >> class="form-control" name="password" placeholder="Enter Password">
>>> 
>>> 
>>> {% if login == 'inactive' %}
>>> User Inactive! Contact 
>>> Admin!
>>> {% elif login == 'invalid' %}
>>> line 32 username or password 
>>> Invalid
>>> {% endif%}
>>> {% if tab_error == True %}
>>> Invalid Tab Selected
>>> {% endif %}
>>> 
>>>
>>>
>>> On Tue, Jun 22, 2021 at 11:55 AM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 can you please share your login view code?

 On Tue, Jun 22, 2021 at 10:12 AM avdesh sharma <
 avdeshsharma...@gmail.com> wrote:

> Hi All,
>
> I have an issue coming in my django code, even though the user id and
> password is present in sqlite3 db still  the user is giving '*None'*
> value
> user = authenticate(username=username, password=password)
>
> and I am not able to login with user and throwing this error.
>
> [image: image.png]
>
>
>
>
> --
> Warm Regards,
> Avdesh Kumar Sharma
> 9650031844
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAF5Nfo65s-8c75FRkhF0rN7Sh0aUH6eKNBbQ--OMawNPCVX13w%40mail.gmail.com
> 
> .
>
 --
 You received this message because you

Re: Help me - Django and python

2021-06-22 Thread DJANGO DEVELOPER
because it is necessary to write when there are no more conditions left.

On Tue, Jun 22, 2021 at 6:31 PM avdesh sharma 
wrote:

> what will happen if I change from elif to else ?
> FYI - I checked it but still getting same error.
>
> On Tue, Jun 22, 2021 at 2:51 PM DJANGO DEVELOPER 
> wrote:
>
>> your index.html
>>
>> 
>> PASSWORD
>> > class="form-control" name="password" placeholder="Enter Password">
>> 
>> 
>> {% if login == 'inactive' %}
>> User Inactive! Contact 
>> Admin!
>> {% elif login == 'invalid' %}
>> line 32 username or password 
>> Invalid
>> {% endif%}
>> {% if tab_error == True %}
>> Invalid Tab Selected
>> {% endif %}
>>
>>
>>
>> changed index.html
>>
>> 
>> PASSWORD
>> > class="form-control" name="password" placeholder="Enter Password" 
>> value="{{login.password_field}}">
>> 
>> 
>> {% if login == 'inactive' %}
>> User Inactive! Contact 
>> Admin!
>> {% else %}
>> line 32 username or password 
>> Invalid
>> {% endif%}
>> {% if tab_error == True %}
>> Invalid Tab Selected
>> {% endif %}
>>
>>
>> On Tue, Jun 22, 2021 at 2:16 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> by seeing your code, it seems that only the 'else' part is working. have
>>> you provided value='{{dict_key.model_password_field}} in your html input
>>> element?
>>>
>>> On Tue, Jun 22, 2021 at 12:52 PM avdesh sharma <
>>> avdeshsharma...@gmail.com> wrote:
>>>
 Here is my View.py code

 from django.shortcuts import render
 from django.http import HttpResponseRedirect
 from django.urls import reverse
 from django.contrib.auth import authenticate, logout, login
 from django.contrib.auth.decorators import login_required
 from student.models import *
 from django.views.generic import TemplateView
 import datetime, random
 from django.contrib.auth.backends import BaseBackend
 # Create your views here.


 def index_view(request):
 if request.method == 'POST':
 username = request.POST.get('username')
 password = request.POST.get('password')
 tab_selected = request.POST.get('tab_selected')

 user = authenticate(username=username, password=password)
 print(user)
 if user:
 # if get_user(username):
 if user.is_active:
 login(request, user)
 request.session['username'] = username
 request.session['tab_selected'] = tab_selected
 if tab_selected == 'student_tab':
 return 
 HttpResponseRedirect(reverse('student:stud_home'))
 elif tab_selected == 'dept_tab':
 if username[:3] == 'hod':
 return 
 HttpResponseRedirect(reverse('student:hod_home'))
 else:
 return 
 HttpResponseRedirect(reverse('student:dep_home'))
 elif tab_selected == 'office_tab':
 return 
 HttpResponseRedirect(reverse('student:off_home'))
 else:
 user_login = 'inactive'
 return render(request, 'student/index.html', 
 context={'login': user_login})
 else:
 user_login = 'invalid'
 return render(request, 'student/index.html', context={'login': 
 user_login})
 else:
 return render(request, 'student/index.html', context={})


 index.html

 
 PASSWORD
 >>> class="form-control" name="password" placeholder="Enter Password">
 
 
 {% if login == 'inactive' %}
 User Inactive! Contact 
 Admin!
 {% elif login == 'invalid' %}
 line 32 username or password 
 Invalid
 {% endif%}
 {% if tab_error == True %}
 Invalid Tab Selected
 {% endif %}
 


 On Tue, Jun 22, 2021 at 11:55 AM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> can you please share your login view code?
>
> On Tue, Jun 22, 2021 at 10:12 AM avdesh sharma <
> avdeshsharma...@gmail.com> wrote:
>
>> Hi All,
>>
>> I have an issue coming in my django code, even though the user id and
>> password is present in sqlite3 db still  the user is giving '*None'*
>> value
>> user = authenticate(username=username, password=password)
>>
>> and I am not able to login with user and throwing this error.
>>
>> [image: image.png]
>>
>>
>>
>>
>> --
>> Warm Regards,
>> Avdesh Kumar Sharma
>> 9650031844
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https:/

Re: Help me - Django and python

2021-06-22 Thread DJANGO DEVELOPER
have you removed for loop from your form?

On Tue, Jun 22, 2021 at 8:33 PM DJANGO DEVELOPER 
wrote:

> because it is necessary to write when there are no more conditions left.
>
> On Tue, Jun 22, 2021 at 6:31 PM avdesh sharma 
> wrote:
>
>> what will happen if I change from elif to else ?
>> FYI - I checked it but still getting same error.
>>
>> On Tue, Jun 22, 2021 at 2:51 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> your index.html
>>>
>>> 
>>> PASSWORD
>>> >> class="form-control" name="password" placeholder="Enter Password">
>>> 
>>> 
>>> {% if login == 'inactive' %}
>>> User Inactive! Contact 
>>> Admin!
>>> {% elif login == 'invalid' %}
>>> line 32 username or password 
>>> Invalid
>>> {% endif%}
>>> {% if tab_error == True %}
>>> Invalid Tab Selected
>>> {% endif %}
>>>
>>>
>>>
>>> changed index.html
>>>
>>> 
>>> PASSWORD
>>> >> class="form-control" name="password" placeholder="Enter Password" 
>>> value="{{login.password_field}}">
>>> 
>>> 
>>> {% if login == 'inactive' %}
>>> User Inactive! Contact 
>>> Admin!
>>> {% else %}
>>> line 32 username or password 
>>> Invalid
>>> {% endif%}
>>> {% if tab_error == True %}
>>> Invalid Tab Selected
>>> {% endif %}
>>>
>>>
>>> On Tue, Jun 22, 2021 at 2:16 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 by seeing your code, it seems that only the 'else' part is working.
 have you provided value='{{dict_key.model_password_field}} in your html
 input element?

 On Tue, Jun 22, 2021 at 12:52 PM avdesh sharma <
 avdeshsharma...@gmail.com> wrote:

> Here is my View.py code
>
> from django.shortcuts import render
> from django.http import HttpResponseRedirect
> from django.urls import reverse
> from django.contrib.auth import authenticate, logout, login
> from django.contrib.auth.decorators import login_required
> from student.models import *
> from django.views.generic import TemplateView
> import datetime, random
> from django.contrib.auth.backends import BaseBackend
> # Create your views here.
>
>
> def index_view(request):
> if request.method == 'POST':
> username = request.POST.get('username')
> password = request.POST.get('password')
> tab_selected = request.POST.get('tab_selected')
>
> user = authenticate(username=username, password=password)
> print(user)
> if user:
> # if get_user(username):
> if user.is_active:
> login(request, user)
> request.session['username'] = username
> request.session['tab_selected'] = tab_selected
> if tab_selected == 'student_tab':
> return 
> HttpResponseRedirect(reverse('student:stud_home'))
> elif tab_selected == 'dept_tab':
> if username[:3] == 'hod':
> return 
> HttpResponseRedirect(reverse('student:hod_home'))
> else:
> return 
> HttpResponseRedirect(reverse('student:dep_home'))
> elif tab_selected == 'office_tab':
> return 
> HttpResponseRedirect(reverse('student:off_home'))
> else:
> user_login = 'inactive'
> return render(request, 'student/index.html', 
> context={'login': user_login})
> else:
> user_login = 'invalid'
> return render(request, 'student/index.html', 
> context={'login': user_login})
> else:
> return render(request, 'student/index.html', context={})
>
>
> index.html
>
> 
>  style="color:black;">PASSWORD
>  class="form-control" name="password" placeholder="Enter Password">
> 
> 
> {% if login == 'inactive' %}
> User Inactive! Contact 
> Admin!
> {% elif login == 'invalid' %}
> line 32 username or password 
> Invalid
> {% endif%}
> {% if tab_error == True %}
> Invalid Tab Selected
> {% endif %}
> 
>
>
> On Tue, Jun 22, 2021 at 11:55 AM DJANGO DEVELOPER <
> abubakarbr...@gmail.com> wrote:
>
>> can you please share your login view code?
>>
>> On Tue, Jun 22, 2021 at 10:12 AM avdesh sharma <
>> avdeshsharma...@gmail.com> wrote:
>>
>>> Hi All,
>>>
>>> I have an issue coming in my django code, even though the user id
>>> and password is present in sqlite3 db still  the user is giving '
>>> *None'* value
>>> user = authenticate(username=username, password=password)
>>>
>>> and I am not able to login with user and throwing this error.
>>>
>>> [image: image.png]
>>>
>>>
>>>
>>>
>>> --
>>> Warm Regards,
>>> Avdesh Kumar Sharma
>>> 9650031844
>>>
>

Re: Help me Please - Django and python program

2021-06-22 Thread mayank sandikar
Thank you sir, sorry for all the troubles.

On Tue, Jun 22, 2021 at 4:41 PM DJANGO DEVELOPER 
wrote:

> request.FILES used when we need to insert images as well. if there is no
> image field then remove the request.FILES.
>
> On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER 
> wrote:
>
>> follow this code's pattern but remember one thing that you have to follow
>> it according to your needs.
>>
>> On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> def insetdata(request):
>>> product_form = your_product_form()
>>> if request.method == 'POST':
>>> product_form = your_product_form(request.POST, request.FILES)
>>> if product_form.is_valid:
>>> product_form.save()
>>> return redirect('put your product's url name value here')
>>> return render(request, 'your template path here',
>>> {'product':product_form})
>>>
>>> On Tue, Jun 22, 2021 at 3:59 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 Thank you sir, the html problem is solved, but I don't know how to
 insert itemname, quantity and rate in the database

 On Tue, Jun 22, 2021 at 4:15 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> is your code working now?
>
> On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER <
> abubakarbr...@gmail.com> wrote:
>
>> First of all please remove the for loop from your form.
>> secondly please add{{displayemp.userquantity_field}}
>>   {{displayemp.amount_field}} 
>>
>> On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> view.py
>>> def displaydata(request):
>>>results = editupdaterecord.objects.all()
>>>
>>>
>>>if request.method=='POST':
>>>  if request.POST.get('userquantity')  :
>>>  quantity = request.POST.get('userquantity')
>>>  a = editupdaterecord.objects.all()
>>>  print(a)
>>>#  if results in a < quantity:
>>>  saverecord = editupdaterecord(userquantity = quantity)
>>>  saverecord.save()
>>>
>>>return render(request , 'index.html' ,{"editupdaterecord"
>>> :results})
>>>
>>>
>>> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 my index.html is

 
 
  Edit 
 
 .button {
   border: none;
   color: black;
   padding: 15px 32px;
   text-align: center;
   text-decoration: none;
   display: inline-block;
   font-size: 16px;
   margin: 4px 2px;
   cursor: pointer;

 }

 .button2 {background-color: #008CBA;}

 


 
 


 
  
 
 
   
 ID
 Itemname
 Quantity

  rate
   amount
   

   {% for displayemp in editupdaterecord%}
   
   {{displayemp.id}}
   {{displayemp.Itemname}}
   {{displayemp.quantity}} 
{{displayemp.rate}} 
   {{displayemp.basicamount}} 

   
{% endfor %}


   
  {% csrf_token %}

 
   
 ID
 Itemname
 Quantity

 userquantity
 amount
   

   {% for displayemp in editupdaterecord%}
   
   {{displayemp.id}}
   {{displayemp.Itemname}}
   {{displayemp.quantity}} 


   

{% csrf_token %}
   >>> value="{{editupdaterecord.userquantity}}"   >
{{displayemp.amount2}} 
   
{% endfor %}



 

 Add


 
 
 




 On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> Hello sir,
> I'm trying to insert the data in the table. For example in
> database
> Itemname quantity price user-quantity amount
> pen20  5   00
> book  20 10  00
>
> in my database I'm getting this result
> pen20  5   0

Re: Django Admin: object history not working

2021-06-22 Thread Ryan Kite

Thanks for the clarification, I didn't realize it only applied to changes 
administered directly from the Django Admin. 
Was interested in learning about an objects' change history, but in this 
case, the changes were not performed from the Django Admin. 


On Tuesday, June 22, 2021 at 5:50:10 AM UTC-7 christian...@gmail.com wrote:

> I am not sure what you are asking about.
> The history works out of the box, but only when you manipulate entries via 
> the django admin.
> When you change the model instance through your own views, you have to 
> explicitly create the log entry.
>
> On Tue, 22 Jun 2021 at 00:48, Ryan Kite  wrote:
>
>> Hello,
>>
>> The issue is when clicking the "History" button on an object from the 
>> Django admin site, it opens to the template but says "*This object 
>> doesn't have a change history. It probably wasn't added via this admin 
>> site."*
>>
>> From reading the docs it appears that: *history_view*() already exists 
>> (which is what I want)
>>
>> /// from the doc page: 
>> ModelAdmin.history_view(*request*, *object_id*, *extra_context=None*)
>> [source] 
>> 
>> ¶ 
>> 
>>
>>  Django view for the page that shows the modification history for a 
>> given model instance.
>>
>> ///
>>
>> We can see the change history when doing:
>>
>>  python manage.shell
>>
>> import django.contrib.admin.models import LogEntry
>> from django.contrib.contenttypes.models import ContentType
>> from app import MyModel 
>>
>>  results = 
>> LogEntry.objects.filter(content_type=ContentType.objects.get_for_model(MyModel
>>  
>> ))
>>
>> print(vars(results[1])) 
>>
>> .. shows the change details
>>
>> Please tell me what I'm missing or need to add. 
>>
>>
>>
>> -- 
>> 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/f59bfb29-c5be-459b-a984-ff1492150f92n%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Best Regards,
>
> Christian Ledermann
>
> Dublin, IE
> Mobile : +353 (0) 899748838
>
> https://www.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cc8975e1-8b77-4316-92df-909eecaad98cn%40googlegroups.com.


Re: Problem to connect to database only when run "migrate"

2021-06-22 Thread Aziz Meknassi
Hi Heron,

To make sure you are talking to your database,
in your project and in your command line, type
 python manage.py shell
then import your model

If for example you have prodApp and model Product
from prodApp.models import Product
prd = Product.objects.all()
print(prd)
Please checkout ORM (
https://docs.djangoproject.com/en/3.2/topics/db/queries/ )operations, if
you can talk to the database via ORM and see the data in your database,
then everything is setup correctly and you need to look into the settings
etc

I hope this helps

Kind regards
Aziz Meknassi

On Mon, 21 Jun 2021 at 21:44, Heron  wrote:

> Yes,
>
> And its works fine with runserver, check or with apache/wscgi
>
> regards,
> _
>
> Heron
> hero...@gmail.com
> _
>
>
> Em dom., 20 de jun. de 2021 às 07:31, Luciano Martins 
> escreveu:
>
>>
>> have you configured mysql database in settings.py?
>> Em sábado, 19 de junho de 2021 às 09:19:09 UTC-3, her...@gmail.com
>> escreveu:
>>
>>> Hello,
>>>
>>> I getting problem to connect to database only when run "migrate". I'm
>>> able to use on apache/wsgi and runserver, so it's seens that connection to
>>> database is okay. Dango is running on docker.
>>>
>>> Anyone can help me ?
>>>
>>>
>>>
>>>
>>>
>>> bash-4.2# python manage.py migrate
>>> /usr/local/lib/python2.7/site-packages/jwt/utils.py:8:
>>> CryptographyDeprecationWarning: Python 2 is no longer supported by the
>>> Python core team. Support for it is now deprecated in cryptography, and
>>> will be removed in the next release.
>>>   from cryptography.hazmat.primitives.asymmetric.utils import (
>>> Traceback (most recent call last):
>>>   File "manage.py", line 46, in 
>>> execute_from_command_line(sys.argv)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>>> line 364, in execute_from_command_line
>>> utility.execute()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>>> line 356, in execute
>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>> line 283, in run_from_argv
>>> self.execute(*args, **cmd_options)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>> line 327, in execute
>>> self.check()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
>>> line 359, in check
>>> include_deployment_checks=include_deployment_checks,
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>>> line 61, in _run_checks
>>> issues = run_checks(tags=[Tags.database])
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py",
>>> line 81, in run_checks
>>> new_errors = check(app_configs=app_configs)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/core/checks/database.py",
>>> line 10, in check_database_backends
>>> issues.extend(conn.validation.check(**kwargs))
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>>> line 9, in check
>>> issues.extend(self._check_sql_mode(**kwargs))
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
>>> line 13, in _check_sql_mode
>>> with self.connection.cursor() as cursor:
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>> line 254, in cursor
>>> return self._cursor()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>> line 229, in _cursor
>>> self.ensure_connection()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>> line 213, in ensure_connection
>>> self.connect()
>>>   File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line
>>> 94, in __exit__
>>> six.reraise(dj_exc_type, dj_exc_value, traceback)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>> line 213, in ensure_connection
>>> self.connect()
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
>>> line 189, in connect
>>> self.connection = self.get_new_connection(conn_params)
>>>   File
>>> "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
>>> line 274, in get_new_connection
>>> conn = Database.connect(**conn_params)
>>>   File "/usr/local/lib64/python2.7/site-packages/MySQLdb/__init__.py",
>>> line 81, in Connect
>>> return Connection(*args, **kwargs)
>>>   File
>>> "/usr/local/lib64/python2.7/site-packages/MySQLdb/connections.py", line
>>> 193, in __init__
>>> super(Connection, self).__init__(*args, **kwargs2)
>>> django.db.utils.OperationalError: (2003, "Can't connect to MySQL server
>>> on '192.168.201.193' (113)")
>>> bash-4.2# python manage.py check
>>> /usr/local/lib/python2.7/site-p

How to insert into multiple tables cascading

2021-06-22 Thread David Crandell
Hello, I come from a platform where I built out forms and then manually
wrote insert statements from the form input entering all the data at once.

What I want to do is enter a customer (one table), have it populate a
master region with the same name (another table), then fill out a master
location record (another table) and then create a user from the person
profiled in the customer information (another table)

I'm trying to go to the next page which is a location form and pass the
value of the customer ID to the region form included on the same page.

  There has to be a better way to do this. I still have no idea how to
combine and enter information into multiple models from one form. The ORM
is cool but it seems so limited. I guess I just don't understand it.

class CustomerCreateView(View):
template_name = 'ohnet/customer_form.html'
form_class = CustomerForm
rform = RegionWCust

def get(self, request, *args, **kwargs):
form = self.form_class
rform = self.rform
return render(request, self.template_name, {'form': form,
'rform': rform})

def post(self, request, *args, **kwargs):
form = self.form_class(request.POST, request.FILES)
rform = self.rform(request.POST)
if form.is_valid() and rform.is_valid():
form.save()
obj = Customers.objects.latest('id')
f = rform.save(commit=False)
f.customer_id = obj
f.save()
messages.success(request, f'Customer entered successfully')
return redirect('ohnet:custlocs-new', obj)


David L. Crandell
469-585-5009
g uitard...@outlook.com
guitardave8...@gmail.com
da...@onholdwizard.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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAACv6dMBaATx9V%3D0t6qrZk2WPVtcVGCOvXwW-aHurzxGE9PB%3Dw%40mail.gmail.com.


Re: Problem to connect to database only when run "migrate"

2021-06-22 Thread Heron
Thank you Aziz


Regards,
_

Heron
hero...@gmail.com
_


Em ter., 22 de jun. de 2021 às 15:29, Aziz Meknassi 
escreveu:

> Hi Heron,
>
> To make sure you are talking to your database,
> in your project and in your command line, type
>  python manage.py shell
> then import your model
>
> If for example you have prodApp and model Product
> from prodApp.models import Product
> prd = Product.objects.all()
> print(prd)
> Please checkout ORM (
> https://docs.djangoproject.com/en/3.2/topics/db/queries/ )operations, if
> you can talk to the database via ORM and see the data in your database,
> then everything is setup correctly and you need to look into the settings
> etc
>
> I hope this helps
>
> Kind regards
> Aziz Meknassi
>
> On Mon, 21 Jun 2021 at 21:44, Heron  wrote:
>
>> Yes,
>>
>> And its works fine with runserver, check or with apache/wscgi
>>
>> regards,
>> _
>>
>> Heron
>> hero...@gmail.com
>> _
>>
>>
>> Em dom., 20 de jun. de 2021 às 07:31, Luciano Martins 
>> escreveu:
>>
>>>
>>> have you configured mysql database in settings.py?
>>> Em sábado, 19 de junho de 2021 às 09:19:09 UTC-3, her...@gmail.com
>>> escreveu:
>>>
 Hello,

 I getting problem to connect to database only when run "migrate". I'm
 able to use on apache/wsgi and runserver, so it's seens that connection to
 database is okay. Dango is running on docker.

 Anyone can help me ?





 bash-4.2# python manage.py migrate
 /usr/local/lib/python2.7/site-packages/jwt/utils.py:8:
 CryptographyDeprecationWarning: Python 2 is no longer supported by the
 Python core team. Support for it is now deprecated in cryptography, and
 will be removed in the next release.
   from cryptography.hazmat.primitives.asymmetric.utils import (
 Traceback (most recent call last):
   File "manage.py", line 46, in 
 execute_from_command_line(sys.argv)
   File
 "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 line 364, in execute_from_command_line
 utility.execute()
   File
 "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
 line 356, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
   File
 "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
 line 283, in run_from_argv
 self.execute(*args, **cmd_options)
   File
 "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
 line 327, in execute
 self.check()
   File
 "/usr/local/lib/python2.7/site-packages/django/core/management/base.py",
 line 359, in check
 include_deployment_checks=include_deployment_checks,
   File
 "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
 line 61, in _run_checks
 issues = run_checks(tags=[Tags.database])
   File
 "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py",
 line 81, in run_checks
 new_errors = check(app_configs=app_configs)
   File
 "/usr/local/lib/python2.7/site-packages/django/core/checks/database.py",
 line 10, in check_database_backends
 issues.extend(conn.validation.check(**kwargs))
   File
 "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
 line 9, in check
 issues.extend(self._check_sql_mode(**kwargs))
   File
 "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py",
 line 13, in _check_sql_mode
 with self.connection.cursor() as cursor:
   File
 "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
 line 254, in cursor
 return self._cursor()
   File
 "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
 line 229, in _cursor
 self.ensure_connection()
   File
 "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
 line 213, in ensure_connection
 self.connect()
   File "/usr/local/lib/python2.7/site-packages/django/db/utils.py",
 line 94, in __exit__
 six.reraise(dj_exc_type, dj_exc_value, traceback)
   File
 "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
 line 213, in ensure_connection
 self.connect()
   File
 "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py",
 line 189, in connect
 self.connection = self.get_new_connection(conn_params)
   File
 "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py",
 line 274, in get_new_connection
 conn = Database.connect(**conn_params)
   File "/usr/local/lib64/python2.7/site-packages/MySQLdb/__init__.py",
 line 81, in Connect
 return Connection(*args, **kwargs)
   File
 "/usr/local/lib64/python2

Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER
is it resolved now? or still want some help?

On Tue, Jun 22, 2021 at 9:44 PM mayank sandikar <
mayanksandikar191...@gmail.com> wrote:

> Thank you sir, sorry for all the troubles.
>
> On Tue, Jun 22, 2021 at 4:41 PM DJANGO DEVELOPER 
> wrote:
>
>> request.FILES used when we need to insert images as well. if there is no
>> image field then remove the request.FILES.
>>
>> On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> follow this code's pattern but remember one thing that you have to
>>> follow it according to your needs.
>>>
>>> On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 def insetdata(request):
 product_form = your_product_form()
 if request.method == 'POST':
 product_form = your_product_form(request.POST, request.FILES)
 if product_form.is_valid:
 product_form.save()
 return redirect('put your product's url name value here')
 return render(request, 'your template path here',
 {'product':product_form})

 On Tue, Jun 22, 2021 at 3:59 PM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> Thank you sir, the html problem is solved, but I don't know how to
> insert itemname, quantity and rate in the database
>
> On Tue, Jun 22, 2021 at 4:15 PM DJANGO DEVELOPER <
> abubakarbr...@gmail.com> wrote:
>
>> is your code working now?
>>
>> On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER <
>> abubakarbr...@gmail.com> wrote:
>>
>>> First of all please remove the for loop from your form.
>>> secondly please add{{displayemp.userquantity_field}}
>>>   {{displayemp.amount_field}} 
>>>
>>> On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
>>> mayanksandikar191...@gmail.com> wrote:
>>>
 view.py
 def displaydata(request):
results = editupdaterecord.objects.all()


if request.method=='POST':
  if request.POST.get('userquantity')  :
  quantity = request.POST.get('userquantity')
  a = editupdaterecord.objects.all()
  print(a)
#  if results in a < quantity:
  saverecord = editupdaterecord(userquantity = quantity)
  saverecord.save()

return render(request , 'index.html' ,{"editupdaterecord"
 :results})


 On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> my index.html is
>
> 
> 
>  Edit 
> 
> .button {
>   border: none;
>   color: black;
>   padding: 15px 32px;
>   text-align: center;
>   text-decoration: none;
>   display: inline-block;
>   font-size: 16px;
>   margin: 4px 2px;
>   cursor: pointer;
>
> }
>
> .button2 {background-color: #008CBA;}
>
> 
>
>
> 
> 
>
>
> 
>  
> 
> 
>   
> ID
> Itemname
> Quantity
>
>  rate
>   amount
>   
>
>   {% for displayemp in editupdaterecord%}
>   
>   {{displayemp.id}}
>   {{displayemp.Itemname}}
>   {{displayemp.quantity}} 
>{{displayemp.rate}} 
>   {{displayemp.basicamount}} 
>
>   
>{% endfor %}
>
>
>   
>  {% csrf_token %}
>
> 
>   
> ID
> Itemname
> Quantity
>
> userquantity
> amount
>   
>
>   {% for displayemp in editupdaterecord%}
>   
>   {{displayemp.id}}
>   {{displayemp.Itemname}}
>   {{displayemp.quantity}} 
>
>
>   
>
>{% csrf_token %}
>    value="{{editupdaterecord.userquantity}}"   >
>{{displayemp.amount2}} 
>   
>{% endfor %}
>
>
>
> 
>
> Add
>
>
> 
> 
> 
>
>
>
>
> On Tue, Jun 22, 2021 at 3:49 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> Hello sir,
>> I'm trying to insert the data in the table. For example i

Re: Help me Please - Django and python program

2021-06-22 Thread DJANGO DEVELOPER
+923012876771, you can send me your queries here.

On Wed, Jun 23, 2021 at 7:39 AM DJANGO DEVELOPER 
wrote:

> is it resolved now? or still want some help?
>
> On Tue, Jun 22, 2021 at 9:44 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> Thank you sir, sorry for all the troubles.
>>
>> On Tue, Jun 22, 2021 at 4:41 PM DJANGO DEVELOPER 
>> wrote:
>>
>>> request.FILES used when we need to insert images as well. if there is no
>>> image field then remove the request.FILES.
>>>
>>> On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 follow this code's pattern but remember one thing that you have to
 follow it according to your needs.

 On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> def insetdata(request):
> product_form = your_product_form()
> if request.method == 'POST':
> product_form = your_product_form(request.POST, request.FILES)
> if product_form.is_valid:
> product_form.save()
> return redirect('put your product's url name value here')
> return render(request, 'your template path here',
> {'product':product_form})
>
> On Tue, Jun 22, 2021 at 3:59 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> Thank you sir, the html problem is solved, but I don't know how to
>> insert itemname, quantity and rate in the database
>>
>> On Tue, Jun 22, 2021 at 4:15 PM DJANGO DEVELOPER <
>> abubakarbr...@gmail.com> wrote:
>>
>>> is your code working now?
>>>
>>> On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 First of all please remove the for loop from your form.
 secondly please add{{displayemp.userquantity_field}}
   {{displayemp.amount_field}} 

 On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
 mayanksandikar191...@gmail.com> wrote:

> view.py
> def displaydata(request):
>results = editupdaterecord.objects.all()
>
>
>if request.method=='POST':
>  if request.POST.get('userquantity')  :
>  quantity = request.POST.get('userquantity')
>  a = editupdaterecord.objects.all()
>  print(a)
>#  if results in a < quantity:
>  saverecord = editupdaterecord(userquantity = quantity)
>  saverecord.save()
>
>return render(request , 'index.html' ,{"editupdaterecord"
> :results})
>
>
> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> my index.html is
>>
>> 
>> 
>>  Edit 
>> 
>> .button {
>>   border: none;
>>   color: black;
>>   padding: 15px 32px;
>>   text-align: center;
>>   text-decoration: none;
>>   display: inline-block;
>>   font-size: 16px;
>>   margin: 4px 2px;
>>   cursor: pointer;
>>
>> }
>>
>> .button2 {background-color: #008CBA;}
>>
>> 
>>
>>
>> 
>> 
>>
>>
>> 
>>  
>> 
>> 
>>   
>> ID
>> Itemname
>> Quantity
>>
>>  rate
>>   amount
>>   
>>
>>   {% for displayemp in editupdaterecord%}
>>   
>>   {{displayemp.id}}
>>   {{displayemp.Itemname}}
>>   {{displayemp.quantity}} 
>>{{displayemp.rate}} 
>>   {{displayemp.basicamount}} 
>>
>>   
>>{% endfor %}
>>
>>
>>   
>>  {% csrf_token %}
>>
>> 
>>   
>> ID
>> Itemname
>> Quantity
>>
>> userquantity
>> amount
>>   
>>
>>   {% for displayemp in editupdaterecord%}
>>   
>>   {{displayemp.id}}
>>   {{displayemp.Itemname}}
>>   {{displayemp.quantity}} 
>>
>>
>>   
>>
>>{% csrf_token %}
>>   > value="{{editupdaterecord.userquantity}}"   >
>>{{displayemp.amount2}} 
>>   
>>{% endfor %}
>>
>>
>>
>> 
>>
>> Add
>>>

Re: How to insert into multiple tables cascading

2021-06-22 Thread DJANGO DEVELOPER
please share your related models and form as well.

On Wed, Jun 23, 2021 at 1:22 AM David Crandell 
wrote:

> Hello, I come from a platform where I built out forms and then manually
> wrote insert statements from the form input entering all the data at once.
>
> What I want to do is enter a customer (one table), have it populate a
> master region with the same name (another table), then fill out a master
> location record (another table) and then create a user from the person
> profiled in the customer information (another table)
>
> I'm trying to go to the next page which is a location form and pass the
> value of the customer ID to the region form included on the same page.
>
>   There has to be a better way to do this. I still have no idea how to
> combine and enter information into multiple models from one form. The ORM
> is cool but it seems so limited. I guess I just don't understand it.
>
> class CustomerCreateView(View):
> template_name = 'ohnet/customer_form.html'
> form_class = CustomerForm
> rform = RegionWCust
>
> def get(self, request, *args, **kwargs):
> form = self.form_class
> rform = self.rform
> return render(request, self.template_name, {'form': form, 'rform': 
> rform})
>
> def post(self, request, *args, **kwargs):
> form = self.form_class(request.POST, request.FILES)
> rform = self.rform(request.POST)
> if form.is_valid() and rform.is_valid():
> form.save()
> obj = Customers.objects.latest('id')
> f = rform.save(commit=False)
> f.customer_id = obj
> f.save()
> messages.success(request, f'Customer entered successfully')
> return redirect('ohnet:custlocs-new', obj)
>
>
> David L. Crandell
> 469-585-5009
> g uitard...@outlook.com
> guitardave8...@gmail.com
> da...@onholdwizard.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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAACv6dMBaATx9V%3D0t6qrZk2WPVtcVGCOvXwW-aHurzxGE9PB%3Dw%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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKPY9p%3DSPsGj1sMuY4dutV8Gau7H0qEztgRNbKVNzLFGxiK4pw%40mail.gmail.com.


Re: Help me Please - Django and python program

2021-06-22 Thread mayank sandikar
Sure sir thank you  again

On Wed, Jun 23, 2021 at 8:10 AM DJANGO DEVELOPER 
wrote:

> +923012876771, you can send me your queries here.
>
> On Wed, Jun 23, 2021 at 7:39 AM DJANGO DEVELOPER 
> wrote:
>
>> is it resolved now? or still want some help?
>>
>> On Tue, Jun 22, 2021 at 9:44 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> Thank you sir, sorry for all the troubles.
>>>
>>> On Tue, Jun 22, 2021 at 4:41 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 request.FILES used when we need to insert images as well. if there is
 no image field then remove the request.FILES.

 On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> follow this code's pattern but remember one thing that you have to
> follow it according to your needs.
>
> On Tue, Jun 22, 2021 at 4:10 PM DJANGO DEVELOPER <
> abubakarbr...@gmail.com> wrote:
>
>> def insetdata(request):
>> product_form = your_product_form()
>> if request.method == 'POST':
>> product_form = your_product_form(request.POST, request.FILES)
>> if product_form.is_valid:
>> product_form.save()
>> return redirect('put your product's url name value here')
>> return render(request, 'your template path here',
>> {'product':product_form})
>>
>> On Tue, Jun 22, 2021 at 3:59 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> Thank you sir, the html problem is solved, but I don't know how to
>>> insert itemname, quantity and rate in the database
>>>
>>> On Tue, Jun 22, 2021 at 4:15 PM DJANGO DEVELOPER <
>>> abubakarbr...@gmail.com> wrote:
>>>
 is your code working now?

 On Tue, Jun 22, 2021 at 3:32 PM DJANGO DEVELOPER <
 abubakarbr...@gmail.com> wrote:

> First of all please remove the for loop from your form.
> secondly please add{{displayemp.userquantity_field}}
>   {{displayemp.amount_field}} 
>
> On Tue, Jun 22, 2021 at 3:27 PM mayank sandikar <
> mayanksandikar191...@gmail.com> wrote:
>
>> view.py
>> def displaydata(request):
>>results = editupdaterecord.objects.all()
>>
>>
>>if request.method=='POST':
>>  if request.POST.get('userquantity')  :
>>  quantity = request.POST.get('userquantity')
>>  a = editupdaterecord.objects.all()
>>  print(a)
>>#  if results in a < quantity:
>>  saverecord = editupdaterecord(userquantity = quantity)
>>  saverecord.save()
>>
>>return render(request , 'index.html' ,{"editupdaterecord"
>> :results})
>>
>>
>> On Tue, Jun 22, 2021 at 3:55 PM mayank sandikar <
>> mayanksandikar191...@gmail.com> wrote:
>>
>>> my index.html is
>>>
>>> 
>>> 
>>>  Edit 
>>> 
>>> .button {
>>>   border: none;
>>>   color: black;
>>>   padding: 15px 32px;
>>>   text-align: center;
>>>   text-decoration: none;
>>>   display: inline-block;
>>>   font-size: 16px;
>>>   margin: 4px 2px;
>>>   cursor: pointer;
>>>
>>> }
>>>
>>> .button2 {background-color: #008CBA;}
>>>
>>> 
>>>
>>>
>>> 
>>> 
>>>
>>>
>>> 
>>>  
>>> 
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>>  rate
>>>   amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>{{displayemp.rate}} 
>>>   {{displayemp.basicamount}} 
>>>
>>>   
>>>{% endfor %}
>>>
>>>
>>>   
>>>  {% csrf_token %}
>>>
>>> 
>>>   
>>> ID
>>> Itemname
>>> Quantity
>>>
>>> userquantity
>>> amount
>>>   
>>>
>>>   {% for displayemp in editupdaterecord%}
>>>   
>>>   {{displayemp.id}}
>>>   {{displayemp.Itemname}}
>>>   {{displayemp.quantity}} 
>>>
>>>
>>>   
>>>
>>>{% csrf_token %}
>>>  

Re: Django 3.1 Makemigrations fails with FilePathField but succeeds with CharField

2021-06-22 Thread Peter of the Norse
I think you might be better off using 
https://docs.djangoproject.com/en/3.2/topics/migrations/#squashing-migrations 
 
than having it recreate all of them.  

> On Mar 18, 2021, at 8:28 AM, Olivier  wrote:
> 
> Hello,
> 
> I've got a Django app which has over 200 migration steps.
> To shorten its test loading time, I'm trying to erase all current migrations 
> and restart from scratch.
> 
> I deteted and re-created my app Postgres database.
> I deleted all files (but __init__.py) in migrations directory.
> I typed "python manage.py makemigrations --verbosity 3".
> 
> 1. Latest makemigrations failed with:
>   File 
> "/home/perenip/venv-flexcore/lib/python3.7/site-packages/django/db/migrations/serializer.py",
>  line 339, in serializer_factory
> "topics/migrations/#migration-serializing" % (value, get_docs_version())
> ValueError: Cannot serialize: PosixPath('/var/www/vhosts/foo/vendorstatic')
> There are some values Django cannot serialize into migration files.
> For more, see 
> https://docs.djangoproject.com/en/3.1/topics/migrations/#migration-serializing
> 
> If I'm not mistaken, I couldn't read any reference to the Model/Field that 
> triggered the error.
> Should we expect an explicit mention of the faulty statement/line ?
> 
> 2. I edited a Model within models.py with:
> class Firmware(models.Model):
> #filepath = models.FilePathField(path=settings.VENDOR_STATIC_ROOT, 
> match=settings.FIRMWARE_REGEX, recursive=True)
> filepath = models.CharField(max_length=64)
> display_name = models.CharField(default='foobar', max_length=32, 
> help_text='Value as shown in HTTP User-Agent string')
> 
> def __str__(self):
> return self.relative_path()
> 
> def relative_path(self):
> return 
> str(pathlib.Path(self.filepath).relative_to(settings.VENDOR_STATIC_ROOT))
> 
> After changing from a PathFileField to a CharFiled as shown above, I could 
> successfully run makemigrations.
> 
> Doc [1] mentions Django can serialize "any Django field". Should it serialize 
> FilePathField ?
> [1] 
> https://docs.djangoproject.com/en/3.1/topics/migrations/#migration-serializing
> 
> 3. How to work around this with rewriting my app (and its tests) ?
> 
> 
> Best regards
> 
> 
> -- 
> 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+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/739e8a51-ed79-476c-9945-1076a0491b75n%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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CE1E3974-F647-4DA3-BB6E-215B31BDC373%40gmail.com.