#web-development
2 messages · Page 163 of 1
from random import randint
app = Flask(__name__)
@app.route('/home')
@app.route('/')
def home_page():
return render_template('home.html',the_title = 'Home')
@app.route('/random',methods=['GET', 'POST'])
def random_page():
if request.method == "GET":
return render_template("random.html")
if request.method == "POST":
range_start = request.form['start']
range_end = request.form['end']
result = randint(range_start,range_end)
return render_template('random.html',the_title = 'Random Generator',the_result = result)
if __name__ == "__main__":
app.run(debug=True)
so you need to do something for a get request as well right
oops! wait, though the page finally loads, I messed something up
wow I'm dumb
nicee
so when you click generate
it shows this
and I have zero idea where it gets converted into int
okay I did
Hi, I have a question about flask.
So from what I gathered you use this to declare a variable that every template can use
@app.context_processor
def inject_stage_and_region():
return dict(some_name=variable)
And I was wondering, how can I modify that variable?
For example, you store a logged_in variable and when the user logs out you update it and now every template knows the user logged out. Is that possible?
CORS is enforced by all major browsers, (and they don't change your code) - so that's a bit ambiguous
Sorry language barreer I mean what is the best browser that's not blocking your code.
google CORS started blocking my code during one web scraping project
does anyone know why i dont recieve any money from sandbox paypal
In both accounts or just one?
both accounts
Business and default
I found a notification it says
idk what's the problem of my code that did this
Are you sure it’s sandbox because as far as I know in sandbox environment payments don’t go through review.
yes it is
Right then maybe there might be a setting to turn off payment review
The setting will be account side and not an issue with the code.
that?
i just turned them off
let me try
not working
aaah yees
its a problem in the code
i added an alert but it's not showing
i still dont see alerts
cause its an account problem let me see
yes
Do you get any responses back from the API requests you make to them?
This reminds me PayPal is an absolute pain integrating. It’s documentation and API is horrible compared to other gateways.
idk what's the problem tbh why its refusing to send money
what do i do now
shall i delete app and create a new one ?
ooh it worked
when i created platform app it worked now the alert appears
@left jackal firstly, CORS doesn't block your code. It blocks the browser/client from parsing the response from the server.
Are you sure you're actually web scraping and not sending a request to the API
yo guys can someone tell me how to detect for automated browsers using django
like if i detect automated browser, display captcha
if no automated browser detected, dont display captcha
Need help 😕
With watermark in views.py
I wanted to know how I can save a photo that will contain a watermark. Currently grabs a photo from the form and creates a watermark on it, but saves it separately. More precisely, I would like the photo I send in the form to be processed and saved.
if request.method == 'POST':
form_w = ImageForm(request.POST, request.FILES)
if form_w.is_valid():
# form = form_w.save(commit=False)
cd = form_w.cleaned_data['img']
im = Image.open(cd)
width, height = im.size
draw = ImageDraw.Draw(im)
text = "TEST WATERMARK"
font = ImageFont.truetype('arial.ttf', 36)
textwidth, textheight = draw.textsize(text, font)
# calculate the x,y coordinates of the text
margin = 10
x = width - textwidth - margin
y = height - textheight - margin
# draw watermark in the bottom right corner
draw.text((x, y), text, font=font)
print('Before saving: ', im)
im.save('Luki/media/upload_p/{}'.format(cd))
img = Image.open(('Luki/media/upload_p/{}'.format(cd)))
print('After saving: ', img)
form_w.instance.save()
return redirect('Luki:gallery')
else:
form = ImageForm()
return render(request, 'Luki/upload_img.html', {
'form': form,
})```
hey is this the correct place to ask for help with Web3?
Hii
Hi everyone.
which framework does it teach?
i don't really know
django is my preference
i think
k so don't udemy when you can learn for free
The one course I ALWAYS recommend for beginners is one taught by coding for entrepreneurs
python have a lots of framework so you have to choose which one you want to learn? and Every framework have some facility and objective. So i think What do you want to do in future then you have to choose framework it will be better.
I'll send a video
@rigid prairie
@rigid prairie , django and Flask are great frameworks -- you should chose now wether you want to build complex web-apps or simpler ones
i really wanna make web apps like chat app, and something on ethe line
django is more comprehensive than flask, but it's not too difficult to learn as a first framework
oh
django could be great for that
I'll drop a link here
right
Learn the Python Django framework with this free full course. Django is an extremely popular and fully featured server-side web framework, written in Python. Django allows you to quickly create web apps.
💻Code: https://github.com/codingforentrepreneurs/Try-Django
⭐️Course Contents ⭐️
⌨️ (0:00:00) 1 - Welcome
⌨️ (0:01:14) 2 - Installing to Get ...
this is the first video I'd recommend -- for anything supremely SPECIFIC, if you can't get a particular thing right in django, check out Corey Shafer on yt
<pronoun> also has great videos for any specific PART or module, though I'd suggest to watch him after you learn the fundamentals
this video places great emphasis on all the CONCEPTS of django, and every application of it on a more simple level
kk
for a coding walkthrough of building a chat app, Corey Shafer and Dennis Ivy (watch in the future) will be great
i would start off with this for now
Django with mangoDB or postgrsql SQL is good I am building large project
I've not tried Mongo but PostgreSQL is good
it won't be as instantaneous as something like dbsqlite, but it's more robust and secure overall of course
not to mention
open
source
🙂
I think, PostgreSQL will be best.
quick google: If you want to use a database-backed session, you need to add 'django. contrib. sessions' to your INSTALLED_APPS setting. Once you have configured your installation, run manage.py migrate to install the single database table that stores session data.
Gimme a sec
wat
i have session data
like request.session['user'] = "John"
how do i get "John" from the consumer
waitup
ok nvm
@ivory bolt its ok ik now
i used self.scope['session']['user']
thanks anyway
Hello
can python also make websites
I am a experienced web developer
Not much JS
But HTML and CSS
how do i start a virtual env
in windows
i tried activate/Scripts
not working
i am in the venv name directory
trydjango
nope
for begginers
can i just use pycharm?
it has virtual env
kk
i will use that
then
it is easier
it should be like this Scripts\activate
but it is not working for some reason
yeah
lemme
in my pc it does not works with this
iyeah
that works
no respond
have you tried deploying react on another local machine/virtual machine and tested that first
wait
no response
C:\Users\Prabal\dev\venv\Scripts\activate.bat
also no work
done
@covert cosmos this is what’s you want to do right
I personally don't have much experience with deployment or system architecture in general
but
setting up another instance and communicating between one another IS POSSIBLE
the name is trydjango
for large scale projects yes
the idea is you want the user to be able to see the frontend FAST
and you don't wanna load your chunky backend with it
what's your project like
and wether you can actually implement it
My question still stands
what type of app are you biilding
*building
and wether you know HOW to run the react app independently from django and deploy it on another instance
Hey this is me on mobile
Explain comprehensively
Cuz no blog app needs fullstack 😂
I suggest deploy on one backend for low traffic
But guy larger scale or experimental purposes, create another instance and run
It's gonna cost you a bit more
Brroooo
Not a blog app 😂
On a scale of 1-10, how heavy is the project
I recommend running another instance if this is something a lot of people are gonna use
Yep
I'll do some research and get back to you though
It could cost you so let's see if it's worth it
how long would it take for a begineer to build a landing page with python
Yep... Architecting systems is pretty interesting
Not long at all
Especially on the backend
depends on persons,if u are fast learner it take less time
django or flask tho
I can help you get started with Flask if you want to just build super quick
With limits
can u teach instead
👍
yh
[django]
took backup of the staging server database,
restored it in dev environment.
no matter what object, model I try to update, I get
IntegrityError
null value in column "id" violates not-null constraint DETAIL: Failing row contains
we also have django-defender setup, so even when logging in, it tries some db transactions, and get the same error,
what would be the issue? has anyone faced this?
css ad js is for front end, if u use it makes ur frontend look nice but u can also avoid it, but i recommend learning css becoz its so simple and its very useful
i got the answer, thx
Can someone please tell me why this is happening
i didnt do anything
def contact(request):
if request.method == "POST":
name = request.POST['name']
subject = request.POST['subject']
message = request.POST['message']
email = request.POST['email']
try:
validate_email(email)
send_mail(
subject,
"Email: {}\n\nMessage: {}".format(email, message),
'from@example.com',
[settings.EMAIL_HOST_USER],
fail_silently=False,
)
anyone ?
show more of the code
looking for your except
that's the whole contact view
def contact(request):
if request.method == "POST":
name = request.POST['name']
subject = request.POST['subject']
message = request.POST['message']
email = request.POST['email']
try:
validate_email(email)
send_mail(
subject,
"Email: {}\n\nMessage: {}".format(email, message),
'from@example.com',
[settings.EMAIL_HOST_USER],
fail_silently=False,
)
except ValidationError:
messages.error(request, "please enter a valid email")
Contact.objects.create(name=name,email=email,subject=subject,message=message)
return render(request, 'base/contact.html', {"name": name})
return render(request, 'base/contact.html', {'title': 'Contact'})
ok let me show u more of error
just add prints...
def contact(request):
print("debug 1")
if request.method == "POST":
print("debug 2")
name = request.POST['name']
print("debug 3")
subject = request.POST['subject']
message = request.POST['message']
email = request.POST['email']
try:
print("debug 4")
validate_email(email)
print("debug 5")
send_mail(
subject,
"Email: {}\n\nMessage: {}".format(email, message),
'from@example.com',
[settings.EMAIL_HOST_USER],
fail_silently=False,
)
print("debug 6")
except ValidationError as error:
print(f"debug error: {error}")
messages.error(request, "please enter a valid email")
print("debug 7")
Contact.objects.create(name=name,email=email,subject=subject,message=message)
print("debug 8")
return render(request, 'base/contact.html', {"name": name})
print("debug 9")
return render(request, 'base/contact.html', {'title': 'Contact'})
and check where they will stop)
as possible reason, send_mail could be broken
oh ok
as alternative, perhaps POST request is not working
and it is not entering your if at all
<form action="{% url 'Contact' %}" method="POST">
Here is the opening form tag
let me try to print the view and it see if it works
so it displayed
debug 1
debug 2
debug 3
debug 4
debug 5
so send mail is the problem
let me update django and see if it's working
not working
idk what's the issue
@inland oak
what is wrong?
think about enabling debug mode for your framework
it should be possible in its settings
it will describe more throughly what's wrong after rendering template
Anyone here create Alexa skills before using Flask or something?
u mean Debug = True ?
yup
it's already true
which framework is it
Django
yes
oh 😦
showing timeout connection without any reason
I updated django and still not fixing it
it's something related to send_email
¯_(ツ)_/¯
this error is showing up
yes
?
!e
var = 5
print(type(var))
@inland oak :white_check_mark: Your eval job has completed with return code 0.
<class 'int'>
remove variables named type if you have them
¯_(ツ)_/¯
not enough information to guess anything else then
perhaps you are iterating wrongly over QuerySet object, or where you expected to have QuerySet
do u know any course where latest django version is used>?
django official documentation is rich enough in my opinion
https://docs.djangoproject.com/en/3.2/
thx
Im really depressed that my code is showing error without any change
is SMTP server down or something
perhaps you aren't having permissions to access it from external source (python)
some email settings tuning is required
it was working clean
but i tried it today its not
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'MYEMAIL'
EMAIL_HOST_PASSWORD = 'PASSWORD'
roadmap for web development
So there isnt any fix for issue it prevents all my email from being sent
Heey mind if u help me here i found the solution but i cant do it
there
it says check dns server
how to do so
why do you bind to local network
perhaps to try binding to 0.0.0.0:8000
nslookup smptp.mail_host.com this shows error
Server: one.one.one.one
Address: 1.1.1.1
*** one.one.one.one can't find smptp.mail_host.com: Non-existent domain
how so
what does this do
perhaps to try changing your internet settings
to have public dns like 8.8.4.4
this isn't working
oh u mean google dns ?
yeah
let me add it wait
let me try now
also
running from Windows server is a bit weird
not really efficient
did you think about getting linux vps
still not working
shrugs
I changed my etherenet dns or should i change router dns
i believe it wont work either
now it shows this
Server: dns.google
Address: 8.8.8.8
*** dns.google can't find smptp.mail_host.com: Non-existent domain
did you change it on windows server?
u mean ethernet IPv4 ?
perhaps you have wrong smtp server address
I am actually having google email working too in django
how to check
my mail sender
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from django.conf import settings
from types import SimpleNamespace
from django.template import Context, Template
import os
def send_mail(mail):
"""Function capable to send google email
from google email address"""
# commaspace = ', '
message = MIMEMultipart("alternative") # create a message
message["Subject"] = mail.subject
message["From"] = settings.MAIL_USERNAME
message["To"] = mail.address # commaspace.join(mail.recipients)
message.attach(MIMEText(mail.text, 'plain'))
if hasattr(mail, 'html'):
message.attach(MIMEText(mail.html, "html"))
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.ehlo()
server.login(settings.MAIL_USERNAME, settings.MAIL_PASSWORD)
server.send_message(message)
server.close()
def send_verify_email(name, url, address):
context = Context({"name": name, "url": url})
with open(os.path.join('main', 'templates', 'email',
'verify_email.txt')) as file_:
txt = Template(file_.read())
with open(os.path.join('main', 'templates', 'email',
'verify_email.html')) as file_:
html = Template(file_.read())
mail = SimpleNamespace(subject='test subject',
text=txt.render(context),
html=html.render(context),
address=address)
send_mail(mail)
it looks like google has 'smtp.gmail.com' as smtp
I was a little bit of pervert when I chose SimpleNamespace, don't mind it
so should i convert this EMAIL_HOST = 'smtp.gmail.com' to this EMAIL_HOST = 'smtp' but i believe i shouldnt
do what you wish. You can just copy my google mail sender, in bits you need
let me try this
and wanna try your port
now i have a new error
getaddrinfo failed
oh waiit
still not working
this is a disaster
Can this fix it ?
ig smtp.gmail.com is correct
yes
they are similar
very much difference
but fetching from db and some things remains same
are u free can u come voice chat ,can u help me plz
its common in web dev lmao
what's ur problem
open this
then scroll down after a minimal application
u can see some text like this
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from .models import Choice, Question
# ...
def vote(request, question_id):
question = get_object_or_404(Question, pk=question_id)
try:
selected_choice = question.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
# Redisplay the question voting form.
return render(request, 'polls/detail.html', {
'question': question,
'error_message': "You didn't select a choice.",
})
else:
selected_choice.votes += 1
selected_choice.save()
# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))```
so some questions , doubts and problems in it
oh
oh
oh
@covert cosmos @ivory bolt https://www.youtube.com/watch?v=xv_bwpA_aEA&list=PL-51WBLyFTg2vW-_6XBoUpE7vpmoR3ztO&index=1
NOTE: Updated and compatible with Django 3.0
In this video I'll introduce my django crash course series. In these tutorials we will will be building a customer management app. Part one will cover installing django and getting our basic app setup.
Follow me on Twitter: https://twitter.com/dennisivy11
Linkedin: https://www.linkedin.com/in/dennis...
is this one
good
for begginers
cause the previous one was using django 2.0.7 which is full of bugs
hey iam new here
Welcome.
hey
can u guyz help me out
clearing my doubts
<form action="{% url 'app1:detail' question.id %}",method="POST"></form>
{% csrf_token %}
<fieldset>
<h1>{{question.question_text}}</h1>``` i have not taken this question.question_text i mean not written inside for loop then too workinng + its given in the docs too
def detail(request,question_id):
question = get_object_or_404(Question, pk=question_id)
question={'question':question}
return render(request,'app1/detail.html')``` iis it because this question
iam new and i dont know about python codinga can anyone make me there student
@late gale bruh help plz
how bruh thats what asking i havent used there any for loop
how
cez of this?
what are u trying to do
learning django from docs and wanted to learn it not only to copy paste ready yo struggle but want to become master thats why going to deep
oh so we r fetching it from?
how without question thats the issue
u can watch youtube videos from dennis lvy or corey
they both are perfect
is there any error occuring
but first docs as my friend @H0NCHO said
i cant get this logic
depends on the person
if you prefer videos or reading
i personally prefer videos
i myself too
but started
and done till some end
now ig i cant leave it like that
change your port and check again
often times it's a TCP thing
sometimes a pending TCP connection on one end from a client gives out a timeout error
check out the default email port
look it could just be some TCP thing, if it's not working today it could work tomorrow
restart your server a couple fo times maybe
@dusk portal please can you be more specific with the errors you encounter? Saying "it's not working" does not help people answer your questions.
-,-
can it works if i restart my PC
i have query not any error
i changed my dns to google
wut no I ain't a legend that can fix ur printer I wouldn't know how to restart a pc
seriously tho no
Be specific with questions then
seriously tho I can't fix ur printer
printer ??
m joking
lol
completely out of context
as im learning from docs so they showed this py <form action="{% url 'polls:vote' question.id %}" method="post"> {% csrf_token %} <fieldset> <legend><h1>{{ question.question_text }}</h1></legend> so in last line we are not fetching it inside for loop so how is it possible ,as per me it can be 2 reasons cez in db question=ForeignKey or cez in my view ```py
def detail(request,question_id):
question = get_object_or_404(Question, pk=question_id)
question={'question':question}
return render(request,'app1/detail.html',question)``` this is detail
its a big question mark guyz
and nothing happened
@opaque rivet where u gone sir 👀
@dusk portal you didn't even show any for loop
yes then too working + its same in docs how can it be working
i myself is amazed after seeing this
#my class Choice
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
```
lemme look into it
Firstly, I don't know what the issue is.
You're rendering the question_text attribute of your question.
There is no for loop there
I have no clue why you're talking about a for loop
Thank you im trying to fix it as well but cant find a solution
its like an error without any reason
i found something and it seems to make sense
I read from
http://www.packtpub.com/article/friends-via-email-social-web-application-django-1.0
and follow the steps:
=> And change my
setting.py
SITE_HOST = '127.0.0.1:8000'
DEFAULT_FROM_EMAI...
let me try
this is very similar to your question here and basically you're unable to connect to the email server
telnet isnt recognized
Probably not connected to smtp server
and how to connect it
let me allow it on windows
found this that can enable it
@ivory bolt It says this
Connecting To smtp.xxxx.com.kh...Could not open connection to the host, on port 25: Connect failed
so no connection to 25 port ?
let me see if its enabled in firewall
That's not it
then what it is
Read the post and understand it completely
That's something for a development server
but that on linux
Surely you're not rying to connect to stmp.xxxx.com.kh?
im using windows
yup i tried 25 and all ports even this and all cant connect
Following their docs
If you plan to send emails from your gmail mail, you need to connect to the smtp server to send said emails.
smtp.xxxx.com.kh is a placeholder. (if you can't tell, its because of the 4 xs).
So obviously you can't connect to a server that doesn't exist.
Pretty sure just following django docs should sort this out for you.
it doesnt has anything related to smtp configuration , I added everything and it was working fine i swear last week
please consider that this problem is intense the website is sending emails everywhere so something like this could destroy organization website
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'EMAIL'
EMAIL_HOST_PASSWORD = 'PASSWORD'
DEFAULT_FROM_EMAIL = "ORGANIzation <noreply@ORGANIzation .com>"
There my settings.py
and not working
For gmail, you have to go into your account settings and tick allow unsecure access.
Did you do that?
where
Search it up. Something about gmail insecure access
I allowed to create app in google
I have no clue what you just said
I created an app password in google so i can connect my gmail to django
It was working fine last week
omg
Look at a guide to setup gmail with Django. It'll tell you the settings to change to allow you to connect to googles smtp servers.
I dont believe the problem is connection between django and gmail
because it was working
the problem is in smtp server
cant connect to
Exactly, which is what I just said.
and still its connected to gmail
oooh
waaaait
should i remove 2FA
and try ? @opaque rivet
Yes, that's the setting, just follow a guide further
🤦♂️
hahaha
still not working
i will kill my self
🔪
😭
@opaque rivet
Cry with me
Cant this problem be erased from Earth
let me try to restart the pc and wish for a miracle
Not working
Anyone ? this is really depressing
I killed my self no need
k wait
Like seriously im done of this Why is it doing like this
What’s your current setup? 2fa and app password?
def contact(request):
print("debug 1")
if request.method == "POST":
print("debug 2")
name = request.POST['name']
print("debug 3")
subject = request.POST['subject']
message = request.POST['message']
email = request.POST['email']
try:
print("debug 4")
validate_email(email)
print("debug 5")
send_mail(
subject,
"Email: {}\n\nMessage: {}".format(email, message),
'from@example.com',
[settings.EMAIL_HOST_USER],
)
print("debug 6")
except ValidationError as error:
print(f"debug error: {error}")
messages.error(request, "please enter a valid email")
print("debug 7")
Contact.objects.create(name=name,email=email,subject=subject,message=message)
print("debug 8")
return render(request, 'base/contact.html', {"name": name})
print("debug 9")
return render(request, 'base/contact.html', {'title': 'Contact'})
Yes
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'NO x 10^99'
EMAIL_HOST_PASSWORD = 'NOOOOOOO'
DEFAULT_FROM_EMAIL = "NoOO<noreply@NOO.com>"
And so what happens currently? Where is the error or issue?
Also have you tried any local test mail providers. Just to rule out if it’s gmail or your code?
yup i tried smtp test on google and it worked perfectly
unable to authenticate using django form
from django.shortcuts import render
from django.contrib.auth.models import User
from django.shortcuts import redirect
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import authenticate, login
from .forms import LoginForm
def Register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
data = form.cleaned_data
user = User.objects.create(username=data['username'],
# password=data['password1']
)
user.set_password(data['password1'])
user.save()
return redirect('/')
form = UserCreationForm()
context = {
'form': form
}
return render(request, 'register.html', context)
def LoginUser(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
data = form.cleaned_data
user = authenticate(
request, username=data['username'], password=data['passsword'])
print(data)
print(user)
form = LoginForm()
context = {
'form': form
}
return render(request, 'login.html', context)
from django import forms
class LoginForm(forms.Form):
username = forms.CharField(max_length=100,)
passsword = forms.CharField(widget=forms.PasswordInput)
output
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
{'username': 'abc', 'passsword': 'abc'}
None
[11/Jun/2021 17:00:47] "POST /login HTTP/1.1" 200 3330
{'username': 'abc', 'passsword': 'abc'}
None
[11/Jun/2021 17:01:05] "POST /login HTTP/1.1" 200 3330
Tried this
added my google account and added smtp.gmail.com and port 587 and worked
so the problem is in my project ?
maybe it's your local machine
Which is why i said have you tried with other local test mail providers.
elaborate please
didnt try anything other than smtp
exactly it doesn't made sense otherwise
how to try other mail provider then
Test with something like mailhog or papercut
[WinError 10061] No connection could be made because the target machine actively refused it
tried mailhog
im not good with these stuffs just beginner with the mail servers
hi guys i have been following a tutorial on django ,and i was doing the same as the tutorial untill he started using css and js ,so i have copied his tamplate and pasted in the right folder
@late gale did you setup two auth for you gmail? and did you create app password?
but the result was different
Yup i did
the problem is that it was working last week but today it didnt
and your EMAIL_HOST_USER and EMAIL_HOST_PASSWORD are set correctly i mean not these examples that youve used here right?
Yup they are
daamn the whole server is trying to help me and this problem cant be fixed yet
Im really glad but this problem is very depressing
Dont leave me struggling alone @mint folio @ivory bolt 😭
we need to call bill gates
Can anyone copy my form and send it and try it in his PC
and tell me if it works or not
but i need to trust someone ^^
and why thistelnet smtp.xxxx.com.kh 25 returns Connecting To smtp.xxxx.com.kh...Could not open connection to the host, on port 25: Connect failed
Please don't forget about me this problem is intense
doomsday
Everything is fixable in the end .. look for the lone code line or variable in this case input parameter
unable to authenticate using django form
from django.shortcuts import render
from django.contrib.auth.models import User
from django.shortcuts import redirect
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import authenticate, login
from .forms import LoginForm
def Register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
data = form.cleaned_data
user = User.objects.create(username=data['username'],
# password=data['password1']
)
user.set_password(data['password1'])
user.save()
return redirect('/')
form = UserCreationForm()
context = {
'form': form
}
return render(request, 'register.html', context)
def LoginUser(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
data = form.cleaned_data
user = authenticate(
request, username=data['username'], password=data['passsword'])
print(data)
print(user)
form = LoginForm()
context = {
'form': form
}
return render(request, 'login.html', context)
from django import forms
class LoginForm(forms.Form):
username = forms.CharField(max_length=100,)
passsword = forms.CharField(widget=forms.PasswordInput)
output
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
{'username': 'abc', 'passsword': 'abc'}
None
[11/Jun/2021 17:00:47] "POST /login HTTP/1.1" 200 3330
{'username': 'abc', 'passsword': 'abc'}
None
[11/Jun/2021 17:01:05] "POST /login HTTP/1.1" 200 3330
Please help me
Is it possible to have an API that gets data through a POST request and also is a websocket / socket server that can send the data in the POST request to the clients connected
Some of my friends said that django is not worth it
Node has more demand ,are my flask skills not worth it are they only for building logic and my use not for commerical purposes
Do anyone ask for flask or django on back-end
done
Absolutely!
Websockets works off the same connection principles of HTTP, so in theory any http server should be capable of upgrading the connection.
can someone please help me here
im getting this error
my settings.py
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'NO x 10^99'
EMAIL_HOST_PASSWORD = 'NOOOOOOO'
DEFAULT_FROM_EMAIL = "NoOO<noreply@NOO.com>"
It was working last week suddenly It occurs
@steady swan once the request is upgraded, it doesn't continue to follow HTTP principles - or does it?
Who says django is not worth it , I don't see his present
Once upgraded a new protocol takes over. Both the client and server hold open the connection allowing the two way interface. I'd suggest not trying to roll your own to start. The websockets protocol is super complex. Use a framework that supports both, and go from there.
See #general ppl say flask is dead and django is not better then node
Anyone ?
Please like we spent all day in this me and some members as well
wish I could. There's obviously something preventing your app from connecting. I'd take it one step at a time. First make sure the machine running your app can ping the server. Then try connecting without your app.
Hopefully if you break it down you can isolate where the connection issues are coming from.
how so
@steady swan ah yeah, I totally just forgot that websockets is an entirely different protocol. It's just the original request with the upgrade header which initiates it.
I've been using django, but iirc the middleware is not async so there's performance penalties out of the box.
ping smtp.gmail.com
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 70ms, Maximum = 71ms, Average = 70ms
ms is great
Yup. Although TBH I'm out of the Django world 10 years or so. I think they started adding async, but I don't know enough to be an authority on that.
thats not my first time sending email it was working very well
But django channels was created for this purpose exactly
so i believe something went wrong
@steady swan what tools have you been using, recently? Out of curiosity.
😆 I'm biased. https://github.com/sanic-org/sanic
@steady swan sorry again like what does it mean
that it is okay
@late gale follow the guide link above. I used it to setup gmail emails.
0% loss means it was able to send packets no problem
All it said , I followed
I told u , it was working
suddenly it didnt
then what might be the problem
is it dns issue ?
likely not if you can ping okay
next step maybe is write a small standalone script to try and make an smtp connection
I'm sure Google can come up with some good tutorials
if that works, then there must be something in your app layer
how to do so
Again, as the Sanic maintainer I'm biased towards that. But all of the async frameworks should support this. There's also standalone libs like websockets which does have an HTTP layer, but is best for super simple heathchecks. You're better off with a framework that has both http and websockets support.
Besides Sanic you can also checkout starlette, aiohttp, Quart, Fastapi. Django also has this ability, albeit more complex since it is out of the box WSGI which is at odds with websockets. Search Google for python ASGI frameworks and find one you like.
@steady swan I tried to send it using the link above and it sends me the same error
[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
so, sounds like a problem with your machine/network connection
what might be the issue
Hello anyone know about Django
is there something to do in my router settings
?/
yea there are alot of people here dont worry
I want to differentiate the edit profile view
Facing this error
edit prof view for labour
and Efitprofview for Engineer
@ruby portal r u there ?
@steady swan Oh when I changed my port to 465 and disabled TLS and enalbed SSL it worked @opaque rivet @ivory bolt
I GONNA CELEBRATEEEEE!!!!
DANCE WITH MEEE
💃
👯
I need 50 champagne for this
cheeeers
how can I overwrite the variable from cleaned_data
x = form.cleaned_data['name']
x = 'Dance with me'
mhm @late gale can you help me with the code?
As I asked before...
I wanted to know how I can save a photo that will contain a watermark. Currently grabs a photo from the form and creates a watermark on it, but saves it separately. More precisely, I would like the photo I send in the form to be processed and saved.
anyone ? 😅
Hello, I'm kind of confused by how django works, when I'm creating a website with django, do I have to code in html css and js? Or just python and django somehow creates html css and js for the front end?
Yes, you still have to write HTML, CSS, and JS.
The HTML you write isn't the plain HTML you might expect. Django can insert data from Python into the HTML before it sends it off to a user's browser.
HTML, CSS, and JS are all front-end things. Django is a back-end framework. It takes care of serving web pages and other static content (images, CSS files, JS files, etc.) to users' browsers. But you still have to write all those things yourself.
Is an ASGI server like Uvicorn supposed to run behind a reverse proxy, or can it be exposed directly to the internet?
how do i get all users that do not have a group with name group_name? (context django)
I would recommend sticking it behind a reverse proxy
Things like Nginx have many security advantages like concurrent connections limitations and also allow you to support HTTP/2 for clients which is a big advantage
Alright. Would you recommend NGINX or HAProxy? I’ve heard good things about both of them.
👍 thanks, I appreciate it!
I have a related question. If I put my site behind Clouflare, do I still need a reverse proxy? CF is a reverse proxy itself, and I don't need any complex routing since I only have 1 service running. AFAIK CF can take care of HTTP/2. Not sure about limiting concurrent connections. What would I be missing out on without nginx?
Well generally
High performance static file sending
and not HTTP/2 + going to your server
I use whitenoise which serves them through cdn, so whatever
Cloudflare does client -> CF upto HTTP/3 v1
which is great
but that's still HTTP/1 to your servers from cloudflare
which generally is more distance apart than clients to cloudflare unless you're also geo distributed
sry this if off topic but in flask wehn ur returning something in html how do. u apply pandas?
Hmm okay. Something to consider. But I don't think my particular case would benefit much from HTTP/2.
I just don't want to deal with having to deploy nginx too 😒
If client sends on average more than 1 request per connection, it's worth it normally
Because multiplexing requests cuts out having to open another connection and doing the whole TLS handshake again etc...
which can make a big big diffrence
but that depends on your work load really
Is it out of scope for WSGIs to support HTTP/2 directly
You can use pandas before you render the template and pass whatever pandas returns to your template. Not sure if that answers your questions.
Hypercorn supports HTTP/2 although performance is meh and Personally i've never been able to get Hypercorn be stable when in a prod environment
oh that helps a lot tysmm
Anything else nginx have that's noteworthy?
Well there's other tools too, but I get the impression nginx is more than just a reverse proxy. Has more features compared to e.g. HAProxy I believe.
well the fact it runs lua basically means it can do alot, our setup uses kong which is basically traefik (although kong is older than taefik iirc) but wraps Nginx as it's backend
so we run Proxy caching, ratelimit, response size limiting, request size limiting, auth
etc..
Actually, nginx's site has a good list of features. Nothing really stands out to me for my use case.
Its not really something you absolutely need, but it certainly can be useful
Yeah, exactly.
I have a small scale project and a lot of the info online was immediately defaulting to "you need a reverse proxy"
It was extremely difficult to find anyone explain why
well alot of it comes down to limiting concurrency, TLS support and just the fact that things like nginx are hyper optimised and have decades of security testing
Python seems to suffer much harder than other languages as concurrent clients increase
hiii, so in my website i'm using sqlite3 as db , is there a way to keep only one row if the primary keys are the same??
thats the idea of a primary key
there can only ever be one row with the same value in the primary key column
because it has the UNIQUE constraint
ohhh okay okay , how do i set a primary key xD
c.execute("""CREATE TABLE MD5 (
md5 text PRIMARY KEY,
link text,
language text,
type text,
date integer
)""")
is this right?
yes
kk thank you so much 🙂
is there a way to disable the console log for when the primary key is found?? sqlite3.IntegrityError: UNIQUE constraint failed: MD5.md5 this one here so it doesn't keep on logging it every time it finds one
#databases is better for database questions
Could you open an issue regarding the stability?
I can although Ill have to run some thorough testing to give a better idea of what / where it happens
also nice to see you in the discord :P
let's goooooooooo
so django let's you write python for the LOGIC of the website
meaning when you visit www.yourwebsite.com/, django will handle where can the user go by typing something in the url, what html n css it should show when you type that URL, and what all you can do next
html and css is only a markup language, it'll help you render things on a webpage but not actually do anything. Adding users, chat or other features, processing of data -- that's all django
Right, but to make a proper website, I gotta use html css and js and create one right? A template¿. And django handles the dynamic part?
yep
simply put, I can create THIS with html and css
But nothing will actually work -- the links won't go anywhere, the site won't do a thing, your server won't run in the first place in the real world
so yea, pretty much
Got it.. I was under the impression that i don't have to learn html,css,and js for now, and just focus on python.
Hello everyone
$(document).ready(function () {
status();
$("li.status").click(function() {
$.ajax({
url: "/update_status/",
type: "POST",
data: {
'request_contract_id': 9, //I need optimize this to detect automatically the id and status
'status': 'Rechazado'
},
});
});
});
Can anyone tell why my ajax it's not working?
This is my aja function
ajax*
class ContractRequestStatusUpdate(View):
model = RequestContract
form_class = RequestContractUpdateStatusForm
@csrf_exempt
def dispatch(self, request, *args, **kwargs):
return super().dispatch(request, *args, **kwargs)
def post(self, request, *args, **kwargs):
#Nowadays the id is manually.
id = self.model.objects.get(pk=9)
if request.method == 'POST' and request.is_ajax():#I verify is request is POST and Ajax
form = self.form_class(request.POST)
if form.is_valid():
id.status = form.cleaned_data['status']#I clean the datos from status
id.save()
return HttpResponse('/')
```
This is my view
class RequestContractUpdateStatusForm(forms.Form):
request_contract_id = forms.IntegerField()
status = forms.ChoiceField(choices=RequestContract.STATUS)
and this is the form that i'm using,
I can update perfectly my register, but i have to reload the page, so I think something it's wrong with AJAX
can anyone help me?
What do you want it to do? What's broken about it?
Remember, since this is AJAX, it is submitting "behind the scenes". You can return a 500 or 200 message back and the AJAX function can do something with it like show a "Success!" modal or do a page redirect.
So as far as I can tell this is running as designed -- you submit the form, it sends data to your endpoint, you save it. And then you do nothing (no success, no redirect, nothing).
In Flask if you're posting to an endpoint and you want that synchronous POST to do something like a redirect when it is complete, check out return redirect(...) or return render_template(...) for instance.
BUT, that's if your form submits directly to the endpoint. Which you don't do here. You're submitting via AJAX. So AJAX is what should handle that. Returning a template or a new URL back to the JS won't do anything for you unless YOU do it. Dig?
@lethal kite ☝️
@warm igloo I got it thanks bro!!!
Does anyone have an idea on how to implement a online compiler where I can run my code online?
Guys how can i make that progress bar work with my python script pls??
I don't get why we use the cite tag for? could anyone explain why it does and why we use it?
for when you a citing something
Uh can you be more informative?
that's pretty much it, there are lots of html features that aren't very useful.
though I would imagine that some accessibility programs might make use of them
or bots looking at metadata
have a look at this: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/cite
Oh Ty I will look in to it
@misty goblet I get it now but we only use cite tag for the title of another person's work for example a book right?
it should contain a citation https://www.plagiarism.org/article/what-is-citation
Yea ik
Why do we use blockquote tag for?
Well, the blockquote tag is for making a blockquote. You can see what it looks like by clicking on the link.
Imo that question is similar to saying "what does the p tag do", well it creates a paragraph. What does the div tag do? It creates a div.
this channel helps with js html css right?
Yes
Within reason. Like if you're writing a Node.js app then it's probably off topic.
no no , i mean like simple questions about a code if its correct or not , etc
Those aren't mutually exclusive but never mind. What is your question?
@proper hingeright now im very stuck in learning js html css, or python, personally i enjoy python alot more, but i dont know a career i can start learning with python right now
whenever i search in freelances or jobs , its usually web developers for front end mostly
I'm not the best person to be asking for career advice. I was under the impression you wanted help with some code. If you want career advice, please ask in #career-advice
ok thanks alot
theres alot you can do with python if you are done learning python start using it somewhere and you will figure out .....if you keep searching for the perfect thing to do without putting your hands into anything it doesnt make sense .....i did the exact thing you doing few years ago
How can i un-install django? pip freeze | grep Django -> for this error: 'grep' is not recognized as an internal or external command,
So i was making a website to show 10 random images daily taken from API ......i have written 10 different img tags in my html anyway i could make it less redundant
if anyone get the error the command is pip uninstall django not grep, it's not for windows
i am making an app using python kivi i have some doubts can i ask here
if these are web related ask it over here or just post in python general
If you're using either Flask or Django, you can use Jinja templating to run a for loop for the img tags
Are you using any of them?
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
i am trying to add some actions to the user but it gives me this error
django.contrib.admin.sites.NotRegistered: The model User is not registered
when i remove the line admin.site.unregister(User) then it gives me this error
django.contrib.admin.sites.AlreadyRegistered: The model User is already registered with 'auth.UserAdmin'.
can you tell why this is happening and how do i fix this (context django)
Someone give me a good web scraping tutorial so that I can pull dynamic data.
alright i changed the order of installed apps and it solved the problem
i want to add additional actions to User modal in django admin how do i do that? i can create a custom ModelAdmin but i want to keep everything as it is and just add additional actions (context django)
i did it by adding a class attribute to from django.contrib.auth.admin import UserAdmin
{"timestamp":1623485161160,"status":400,"error":"Bad Request","message":"JSON parse error: Unrecognized token 'mobile': was expecting ('true', 'false' or 'null'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'mobile': was expecting ('true', 'false' or 'null')\n at [Source: (PushbackInputStream); line: 1, column: 8]","path":"/campaign/vouchers/kAxAeMsjtmjCe4aoep/redeem"}
you can learn from udemy
is
@admin.action(description='My Action')
def my_action():
pass
and this
my_action.short_description = 'My Action'
the same thing? (context django)
anyone have the same question then, yes its the same thing
yes im using flask ...dont know anything about jinja .....so i was stuck how to do it using python finally figured out i can do that by javascript .....if iam gonna do that with JS then might aswell do the whole thing in JS and node
instead flask
Hi
i want to create a dashboard which need the actions dropdown from admin change list how do i reuse them? (context django)
not just dropdown widget the functionality ofcourse
INSTALLED_APPS is meant to be a list. Look over your INSTALLED_APPS if you can spot the error.
??
@simple sentinel
Have you tried saving the files and re-running the server?
Because I see the white dot which indicates some files have not been saved
@simple sentinel now see
Bro save all your files
Your urls.py isn't saved, your settings.py isn't saved
No autosave in vsc? 🤔
naah... i have saved it
Are you importing the index.html index in that views file?
Try to rename template directory into templateS
man that wont work
You tried it?
mannnnnnnnnnnn!!!!!!!
worked......
hahahahahaha.....
shit just a mistake of 's'.
@serene prawn
You could also have templates local to your applications
like this
thank you so much buddy @serene prawn @simple sentinel
i see!!
I am unable to load a CSS file

What's the problem?
i was able to fix, my 2 brain cells forgot to add STATIC_URL = '/static/'
use flexbox:
<div class="container">
<div class="title" />
<div class="box" />
</div>
.container{
display: flex
flex-direction: row
justify-content: flex-start
}
.container div {
height: 100%
}```
just apply the same height rules for both elements if you want them to be the same height.
My website needs to use a third party API's data to display in the front end. The problem is that the API has a quota limit. If I make the requests directly, then my API key is exposed. If I wrap the API in my own, then the key is technically hidden but anyone can freely request my endpoint so it's practically the same.
How do I prevent abuser from quickly eating up my quota? How is this situation typically dealt with? Should I wrap the API and then implement rate limits on my endpoint?
I found that i missed comma in the installed apps. Thanks ❤️
Either wrap the API in your own and implement rate-limits, or setup a cron-job to periodically poll the third-party API and cache the result to all users (so each user doesn't individually have to request from the 3rd party API), but this of-course is dependent on what information the 3rd party API is returning.
Thanks. Caching is prohibited by their terms, so I suppose I'll try to do rate limits.
Perhaps it would be also possible to queue each user request to the 3rd party API. Maybe with rabbitMQ or redis? That way you're rate limiting your own server instead of each client, but that might mean that users wait longer for their first request
That's an interesting idea, and might make more sense if I expected lots of simultaneous users. But it also sounds more complicated to set up than endpoint rate limits.
Hi, someone can help with this:
I use abstractUser
and m2m to tournament
hey any flask dev i need some help
@dusk portal so what're your issues
so hey the issue is i was learning flask from last 1.5 months and then later left (Flask was my first framework ) so i faced alot of issues now im learning django from last 15 days but somehow my mind says plz cover topics u left in flask so plz can u help me cover those so im starting to ask @red palm
ok, you can start ask
so first i will tell something will tell things idk so tell me as per that ik to connect db make db link form stuff jinja inheritance linking from mail and stuffs like login panels and all , so 1st question how can i use my react file as template 2nd question how can i make a signup backend ik it sounds simple but the thing is ik we have to take input as single form and then get it to db but the problem is it will be stored as simple text then how user can use it to login ;-; 3rd how can i write backend of search bar ;-;-; 4th how can i write backend of forgot password to reactive
and 5th yes how can i take donations by patroen paytm paypal ;-;
and yes i dont use flask_forms i like to write html and i dont use that import models to make main application(.py) file clean if project == big i use django
r u there 🤣 @red palm
First, you can add databases with flask_sqlalchemy, here is the usage - https://pypi.org/project/Flask-SQLAlchemy/ , 2nd, how to add a login pannel is also written here - https://pypi.org/project/Flask-SQLAlchemy/ , 3rd, a search bar you can do with the requests.method [GET], 4th, you should search in your explorer the files
ik db yes
idk add a paypal link or something+
so 1st question how can i use my react file as template
😑
ik db i just wrote ik these things
ik to add login panel im asking about sign up
Add a new template with the methods POST and add them in Python the parameters to your db
Ok
hello
love u broi
i learn creating web-site in w3schools and free code camp
and
is ths web-sites good
Ok, trying Django for the first time and I can't even make migrations!
np is it ur 1st day?
Hey @surreal portal!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
File "C:\Users\User\Documents\Projects\django-next\backend\api\views.py", line 1, in <module>
from backend.api.models import Post
ModuleNotFoundError: No module named 'backend.api'
This is after executing python manage.py makemigrations
Settings go like this
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# Install `api` here
"api.apps.ApiConfig",
# Set up djangorestframework here
"rest_framework",
]
It was working fine before creating a new model
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length=50, default="")
content = models.TextField(max_length=250, null=False)
date_posted = models.DateTimeField(auto_now_add=True)
thumbs_up_number = models.IntegerField(null=False, default=0)
author = models.ForeignKey(User, on_delete=models.CASCADE)
How come it's not registered properly?
Do I have to do something else?
Ok after examining the file I really can't see where the error is
Wait do I really need api in INSTALLED_APPS
Urgh this is getting annoying. I'm commenting everything and I can't see where the problem is
Why do we need Flask?
I started learning Flask an hour ago, and haven't exactly figured out the purpose of Flask
Can't we achieve it by html and css?
Hi guys
I have a question
I'm doing this AJAX call
btnSendOrder.onclick = () => {
const request = new Request(`${URL}/set/purchases/`, {
headers: { "X-CSRFToken": csrftoken },
})
fetch(request, {
method : 'POST',
mode : 'same-origin',
body : JSON.stringify({
id_user : idUser,
phone : phoneNumber.value,
products : productsStored,
})
})
// .then(response => response.json())
.then(response => {
console.log(response)
return response.json()
})
.then(test => console.log(test))
.catch(err => console.log(err))
}
In this view of Django
def set_purchases(request):
return HttpResponse(request)
how can i access to the data what i am sending
I tried with request.POST['id_user'] for example
but it don't work
Guess i'm gonna try the djangorestframework tut before I explode
Oh good news. I knew where the bug was
Apparently my Django server """fixes""" imports I've already imported

hello
hi
DatabaseError: database disk image is malformed
Can someone give me some website feedback? Also can i post links?
My website sells stock photography where users can also sell their own images
is there any servers that spicifcially answers some of my dobuts in Django?
try request.POST.get('id_user')
Hey, I need your help /advice to resolve the Bug.
What I want to do:
If a user login in vue.domain.com then he doesn't need to login in bubble.domain.com and domain.com. Basically if user login via any subdomain.domain.com or domain.com, then he doesn't need to re-login in any of the sub-domain.
What my current approach is:
I trying to achive this by using JWT token in cookies.
so basically what I'm doing is, whenever login endpoint hit via anysubdomain.domain.com, and credentials are correct, we set cookies in response header with domain attribute.
response.set_cookie(key='refreshtoken', value=refresh_token, httponly=True, domain=".domain.com")
response.set_cookie(key='accesstoken', value=access_token, httponly=True, domain=".domain.com")
what my current hosting or setup look like:
backend (DJANGO/DRF) hosted on: api.domain.com
frontend (vue.js): vue.domain.com
frontend (bubble): bubble.domain.com
frontend (html/css/js): barehtml.domain.com
what the issue:
whenever I hit the api.domain.com/user/login via vue.domain.com with correct credentials, In response header I got the set-cookies with domain=".domain.com" but cookies aren't set on vue.domain.com or .domain.com
Backend (Django) Hosted on (api.domain.com)
Frontend(vue.js) Hosted on (vue.domain.com)
Here is the quick demo for better understanding
whenever I hit api.domain.com/user/login from api.domain.com everything work fine, cookies scope set on .domain.com
but when I hit api.domain.com/user/login from vue.domain.com then In response header I got the cookies but It is not setting up on the browser
If anyone able to help me to resolve this bug, I really really appreciate.
does anyone have experience with django + react?
Can someone please help me here?
https://stackoverflow.com/questions/67955631/how-to-django-link-url-to-decoupled-react-app
thanks!
please ping me when help!
please look into the matter guys:
I have written the code for the body of my website using {%block body} but it is not showing on my website.
should i try to make forms in forms.py whenever possible or just use html whenever possible? whats the recommended way? (context django)
for example should i be making a form in forms.py for a choicefield or include it in html directly?
does anyone know how I can get or make a custom domain?
You have to buy them from a registra
cant you get them for free?
not really
pilij help me xD
Some registras are partnered with github education so give you 1 domain of some un-popular endings for free for a year
but generally you have to pay for a domain
;-; @quick cargo @scenic pollen
ye?
^^
please dont ping people randomly
sorry will not repeat again
^^
ok sorry
done
xD
You will need to add your app1 to INSTALED_APPS in settings.py
no it was some other problem xD
im dumb
fixed it
thanks alot u r the only who u replied @west peak
xD
anyones up
name 'serializer' is not defined
code is this in drf
class DetailProduct(APIView):
"""docstring for DetailView"""
# the below function will check where the object with following primary key
def get_object(self,pk):
try:
return Product.objects.get(pk=pk) # if there is object it will get that object
except Product.DoesNotExist:
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) # if ther is not such object will send bad request
well, yeah - you didn't define serializer
i think it should import from drf
Well, you import the Serializer class from DRF, but errors is an attribute of the serializer object.
Follow the DRF docs on using serializers.
It isn't defined because you didn't create any serializer object. It's literally the same as this:
print(x) without ever specifying what x is.
ok then any solution?
And in this case there isn't even any need for a serializer, just return a message
Yeah, follow the DRF docs on serializers to understand how to use them
i have same program from member it working
Django, API, REST, Serializers
ok bro
I have no idea what that means
You could just say:
return Response(data="Product not found", status=status.HTTP_400_BAD_REQUEST)
ok i will figure it out thanks for help
Need Help
anyone's up
what does the div tag do in html(specifically)?
doesn't actually do anything but act as a division which you can use to style it with css or something
I thought I makes a new line?
Don't think so
hello
I need to create edit profile buttons which is consisting the different href
<li><a class="dropdown-item" href="{% url 'edit_prof' %}">EDIT PROFILE</a></li>
<li><a class="dropdown-item" href="{% url 'edit_prof_eng' %}">EDIT PROFILE</a></li>
If some condition then this will show up --><li><a class="dropdown-item" href="{% url 'edit_prof' %}">EDIT PROFILE</a></li>
else this will show up --> <li><a class="dropdown-item" href="{% url 'edit_prof' %}">EDIT PROFILE</a></li>
def home(request):
eng_id = Engineer.objects.get(user = request.user.id)
lab_id = Labour.objects.get(user = request.user.id)
print("ID and Username : ",lab_id.id,lab_id)
# print(eng_id)
# print("Labour {}".format(lab_id))
# print("Engineer {}".format(eng_id))
# context = {"eng_id":eng_id,'lab_id':lab_id}
return render(request, 'home.html')
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
@native tide @fast yoke Divs are containers for other elements. https://www.w3schools.com/tags/tag_div.ASP
in bootstrap how do i choose a theme like this?
