Re: Hi, I am learning Django, I am stuck at one place and can't over come after many days

2022-01-19 Thread Leo guitar girl
I have sent you an invitation

On Wed, Jan 19, 2022 at 9:54 AM Vkash Poudel 
wrote:

> can we connect via email so that i can share my codes regarding Time basis
> OTP Generation and OTP Verification and activate user's account using pyotp.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Wed, Jan 19, 2022 at 1:20 AM Leo guitar girl <
> mansarimtabas...@gmail.com> wrote:
>
>> I have not used any library. I have done manual OTP verification by using
>> Rand library as told in the tutorial.
>>
>> On Tue, Jan 18, 2022 at 9:00 PM Vkash Poudel 
>> wrote:
>>
>>> first of what did you use to generate otp. If you've used pyotp
>>> libraries then you can verify otp in simple step and the documentation is
>>> good in pyotp.
>>>
>>> On Tue, Jan 18, 2022 at 8:35 PM Leo guitar girl <
>>> mansarimtabas...@gmail.com> wrote:
>>>
 I am following the tutorial from LearnVern.com


 https://www.learnvern.com/python-tutorial-django/project-implementation-part2

 I have followed ditto as taught in the tutorial but the trainer has no
 issue and I have this issue.

 I am sharing the views.py code also

 from django.shortcuts import render
 from .models import *
 from random import randint


 # Create your views here.

 def Index(request):
 return render(request, 'myapp/index.html')


 def SignupPage(request):
 return render(request, 'myapp/signup.html')


 def RegisterUser(request):
 if request.POST['role'] == "Candidate":
 role = request.POST['role']  # Master Table Field
 fname = request.POST['fname']  # Candidate Table Field
 lname = request.POST['lname']  # Candidate Table Field
 email = request.POST['email']  # Master Table Field
 password = request.POST['password']  # Master Table Field
 cpassword = request.POST['cpassword']

 user = UserMaster.objects.filter(email=email)

 if user:
 message = "User already Exist"
 return render(request, "myapp/signup.html", {'msg': message})
 else:
 if password == cpassword:
 otp = randint(10, 99)
 newuser = UserMaster.objects.create(role=role, otp=otp, 
 email=email, password=password)
 newcand = Candidate.objects.create(user_id=newuser, 
 firstname=fname, lastname=lname)
 return render(request, "myapp/otpverify.html", {'email': 
 email})
 else:
 print("Company Registration")


 def OTPpage(request):
 return render(request, "myapp/otpverify.html")


 def OTPverify(request):
 if request.method == 'POST':
 email = request.POST['email']
 otp = request.POST['otp']

 user = UserMaster.objects.get(email=email)

 if user:
 if user.otp == otp:
 message = "OTP Verified Successfully!"
 return render(request, "myapp/login.html", {'msg': 
 message})
 else:
 message = "OTP is incorrect"
 return render(request, "myapp/otpverify.html", {'msg': 
 message})
 else:
 return render(request, "myapp/signup.html")


 On Tue, Jan 18, 2022 at 3:21 PM Kasper Laudrup 
 wrote:

> On 18/01/2022 04.31, Leo guitar girl wrote:
> > Oh, I apologize. I had pasted the error code here don't know why it
> was
> > not sent.
> > Actually, I am trying to create a job portal by seeing a tutorial.
> Now I
> > am at the step of verifying OTP. OTP is generated successfully in
> the
> > database. But when I enter it to the textbox and submit, it shows
> this error
> >
>
> Which tutorial are you following?
>
> What's in the views.py file that is causing the error?
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/P1-fQLDoncc/unsubscribe
> .
> To unsubscribe from this group and all it

Re: Hi, I am learning Django, I am stuck at one place and can't over come after many days

2022-01-19 Thread Leo guitar girl
yeah sure

On Wed, Jan 19, 2022 at 9:54 AM Vkash Poudel 
wrote:

