Anonymous
Yes
Anonymous
{% extends 'base.html' %}
{% block body %}
<div class="container">
<div class="jumbotron">
<div class="text-center">
<div>
<h2 >C Gateway </h2>
</div>
<h4>Welcome to C you can login here</h4>
<form method = "post">
{% csrf_token %}
{{ form.as_p}}
<button type="submit" >Login</button>
</form>
</div>
</div>
</div>
{% endblock %}
Anonymous
It seems to be all right.
Anonymous
show your forms.py
Anonymous
i don't have any forms .py
Anonymous
🤔
Anonymous
is it neccessary to create forms.py
Anonymous
and your views.py?
Anonymous
i don't have any idea about forms
Anonymous
from django.shortcuts import render
# Create your views here.
from django.shortcuts import render,HttpResponse
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout
# Create your views here.
def login_view(request,*args,**kwargs):
context = {}
print(args,kwargs)
print(request.user)
return render(request,"gateway/login.html",context)
Anonymous
you use {{ form_asp }} when youŕe using a ModelForm
Anonymous
in your case you need to Rrendering fields manually
Anonymous
Anonymous
Csrf is working
Anonymous
it is not the problem
Anonymous
why dont you define your labels and inputs?
Anonymous
for example
Anonymous
<div class="container"> <label for="uname"><b>Username</b></label> <input type="text" placeholder="Enter Username" name="uname" required> <label for="psw"><b>Password</b></label> <input type="password" placeholder="Enter Password" name="psw" required> <button type="submit">Login</button> <label> <input type="checkbox" checked="checked" name="remember"> Remember me </label> </div>
Anonymous
instead of {{ form_asp }}
Anonymous
if you wanna use that, you need to create a form in forms.py and define your form according with your model
Anonymous
but in this case you dont need them, because is just a login
Anonymous
Anonymous
Anonymous
from django import forms
class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField(widget=forms.Textarea)
sender = forms.EmailField()
cc_myself = forms.BooleanField(required=False)
Anonymous
Yeah will try it thank you 😊
Anonymous
👍
Евгений
hi all
I have nex config:
# —-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(SITE_DIR, 'db.sqlite3'),
'OPTIONS': {
'timeout': 30,
},},}
# —-
but i had continue cach errors:
"django.db.utils.OperationalError: database is locked"
#—-
also the django send this options to sqlite
site-packages/django/db/backends/sqlite3/base.py: get_new_connection(...)
conn_params['timeout'] == 30
#—-
have any idea how to fix it?
Kueen
I have a problem with the register page, after registration it redirects to login page then after login it redirects to profile page as expected but it isn't storing the registered users in the database
Kueen
What might be the issue?
Time
What might be the issue?
Check your registration view if the .save() method is appropriately indented, form method is a post and button type is submit...Further debug requires u to show us the code snippet
Kueen
forms.py
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
import datetime
from django.contrib.auth.password_validation import validate_password,password_validators_help_texts
class SignupForm(UserCreationForm):
email = forms.EmailField(required=True)
class Meta:
model = User
fields = (
'username',
'first_name',
'last_name',
'email',
'password1',
'password2'
)
def save(self, commit=True):
user = super(SignupForm, self).save(commit=False)
user.first_name = self.cleaned_data['first_name']
user.last_name = self.cleaned_data['last_name']
user.email = self.cleaned_data['email']
if commit:
user.save()
return user
Kueen
views.py
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from users.forms import SignupForm
# Create your views here.
def register(request):
if request.method == 'POST':
form = SignupForm(request.POST)
if form.is_valid():
form.save()
first_name = form.cleaned_data.get('first_name')
messages.success(request, f'Your account has been created! You are now able to log in')
return render(request,'users/login.html')
else:
form = SignupForm()
return render(request, 'users/01-LandingPage.html', {'form': form})
@login_required
def profile(request):
return render(request, 'basics/profile.html')
Kueen
and this html file is big so im just showing the form part
Anonymous
Request URL: http://127.0.0.1:8000/mygoal/%7B%25%20url%20'mygoal:delete-goal'%20object.id%7D
When i clicked the delete button that i have made it redirects me to Page not found and this url shows up.... what can i do to fix it?
Ильяс
How to make a choice field of freelancer and a customer in API
Ильяс
?
Kueen
cj
Kueen
Yes
Anonymous
hello, can anyone please tell me how to upload multiple images in single selection through django admin panel.
Anonymous
hello guys:
I am developing a campus application which can offer students timetable, course comments and news notifications.
The back-end was developed by Django and the question is:
How much performance do i need to support such application?
Here is my GitHub:
https://github.com/Military-Doctor/MUSTPlus.Server.Public
cj
⟨ Simon |
⟨ Simon |
did I miss something ?
cj
did I miss something ?
a UnitTest folder https://github.com/Military-Doctor/MUSTPlus.Server.Public/tree/master/UnitTest without using any single library to do unit testing....
⟨ Simon |
oh
⟨ Simon |
thought you actually meant someone would die
cj
if you're strong enough, go check that repo, else you'll die just in the first line of code
cj
Anonymous
I almost die reading that repo ⚰️
Thank you very much for suggesting these improvements to my project, I have deleted the sensitive code. This project is still under development...
Rohan
Rohan
Have you done a full rebase?
Anonymous
I would like to know what else you fell uncomfortable about my project
Anonymous
yeah, I crate a new branch and delete the master
Rohan
Cuz if you remember it's vcs, I can still revert your commits and get all sensitive data back
Anonymous
yeah, I've done a full rebase.
Anonymous
Thanks for reminding me
Rohan
now this is uncomfortable.
Anonymous
😂
Anonymous
The reason I print the password was for debugging..... Sorry
cj
Anonymous
Anonymous
Because I didn't have good habits when I started learning programming.
Anonymous
The first programming language I learned is called "E"
Anonymous
which E has the same pronunciation as "易"(easy)
Anonymous
in Chinese
Anonymous
This E language using chinese to write codes, which means I don't have to learn English at the beginning.
Anonymous
It was was in primary school, 10 years old
Anonymous
E language is very similar to VisualBasic, you can even say that E language is the translated version of VB
Anonymous
The IDE is horrible, code cannot be edited by third-party editors, but only by the official development environment.
Anonymous
You can't look at the call stack, can
Anonymous
can't modify variables on the fly
Anonymous
So... I have such a bad habit
Anonymous
The easiest and most effective way to debug this horrible language is to print the result
Ruffiano
Ruffiano
Hello Guys,
If someone has experience with mobile number verification or Send (OTP) a One-time Password Via SMS, please share your experience or advice.
Here is what I found some useful links.
1. Twilio has Authy 2FA and Passwordless Login solution, how do you think about this? www.twilio.com
Ruffiano
thank you in advance
Anonymous
Ruffiano
Before def login_view