> can we connect via email so that i can share my codes regarding Time basis
> OTP Generation and OTP Verification and activate user's account using pyotp.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Wed, Jan 19, 2022 at 1:20 AM Leo guitar girl <
> mansarimtabas...@gmail.com> wrote:
>
>> I have not used any library. I have done manual OTP verification by using
>> Rand library as told in the tutorial.
>>
>> On Tue, Jan 18, 2022 at 9:00 PM Vkash Poudel 
>> wrote:
>>
>>> first of what did you use to generate otp. If you've used pyotp
>>> libraries then you can verify otp in simple step and the documentation is
>>> good in pyotp.
>>>
>>> On Tue, Jan 18, 2022 at 8:35 PM Leo guitar girl <
>>> mansarimtabas...@gmail.com> wrote:
>>>
 I am following the tutorial from LearnVern.com


 https://www.learnvern.com/python-tutorial-django/project-implementation-part2

 I have followed ditto as taught in the tutorial but the trainer has no
 issue and I have this issue.

 I am sharing the views.py code also

 from django.shortcuts import render
 from .models import *
 from random import randint


 # Create your views here.

 def Index(request):
 return render(request, 'myapp/index.html')


 def SignupPage(request):
 return render(request, 'myapp/signup.html')


 def RegisterUser(request):
 if request.POST['role'] == "Candidate":
 role = request.POST['role']  # Master Table Field
 fname = request.POST['fname']  # Candidate Table Field
 lname = request.POST['lname']  # Candidate Table Field
 email = request.POST['email']  # Master Table Field
 password = request.POST['password']  # Master Table Field
 cpassword = request.POST['cpassword']

 user = UserMaster.objects.filter(email=email)

 if user:
 message = "User already Exist"
 return render(request, "myapp/signup.html", {'msg': message})
 else:
 if password == cpassword:
 otp = randint(10, 99)
 newuser = UserMaster.objects.create(role=role, otp=otp, 
 email=email, password=password)
 newcand = Candidate.objects.create(user_id=newuser, 
 firstname=fname, lastname=lname)
 return render(request, "myapp/otpverify.html", {'email': 
 email})
 else:
 print("Company Registration")


 def OTPpage(request):
 return render(request, "myapp/otpverify.html")


 def OTPverify(request):
 if request.method == 'POST':
 email = request.POST['email']
 otp = request.POST['otp']

 user = UserMaster.objects.get(email=email)

 if user:
 if user.otp == otp:
 message = "OTP Verified Successfully!"
 return render(request, "myapp/login.html", {'msg': 
 message})
 else:
 message = "OTP is incorrect"
 return render(request, "myapp/otpverify.html", {'msg': 
 message})
 else:
 return render(request, "myapp/signup.html")


 On Tue, Jan 18, 2022 at 3:21 PM Kasper Laudrup 
 wrote:

> On 18/01/2022 04.31, Leo guitar girl wrote:
> > Oh, I apologize. I had pasted the error code here don't know why it
> was
> > not sent.
> > Actually, I am trying to create a job portal by seeing a tutorial.
> Now I
> > am at the step of verifying OTP. OTP is generated successfully in
> the
> > database. But when I enter it to the textbox and submit, it shows
> this error
> >
>
> Which tutorial are you following?
>
> What's in the views.py file that is causing the error?
>
> Kind regards,
>
> Kasper Laudrup
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/P1-fQLDoncc/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an em

Django Parler throwing 404 error when switching language

2022-01-19 Thread nonw...@gmail.com
 I created a website that will be translated into different languages using 
the Django Parler package, my default language is English, but I was told 
by my client to make the website load French by default and then a user can 
switch to English if he or she wants. I was able to make the site load 
French by default by creating a middleware and adding it to settings, but 
my challenge is this, I can't switch the site to English, If I do it gives 
me a 404 error here is the link to the site site 
https://ambassadedusaintesprit.com

*Middleware*
from django.conf import settings
from django.utils import translation

class ForceLangMiddleware(object):


def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
language_code = 'fr' 
translation.activate(language_code)
response = self.get_response(request)
translation.deactivate()
return response

*My Settings* 
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'ambassade_app.middleware.ForceLangMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
   
]
LANGUAGE_CODE = 'en'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

LANGUAGES = (
('fr', _('French')),
('en', _('English')),

)

PARLER_LANGUAGES = {
None: (
{'code': 'fr',},
{'code': 'en',},
),
'default': {
'fallback': ['fr',],
'hide_untranslated': False,  

}
}

PARLER_DEFAULT_LANGUAGE_CODE = 'fr'

*base.html*

   {% csrf_token %}
   
   
  {% get_current_language as LANGUAGE_CODE %}
  {% get_available_languages as LANGUAGES %}
  {% get_language_info_list for LANGUAGES as languages %}
  {% for language in languages %}
 
{{ language.name_local }} ({{ language.code }})
 
  {% endfor %}
   
   

   



  


  

-- 
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/9bd91348-ead9-4a66-9b39-d2a157b02000n%40googlegroups.com.