#web-development
2 messages ยท Page 112 of 1
i used it once when i was learning html since 4 years lol
Vscode is awesome for web developement
i will later also try pycharm
guys if i want to make a website and me mysel want tof code it how should i do it?
@mental prawn you wanna code a website ?
no no no
who cares. Try out what you like. If you want, get vim and learn it and install a plugin installation plugin and write a 200 line config to make it work like you want. It would work too.
i want to make a website, and i dont want to use wix or webflow or something, i want me mself to code and bring the code to life how am i suppose to do it?
just code
you need to learn frontend and backend
not by changing your editor.
frontend = html , css , js or sass
yeah learn
backend = django or flask
if u are talking about python
if u want to build using php so laravel
never heared django
if u want to build using C# so .Net
i want to build using python
@placid vale you never heard anything
@mental prawn So either choose django or flask
and i highly recommend Django
i am now days learning css
well i heard that django is a bit hard comparing with flask
i am a beginner
@placid vale Welcome ^^
everything is easy just practice!
same im a beginner on python i know a bit of if's and while's and other variables
so i want to test my knowledge on making a website
well you have a long way to go still
you need to learn oop , datastructures and algorthims
then u go for django as a backend
but u still have to learn html and css and javascript
datasturcture like panda or?
you need to learn oop , datastructures and algorthims
@late gale what are those i have heared about them are they necessary?
i think you still can make a website using python
pandas is a library
Data structures and algorthims are the way to how to solve problems
yes and there are many more library's
oh
like pd.Datastructure
noo it's a technique for problem solving
discord bots ?
yeah
you dont need python to create a discord bot
soo do i need to learn html n js to make a website or?!
any language can build a discord bot
@mental prawn html and css js are necessary yes because they are anything you see at website "FrontEnd"
buttons , texts images
all of them are frontend
designs colors
anything u see is a frotnend
unlike backend
@placid vale discord.js is nice
and they are super easy!!
agreed
and it might be too hard if u get to advanced javascript
as it says 1 + "1" = 2 and "1" + 1 = 11
something like that cant remember
dont scare me๐ซ
heh
xDD
๐ฆ
you dont need advanced javascript
just vanilla is fine
with html and css
beside ur backend framework
hmm
you can build a website without a backend but you can't build a website without a frontend
i never heard about front and backend's ๐
you have a long road to go ^^
hmm
but its nothing hard
it is hard
agreed
๐
nope it's not
soo ugh
i'm doing an api and learning typescript and angular. Never did js or web things before. It's hard enough ๐ Learning html, css, sass, js, typescript, flask, jwts, etc
theres so much stuff
still it's something ๐
any ideas how i can improve my python skills?
practice?
wdym?
idk about python ๐
@mental prawn keep making projects everytime u learn something new
like ?
u said that u learned the while loop and if statements
yes
try to create a software for someone's interview
so they can write their name their age and answer questions
@late gale nice to meet you
now i need to go for school homework ๐
and different ages means different questions
good idea ๐
@placid vale same here ^^
you have to use your best friend " Google " for basic projects
wow @late gale you know so much about programming!
that way will improve your knowledge
@placid vale same here ^^
@late gale u also school homework ๐ค ๐
well i tried making like a small project where its like an online restaurent
@placid vale I am 18 but i dont have a homework ๐
@mental prawn always go with something basic
i tried n tried but failed ๐ฆ
the issue is that when i try making some project i get confused and then get stuck and then i stop
and i recommend not to start with games start with something u have studied
so u dont lose confidence and hope
and along the way
keep going for ur next level
and i believe that u will create your dream website ^^
Thank you ๐ i appreciate it
So as i asked yesterday i had a problem with Flask, ```py
from flask import Flask, redirect, url_for, render_template
app = Flask(name, template_folder='templates')
@app.route("/")
def home():
return render_template("index.html")
if name == "main":
app.run(debug=True)
im not sure ๐
idk if these links are correct but i guess it will not be the fault for infinet loading with no errors
<link rel="stylesheet" href="{{ url_for('assets', filename='main.css') }}" />
<link rel="stylesheet" href="{{ url_for('assets', filename='responsive.css') }}" />```
Hey anyone know abt what the heck is WebRTC . I heard about the webSocket and use it to build the chat app that allow birectional connection. Is WebRTC same as WebSocket or is diffrent then what is the diffrence?
@patent thistle WebRTC means Web Realtime Comunication
@patent thistle The main difference is WebRTC uses Peer to Peer connection while Websocket uses client server connection
Morning
Hey, I want to create some kind of a counter to a model, basically every time a user clicks a button, 1 num will be added to the counter, basically like counter += 1.
How do I do that? (Django)
um let's say then whenever a user is being added to a group
Is it still possible to do that with js?
You'd just use it to interact with the backend without reloading the page
which is better and useful HTML forms or ModelForms ??
@snow sierra arent bot same
if u dont want to code and do backend u can try google forms
ahh never tried modelforms
Can you guys point me in the right direction. I want to display few items on the home page: most viewed and most recent. how do i do that?
I would check if there's a lib for that first.
Not sure, but can be implemented in an ORM probably
You can store the most frequent and recently used transactions in a separate table
Maybe do many to many relationships
@halcyon lion
i think i've done it in the past but i am a beginner with django ๐
and if i can remember correctly i had a like counter ๐
and u can just click as much as u want
Yeah that works as to the most frequent
Sort by likes
What about recently used? You may need a timestamp
oh man ๐
this is hard to learn ๐
i have never studied html, css and js
and now i have to learn all of those + django for 2 months while working 8h a day :d
Hey anyone know abt what the heck is WebRTC . I heard about the webSocket and use it to build the chat app that allow birectional connection. Is WebRTC same as WebSocket or is diffrent then what is the diffrence?
@patent thistle .
can any one tell me more descriptive i dont understand the bot answer
Anyone have experience with setting up django-sass-processor? Im dealing with old scss files being loaded and reseting the browser cache doesnt solve my issue so I'm presuming I missed something when it comes to setup
can somoeone please help me authenticated users can see other profiles but unauthenticated can't .
here is my views.py
class UserProfile(DetailView):
model = User
template_name = "users/profile.html"
context_object_name = 'user'
and the template
{% if user.is_authenticated %}
<li class="nav-item cta"><a href="{% url 'Profile' request.user.id%}" class="nav-link"><span>{{ request.user.username }}</span></a></li>
{% else %}
<li class="nav-item cta"><a href="{% url 'Contact' %}" class="nav-link"><span>Contact</span></a></li>
{% endif %}
fixed it
Good, I was just about to help
i should add
{% if request.user.is_authenticated %}
<li class="nav-item cta"><a href="{% url 'Profile' request.user.id%}" class="nav-link"><span>{{ request.user.username }}</span></a></li>
instead
i have another problem
haha
on the update profile
let me show it to you
Ok
there
here is my views.py
class UpdateProfile(LoginRequiredMixin, UpdateView):
model = Profile
template_name = "users/update_profile.html"
fields = ['user']
def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)
and here is the template
And you are getting this error when the user does not exist? Or is not authenticated?
i am getting this error whenever an authenticated user clicks on the edit button so it directs him to the update page so he can update his profile
and here is the urls.py
path('<int:pk>/profile/update',user_views.UpdateProfile.as_view(), name='Update_Profile'),
Ok, well I can tel you that error means that the field you are paso to the crispy forms filter is none. So do a print or something to ensure you have a form being passed.
nah it's working i've opened the shell and got that profile and whenever i say profile.user.username it shows that person's username
Did you spell all the fields right?
i commented all the fields except the user so i can see if its doing ok
let me show you the models.py
class Profile(models.Model):
user = models.OneToOneField(User, on_delete= models.CASCADE)
bio = models.TextField(max_length=300)
Committees = (
('IT','IT'),
('Design','Design'),
('ER','ER'),
('Design','Design'),
('Marketing','Marketing'),
('Coaching','Coaching'),
('Media','Media'),
('Branding','Branding'),
)
committee = models.CharField(choices=Committees, max_length=10, default='')
position_list = (
('Member', 'Member'),
('Head', 'Head'),
('Vice', 'Vice'),
('President', 'President'),
)
position = models.CharField(choices=position_list, max_length=10, default='Member')
awards = models.TextField(max_length=300, null= True)
experience = models.TextField(max_length=300, null=True)
achievement = models.TextField(max_length=300, null=True)
image = models.ImageField(default='default.jpg', upload_to='profile_pics')
def __str__(self):
return f'{self.user.username} Profile'
let me try to add all the fields and see if thats working
not working
Ok since it looks like you have multiple things going on in that template can you comment out all the fields but one and then check. So we can narrow the issue down to one field.
Then we can start adding them back one at a time
sure
guys i have an issue while using kivvy
ok now i commented all the fields except that
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group col-md-4 mb-0" >
{{ profile.user.image|as_crispy_field }}
</div>
And you get the error?
yes
Ok cool. Wait, thatโs not a form field. Thatโs a model field
oh ok wait
let me comment it
cool so i commented the everything and the error is gone without any model field has been showing
now i uncommented form but commenetd the model field
and it works
so the problem should be in the model fields
No
The problem is that a mode field cannot be used in a form
So itโs not the field itself
You need to make a form for it like a modelForm
Yes, because they are not formFields. Crispy forms expects a form field. All you are doing is fetching the attribute by doing profile.user.image.
Ok, so just import the form in the view. Then instantiate it inside the class and pass it to the template
ok let me try
class ProfileUpdateForm(forms.ModelForm):
Committees = (
('IT','IT'),
('Design','Design'),
('ER','ER'),
('Design','Design'),
('Marketing','Marketing'),
('Coaching','Coaching'),
('Media','Media'),
('Branding','Branding'),
)
committee = forms.ChoiceField(choices=Committees, required=False)
class Meta:
model = Profile
fields = ['bio', 'image', 'position' ,'committee', 'achievement','awards', 'experience']
here is the forms.py
i believe the fields are added right ?
or shall i add it in the class itself
Yes, is are you passing that form as profile?
yes thats it
i also want to display the email from the user from that class
class UserUpdateForm(forms.ModelForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email']
and his username
lets just focus on the profile thing
Ok could you just comment out everything in the form and replace it with {{ profile }} assuming the profile variable is the form itself
sure
I just want to make sure you are actually passing that to the template
It's not showing the form fields but it shows the <username of the person> Profile
as a text
Yep, I donโt think you are passing the form itself.
so you mean that profile isn't the form ?
its not showing the forms yes
it only shows the value
nothing appears
I found that when i removed |as_crispy_fields it doesnt show the error
but still there are no forms
Alright, I was trying to just ensure it was indeed the wrong object type by printing the class name
Yeah, I think you are not passing it the form. Post the view again please
ooh srry
No worries
class UpdateProfile(LoginRequiredMixin, UpdateView):
model = Profile
template_name = "users/update_profile.html"
fields = ['user','bio','committee','position','awards','experience','image']
def form_valid(self, form):
form.instance.author = self.request.user
return super().form_valid(form)
there
Ok, I do not think you are able to pass more than one form to UpdateView
Where on there are you specifying which forms to use?
fields
Because UpdateView creates a form for you based on the model you pass it.
Unless you tell it which for to use
i added the fields so it knows what forms to use
Ok in you template do the following please.
Remove everything in the form tag and add {{ form }}
Yeah.
Because by default it will pass the form as form.
Now un comment the first field and replace it with the following. {{ form.position|as_crispy_field }}
ok let me try
oh it's showing
but the reason is why
why profile not showing but form is
Ok let me explain
So basically by default UpdateView just takes a model and it will automatically create the form for you then pass it to the template as form. So you can access it in you template like so: {{ form }}
You can however make a custom form and tell the view to use it and also give it the name for the variable.
But it looks like You havenโt done either of those things.
ok here is another problem
i tried to view the update page from the second user but i believe that this user is not showing because the user.id is different than the profile's id not worked as the superuser which is me
it gives this error
i am really sorry for asking too many questions
let me see
i beleive the problem is here
{% if request.user.is_authenticated %}
<a href="{% url 'Update_Profile' user.id %}" class="btn btn-danger" style="position: relative; top: -50px;">Edit</a>
{%else%}
{% endif%}
Yes, user.id will correspond to whoever is logged in.
when i changed it to profile.id not worked
let me try
yea not working
let me show u ther error
Show me your urls too please
sure
path('<int:pk>/profile/',user_views.UserProfile.as_view(), name='Profile'),
path('<int:pk>/profile/update',user_views.UpdateProfile.as_view(), name='Update_Profile'),
fixed it
Why are you passing the id to begin with?
waait
Ok, how did you fix it?
i added this user.profile.id instead
as each user has profile and it gives the profile id to the url
as every user has different user id and different profile id
let me check on everything again
so we are done here
So y out got it?
yeea thank you alot
i am checking now on everything
got a problem
xDDD
lol
{{ form.user.email|as_crispy_field }} the email is not passing
everything works except the email
So remove crispy stuff see what you get
i need to add the email to the field i guess and add it to the forms.py
i got nothing
so how can i add the user's email to the field where its from different class
hey guys wanna ask about css if i can position linear gradient in background?
@late gale you would need a custom form and probably add to its save method.
@vivid canopy you can
@vivid canopy just set the background color using linear_gradient.
@vivid canopy here is a tutorial to help
https://www.youtube.com/watch?v=4kWHW7da4U8
A quick look at CSS gradients. While the basics of them are really simple, a lot of people don't know about repeating gradients, which are really easy to use and which let you do some pretty cool stuff.
#fiveminutefriday
I have a newsletter! https://www.kevinpowe...
@late gale are you using the Django default user?
nope
ty guys gonna look at it
a user i created from the form
@late gale No I mean the actual model itself
the account that i am currently logged in ?
No, Im your models. How are you defining your user class?
there
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email','password1', 'password2']
# USER UPDATE FORM!!
class UserUpdateForm(forms.ModelForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email']
i wanna get that email from that class UserUpdateForm
Ok I get that. But I think you should just have email as part of the user object. Along with the username.
Why not do that? This way you only have to worry about that one object when dealing with a users information.
elaborate please
from django.db import models
from django.contrib.auth.models import User
class Profile(models.Model):
user = models.OneToOneField(User, on_delete= models.CASCADE)
bio = models.TextField(max_length=300)
Committees = (
('IT','IT'),
('Design','Design'),
('ER','ER'),
('Design','Design'),
('Marketing','Marketing'),
('Coaching','Coaching'),
('Media','Media'),
('Branding','Branding'),
)
committee = models.CharField(choices=Committees, max_length=10, default='')
position_list = (
('Member', 'Member'),
('Head', 'Head'),
('Vice', 'Vice'),
('President', 'President'),
)
position = models.CharField(choices=position_list, max_length=10, default='Member')
awards = models.TextField(max_length=300, null= True)
experience = models.TextField(max_length=300, null=True)
achievement = models.TextField(max_length=300, null=True)
image = models.ImageField(default='default.jpg', upload_to='profile_pics')
def __str__(self):
return f'{self.user.username} Profile'
there
Can you paste bin it. Iโm on mobile and makes it easier to read a lot of code.
Thanks
One sec
Alright, yeah so you are just making a profile and having a OnetoOne relationship with profile. Now this is ok for something quick a dirty. But what you probably should be doing (specially to make your life a lot easier later) is to make a custom user model.
One that inherits from AbstractBaseUser
It sounds complicated and it really isnโt. This will allow for you to simply make one UpdateView pass it the user class(the custom one) and that is it. No need to make a form or anything.
so you mean i have to create a user custom model instead of the default one ?
but i don't want that it will change the regisration and the adminpage and everything doesn't it?
Yeah it will.
I do not think you can have two separate forms in UpdateView.
Iโm not sure though.
You can just make your own class view to handle the two different forms.
btw i believe {{form}} is not the correct method
when i say {{form.user}} it shows me the users who has a profile but what i wanted is a form that can change his username
let me see
Yea, because it will not create a second form...
Thatโs what I am trying to say.
UpdateView is for one model. To update one Model.
I think there is a multi form view class
nope there isnt
sry mb bad said question i wanted to do this gradient colors to like rotate like whole that color section
no there is not @devout coral
Alright, so make your own class to have two forms and save the results.
However, I think you are better off making a custom user.
let me see something
@late gale well good luck, message me if anything but I might not be able to respond.
Alright, also once y py solve it. Iโd like to know how you did so let me know (ping me)
thanks ^^
don't worry getting there
@devout coral hey i found that update button only works without crispy fields but i want it to work with crispy fields so i can use css and js
here is the template
idk why
like really why doesnt the button work
hello
let's talk about why is elasticsearch, (django-elasticsearch-dsl) being a PITA today
so I have a nested field on my model, which is being populated, and has it's mapping type defined
and every time the index updates, that fields gets disappeared ๐
i cant figure out why it keeps happening
@late gale manually bind it to the form. Set the id property for the form. Then set the form property for the button to the same as the formโs is
@late gale like so:
<form action=โโ id=โsomeFormโ>
<button type=โsubmitโ form=โsomeFormโ>Submit<\button>
<\form>
No, the form has an id then you set which button the submit goes to with the form property.
Sorry, on mobile. Had to edit.
still not working
Is it not submitting?
yes its not
I don't think you need to set the form attribute for the button for it to be linked to a form.
Btw what is the original problem?
the button doesnt submit
@native tide you donโt.
Just testing
@late gale try manually setting the forms action to the url.
still
@native tide that should not matter. I use POST all the time.
@late gale did you try setting the action url?
Yeah I don't see why it wouldn't be submitting.
You can see if it's making POST requests, is it?
It just did. They set the action on it and it posted. Now they are getting page not found error.
Yeah so thats not the issue
wait let me see
It was not posting before now it posted.... it was no?
@late gale did you not just get a page not found error? How did you get that without posting?
what leads you to think it's not submitting
{% extends 'base/base.html' %}
{% load crispy_forms_tags %}
{% load static %}
{% block content%}
<div class="profile-body">
<header>
<div class="container">
<div class="col mt-5">
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group col-md-4 mb-0" >
{{ form|crispy}}
</div>
<button type="submit" class="btn btn-danger ">Update</button>
</form>
</div>
</div>
</header>
</div>
{% endblock content%}
Whenever i used this the button submit
otherwise not
@late gale set the action property on the form and try it.
forms can be in the header?
@native tide the page keeps refreshed while it should redirect me to the profile page with the new updates
i did set an action and didnt
let me show you
<form method="POST" enctype="multipart/form-data" action="{% url 'Update_Profile' profile.id %}">
{% csrf_token %}
<div class="form-group col-md-4 mb-0" >
...
so when you submit that form, what is the URL it's trying to redirect to (you should see this in your logs)?
No, just look at the terminal where the server is running for the post request being sent.
well the action attribute redirects you to the specified URL when you submit the form. And as said ^ you can see where it's trying to redirect you
i did set the action to the redirected page but it shows me white screen
i believe that means that the button is not submitted
You submitted the form and it redirected you, so it did submit. You could've just checked your logs and see that it's making post requests
What are you logs showing? Where you ran python manage.py runserver
It should tell you which url it went to which can tell you which view it is trying to use
guys just listen the button submit here
{% extends 'base/base.html' %}
{% load crispy_forms_tags %}
{% load static %}
{% block content%}
<div class="profile-body">
<header>
<div class="container">
<div class="col mt-5">
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group col-md-4 mb-0" >
{{ form|crispy}}
</div>
<button type="submit" class="btn btn-danger ">Update</button>
</form>
</div>
</div>
</header>
</div>
{% endblock content%}
and it doesnt submit in my template
although there is no action
When there is no action the page will just refresh. The form will not redirect anywhere
What do you mean by "doesn't submit", what are you trying to get from the form?
it will be redirected because i used UpdateView which redirects url when u use get_absolute_url in the models.py
i am trying to make the form update the data
yo
can anyone here help with cyclical import
im very new to flask tryna make a blog
Ok so have you set up your view to handle the form data?
@upper gorge use blueprints
@late gale Could you just post the log? So we can see what view it is going to?
@upper gorge use blueprints
@native tide i do not understand blueprints, maybe i just gotta sleep on it
ok let me post the log
[07/Nov/2020 23:40:39] "POST /en/16/profile/update HTTP/1.1" 200 13427
there
the Post request
Yeah when I was learning blueprints I didn't get it either, watch some good explanatory videos on it and practice that helped me. But the blueprints do fix the cyclical imports for sure @upper gorge
So yeah, it's submitting
Yeah when I was learning blueprints I didn't get it either, watch some good explanatory videos on it and practice that helped me. But the blueprints do fix the cyclical imports for sure @upper gorge
@native tide yeah tysm
then why the data isnt saved and its not redirected
@late gale so itโs posting and returning a 200 status code. So check that view and look at what template you are trying to render.
@late gale when you submit a form, you need to handle the data in your view (that is where you will save the data). The form does not save it - it just sents data from the client to the server
but when i use this template it does redirects me and saves the form
{% extends 'base/base.html' %}
{% load crispy_forms_tags %}
{% load static %}
{% block content%}
<div class="profile-body">
<header>
<div class="container">
<div class="col mt-5">
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="form-group col-md-4 mb-0" >
{{ form|crispy}}
</div>
<button type="submit" class="btn btn-danger ">Update</button>
</form>
</div>
</div>
</header>
</div>
{% endblock content%}
@late gale wait... you form is rendering properly? You are including crispy form tags but using a crispy filter that does not exist. The syntax should look like the following:
{% crispy form %}
it doesnt show probably
@late gale ? What does not show?
wait
the button is not clickable now and the page doesnt refresh
wait
oh yes the button isnt
The button is not what?
submitting
and the page isnt refreshing
it just clickable
even i added an action and still
But the form is there right?
yes
And when you click the button nothing shows up in the logs right?
So now try doing the id thing I mentioned earlier and see if it posts.
ok
By see if it posts I mean look at the logs to see if anything shows
it worked great but why it doesnt work on the crispy fields
when i used {{form.bio|as_crispy_field}} the button wasn't working
i wanted to adjust every field
Idk. Now go through and try it.
but it's fine the crispy form looks nice
And add one field at a time this time
ok let me try the field
Maybe a field you are passing there is something wrong with it idk.
maybe
let me see
it doesnt although every form is showing
but its fine
the crispy form looks nice
yea thank you @devout coral
and thank you alot @native tide
I am one of the homies
hahaha
Here is a website i have deployed that uses google auth from a tutorial i followed. It works on local host, but has an issue when i deployed the app to heroku
2020-11-07T22:59:02.874765+00:00 app[web.1]: oauthlib.oauth2.rfc6749.errors.InvalidClientError: (invalid_client) Unauthorized
That is the error i am getting on my heroku logs
It was a typo 
as are so many bugs
I can't seem to link my css stylesheet to my React application. Must I use webpack for this?
https://plotly.com/python/v3/html-reports/
Does anyone know of a more up to date stack for generating static html reports, with graphs and stuff? This guide uses python2 so seems kind of out of date, and I'm not really familiar with the area.
Anyone know if you can deploy a python app on Cpanel with bluehost?
Im having some troubles
Hello
I used bluehost for WordPress
Not sure
I didn't host on aws or azure for example because WordPress recommended them as the number 1 hosting for their CMS
Do you have a recommendation for deploying a Django app
Docker
Put it into a docker container and deploy
I think I have tutorial saved, brb
Take your pick. There are plenty of tutorials online
Are you only able to host a Django app on a VPS server? not shared.
Anyone recommend a good resource for learning/setting up a user account system in flask?
Flask tutorial by corry schafer might work.
Is the stuff like tax percentage stored in the db ? it's a single value (ex 2%) ? a non developer should be able to change the value from an interface such as django admin app
I am not understanding the css transition property . Can any one help me to understand it?
can someone explain how to create a login system with flask?
I made this using django rest frame work
I will be sharing my git repo in a while, need to clean it up a bit
Any tips on how to homehosy django websites? Windows
Get a fast internet,
A kick ass router
Watch a youtube video on how to open your comouters port through your router
It'll be unsafe if there's any valuable data on your system.
You done.
@toxic flame
anyone knows a doc where I can find a list of these?
class="btn btn-secondary btn-sm mt-2 mb-2"
hey guys wanna ask what should i have wrong. when i write in cmd python main.py error says there is something wrong with line 32 wich is login line line...for me it looks like login def doesnt take LoginForm but i m not sure
Guys I need your help, here's how the bedrooms field looks on the home page https://gyazo.com/e24d0697d0353abde965324af88ae6f0
and here's how it looks on the form_detail page https://gyazo.com/e87c405488d2bfa0587a27f9344140a3
the code is exactly the same
share us ur code
{% extends "blog/base.html" %}
{% block content %}
<article class="media content-section">
<img class="rounded-circle article-img" src="{{ object.author.profile.image.url }}">
<div class="media-body">
<div class="article-metadata">
<a class="mr-2" href="#">{{ object.author }}</a>
<small class="text-muted">{{ object.date_posted|date:"F d ,Y" }}</small>
{% if object.author == user %}
<div>
<a class="btn btn-secondary btn-sm mt-1 mb-1" href="{% url 'post-update' object.id %}">Update</a>
<a class="btn btn-danger btn-sm mt-1 mb-1" href="{% url 'post-delete' object.id %}">Delete</a>
</div>
{% endif %}
</div>
<h2 class="article-title"> {{ object.title }}</h2>
<p class="article-content">{{ object.content }}</p>
<a class="btn btn-light btn-sm mt-1 mb-1">{{ object.bedrooms }}</a>
</div>
</article>
{% endblock content %}
the form_detail page
{% extends "blog/base.html" %}
{% block content %}
{% for post in posts %}
<article class="media content-section">
<img class="rounded-circle article-img" src="{{ post.author.profile.image.url }}">
<div class="media-body">
<div class="article-metadata">
<a class="mr-2" href="#">{{ post.author }}</a>
<small class="text-muted">{{ post.date_posted|date:"F d ,Y" }}</small>
</div>
<h2><a class="article-title" href="{% url 'post-detail' post.id %}">{{ post.title }}</a></h2>
<p class="article-content">{{ post.content }}</p>
<p class="btn btn-light btn-sm mt-1 mb-1">{{ object.bedrooms }}</p>
</div>
</article>
{% endfor %}
{% endblock content %}
the home page
I just changed the <a> to <p> so no worries
I just changed the <a> to <p> so no worries
@vernal furnace solved?
no
I FIXED IT!
The problem was object.bedrooms, object.bedrooms was a class that only worked for certain forms, it wasn't supposed to work on home.html, so the solution was post.bedrooms
anyone knows how to add that line?https://gyazo.com/4427481cac46352c4d9e7ae1839d9234
nvm
<hr>
Guys
i need helo
help*
someone can help me ??
i get this error
init() takes 1 positional argument but 3 were given
init has underscore
Can you send the whole error (with traceback)?
I downloaded open iconic from bootstrap
anyone knows how to use it/download it to my project?
should i send a query string or json with PATCH request?
can i set the target attribute of a form button to a value so that submiting the form will not change the window
so that i can send a POST request to say website/api and stay on website/index
where does my django project saved in windows?
also How do I move the folder to docs by which all my projects will save in docs
If I make a POST request to submit HTML to my database, will it be saved as HTML or as plain text?
@coral wind yeah you can do that, it's easy to do with JS
do any of you guys know how to change the location where my django projects are saved in windows?
hey guys wanna ask what he did in the cmd at 16:10 like how did he get that long path https://www.youtube.com/watch?v=8aTnmsDMldY&ab_channel=PrettyPrinted
In this video, I show you a more realistic example of how to use Flask-Login, Flask-WTForms, Flask-SQLAlchemy, and Flask-Bootstrap to build a registration and login system for users of your Flask app.
This is something that is very common to web apps, so if you need to know h...
what long path @vivid canopy
like what he did there bcs when ctl+c to stop runing local host
and write sqlite3 database.db
""" 'sqlite3' is not recognized as an internal or external command,
operable program or batch file. """
this is what i get
i m right now looking for instalation it but idk if it will work
@native tide if u understand what i mean
ValueError: malformed url rule: '/stats/<string:date:>/<string:tier>-1500'
trying to use flask to setup an api, and im getting this error. this is the line where I add the resource:
api.add_resource(Stats, "/stats/<string:date:>/<string:tier>-1500")
why am I getting this error?
@severe venture I donโt use Flask but you use the word string to signify you need a string? As opposed to str.
yes, its the whole word
Lol no worries. Glad I could help
sry for spaming but how is supposed to look this uri?
Hey
Anyone onine?
Can anyone help me
I am facing issue in getting in ssl certificate
for the website
Yes sir
Have you tried cloudflare ?
They provide free
and easy to setup
ssl protection
@west hollow
guys does have i writed wrong SQL URI ?
well i said it first
๐
Hello everyone
Good morning (where I am)
good morning
Yโall currently working on some Web Dev projects?
always
yes
@vapid fox that moment when i cant figure it out for 2 hours and seen just missing ' ....ah it feels like to go trough mi heart with knife
hahaha
you do get used to the error messages.
in this isntances it is telling you that it
What projects are you guys working on? If you donโt mind me asking?
read the end of file
without being able to finish reading the string
( i.e. didn't find the end of the string )
@devout coral I am working on building
an appstore
for emacs
anyway ty ....now i know and will know to future for long time D
Tweaking some stuff on warcache.com a little wargaming site I built a while ago. Also turning its Flask skeleton into a cookie-cutter template.
Nice nice
wbu?
This second I donโt have access to my computer so im a bit bored. But I am working on a web app. Currently working on getting it all into docker to increase productivity and help during deployment.
What is the web app about?
hi
i accidently deleted a postgresql table created by django
how to fix the issue ?
fixed it
fixed it
@native tide I wanna know how.
I have asked a question in #help-broccoli, about Django and React integration, I get unexpected 404 error, if you wanna help please see the question in channel for more details
I need ideas to make flask projects. Any ideas?
try replicating things like Reddit or Twitter
used magic powder Spโrtn
#4575
this line gives me this error why??
return reverse('Profile', kwargs={"pk": request.user.id })
oh fixed it
thanks
can you guys think of a reason why css wont load on the new page when i use extend? I tried to copy/paste the whole html code and still its not loading the css on the new page
cache
@halcyon lion CTRL + F5 in the browser
๐
uhmm, ok. That is something that a lot of people stumble upon, so what is your issue?
It's just baffling how the same html copied on another html file is not working
So I wanted to extend the page using header and footer from base page and get a register form in the middle
I loaded static
I did everything and it doesn't load any css for the base.html
Any recommendations on how to write the front end for a tornado service that is controlling a piece of hardware? I've cobbled together a working HTML/websocket implementation, but it is pretty rough, and would like it to be a bit more uniform and easier to change.
@halcyon lion So, anything in the browser console? Like maybe a 404 for the css file? Check the path, maybe something isn't as you think it is.
can someone help me with web scraping
i wanna take the highlighted value and assign it to a variable
how do I do that
im pretty new to python, like 1 or 2 weeks but i need this for a project in my comp tech course
Can someone please tell me if this is incorrect? At least if i do use that validate request function, the request fails even from Twilio.
from django.core.exceptions import SuspiciousOperation
from django.http import HttpRequest, HttpResponse
from django.conf import settings
from django.utils import timezone
from django.shortcuts import reverse
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from twilio.request_validator import RequestValidator
from twilio.twiml.voice_response import VoiceResponse
from .settings import twilio_auth_token
import arrow
request_validator = RequestValidator(twilio_auth_token)
def validate_django_request(request: HttpRequest):
try:
signature = request.META['HTTP_X_TWILIO_SIGNATURE']
except KeyError:
is_valid_twilio_request = False
else:
is_valid_twilio_request = request_validator.validate(
signature=signature,
uri=request.get_raw_uri(),
params=request.POST,
)
if not is_valid_twilio_request:
# Invalid request from Twilio
raise SuspiciousOperation()
can i do conditionals using flask-wtf/wtforms?
like if i have a survey, ive only seen the form class defined as a set of variables, but can i do like "conditional values" for my form traits
like if input = yes, class has variable Y
or should that be handled in my view function?
@app.errorhandlder(404)
AttributeError: 'Flask' object has no attribute 'errorhandlder'```
why is this happening?
so confused
I'm trying to deploy flask on namecheap,
currently I set the logfile location like this:
logfile = os.path.join(os.path.dirname(__file__), "app.log")
print(logfile)
if not os.path.isfile(logfile):
with open(logfile, "w+") as f:
pass
logging.basicConfig(level=logging.DEBUG, filename = logfile)
t = time.ctime()
app.logger.info(f"Started at {t}")
however when I do this the file remains empty even though it is properly created. any ideas?
(btw it works locally)
also everything else works fine like file serving / content generation
w+ means create a new file every time its launched
so it might just be getting wiped out
is that all of the relevant logging code?
yes but the new file only gets created if it doesn't already exist
even when just that logging code runs it should have the "started at" entry
Why not โaโ instead of โw+โ?
What python version are you running on namecheap?
Needs to be 3.6+
yo im having a problem with selenium (python,windows 10): so this is an element that im using in my code:
'//*[@id="itemCardmarket_0"]/text()' and there is text embedded within the element but since it has that "text()" end part i cant print the text thats in the element, so how would i change it to where i can print the text of my element even with the "text()" thing at the end?
can I use flask to hook my code with a website
ok ty
or is there any way to do that?
thanks
can I use flask to hook my code with a website
@native tide what do you mean
yeah that's basically what Flask does
when the user visits a URL
it triggers a function
in your Flask app
From
top.gg
If someone clicks on a button it
print("hi you clicked on the buttor on the website called top.gg)
the already built websites
Or taking pictures from reddit
i want to center my couresel but i cant ??
i want to center my couresel but i cant ??
@strong umbra What have you tried to center it?
@strong umbra I mean what didn't work?
Can anyone recommend a good YouTube series to learn the basics of creating a web application from scratch
Can anyone recommend a good YouTube series to learn the basics of creating a web application from scratch
@torpid pecan Which framework do you wanna learn?
@nova nacelle Django
@torpid pecan https://youtu.be/OTmQOjsl0eg this is where i started Django
Python tutorial : https://www.youtube.com/watch?v=YfO28Ihehbk
- What is Django? โ 00:05
- Django Setup โ 05:05
- First App in Django (Part-1) โ 16:03
- First App in Django (Part-2) โ 24:21
- Django Template Language (DTL) (Part-1) โ 31:57
- Django Template Language (DT...
Awesome thank you
hello
So I am using Django forms alongside Html
when validation if the form isnt valid then all the content of the form is reset
this is what I have like the error is issued but then the content previously entered is reset
how to prevent this?
pls ping me when help
thanks!
def register(request):
if request.method == 'POST':
register_form = RegisterForm(request.POST)
if register_form.is_valid():
register_form.save()
# redirect to homepage after registration
else:
pass
else:
register_form = RegisterForm()
return render(request, 'register.html', {'form': register_form})```
this is how I check for errors and validate the form
anyone there??
I have a VSCode โtaskโ that create a Django project for me. BUT, how do I add a choice to enter in what to name the project? So: && input=โ name here โ? How do I add a โquestionโ of what name I want to give it?
Hi, I am getting the following error:
This typically means that you attempted to use functionality that needed
an active HTTP request. Consult the documentation on testing for
information about how to avoid this problem.
def paid_redirect(f):
@wraps(f)
def decorated_function(*args, **kwargs):
user = User.get_from_cookies()
key = Key.get(user.key)
if key.is_active():
return redirect('/dashboard')
return f(*args, **kwargs)
return decorated_function()
@classmethod
def get_from_cookies(cls):
user_data = Authentication.get_cookie_data('user_d')
if not user_data:
return None
if 'discord_id' in user_data.keys():
user = User.get(discord_id=int(user_data['discord_id']))
if user:
return user
return None
@classmethod
def get(cls, key_value: str):
key = Key.query.filter_by(value=key_value).first()
return key
def is_active(self):
return True
@classmethod
def get_cookie_data(cls, name: str = None):
if not name:
raise Exception('NoneType: invalid cookie name "None"')
token = request.cookies.get(name)
return Authentication.decode_jwt(token)
@classmethod
def decode_jwt(cls, token: str = None):
if not token:
raise Exception('NoneType: a token has not been passed')
token = str(token)
data = jwt.decode(token, Authentication.__readfile__('./assets/keys/jwt-key.pub'))
return data.decode('utf-8')
I hope anyone can help me ๐
Any ideas why subprocess doesn't work inside uWSGI?
@twilit needle if the form does not send render it again with request.POST
Is it possible to run an Aiohttp websocket on a flask app? And if so, how? @ me when responding please.
@rapid bramble probably cuz uwsgi is not allowing child processes in order to ensure process management
@topaz finch is it possible? Yes, should you do it -> Fuck no
Hmm I see, nvm I switched to gunicorn and did a bit of code tweak
Works perfectly now ๐
@topaz finch is it possible? Yes, should you do it -> Fuck no
@quick cargo why would you recommend not doing it?
because you're mixing a Sync framework with a async system
Refused to apply style from 'http://127.0.0.1:8000/register/static/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
help ๐
give me some ideas for django ..
ecommerce
@quick cargo so my websocket server is going to be connected to a client application. The intention is essentially to make interaction quicker. Currently, the flask app would have to make http requests to the websocket server to receive info from the other app, and to give it info. If I connected the flask app as well, it would essentially just be to receive some basic data from the other application, and to send info to the other app, in a way that wouldnt involve http requests. Essentially, just replacing http requests w/ websocket requests. I can do either, just thinking that having both ends connected to websocket server would be nice. How would I go about doing it either way, can you point me in the direction so that I can do more research on this as well?
@ me when responding, and thank you for your time and feedback.
then rewrite it in async using a async lib. Flask is slow same with Django no way to get around that. @topaz finch
That would not be a small process ๐
how hard would conversion be? This is not a small app.
It will take time
It will mostly be replacing decorators and things, but some core processes are done differently since it is async
What app are you building?
What types of speed increases are we talking about here? I will look into a full replacement, but if not, I may at least replace my API with async webapp.
I am not sure wha toyu want to do
Are you looking to communicate between 2 webservers?
web dev meme
@rustic pebble No, flask web server an an async bot application.
yes
Haha
You can do the following:
Run the bot and an async quart server on the same loop, that way you can communicate with the flask server with no problem
and its really easy as well
loop = asyncio.get_event_loop()
loop.create_task(client.start('token_here'))
app.run(loop=loop, port=3000, host='0.0.0.0')
That simple ^^
Then divide the client and the app into different folders and work on them independently
That way you can have a setup like this:
I am admittedly new to the world of asyncio and aiohttp. So far I have been using an.. unconventional and bootleg way for website -> bot communication, which is why I am making this websocket. Even the current way will vastly improve communication, but just checking if there is anything else I should do.
Well wouldnt that still involve http requests?
I dont really. Http requests to communicate w/ my bot are way better than my last method
right
can someone help me out with web requests
i wanna get info from bazaartracker.com and use the values for a, b, and c variables but idk how to
choice = str(input("What Minion do you wish to calculate the price of? >>> "))
if choice == "wheat":
a = float(input("What is the price of wheat? > "))
b = float(input("What is the price of hay bale? > "))
c = float(input("What is the price of enchanted haybale? > "))
I am not really sure of the size of your project
But I have done some pretty big projects usingt hat method
dont run a bot and a webserver in the same process ๐ฉ
Ill look into quart, because you are right in that it looks VERY similar to Flask, and your method certainly has merit. If I had known about it in first place I probably would have started there, but I also already have the websocket server and client partially set up and tested, so it just depends. I sincerely appreciate your time on this, and all the feedback, it has been enlightening. I think I will replace at least some of my current flask app w/ Quart, because just from basic lookup it seems like itll be faster.
Quart is litterally a drop in replacement other than the async await keywords
but yeah
dont run a bot and a webserver in the same process ๐ฉ
I used to to think that as well
But for like
really simple http requests you can use it
but by that point its easier to just run it seperately
Although you can tap directly into discord and not use the http thing
and use a gateway or smth
No, its not easier
Trust me
Its a 3 line thing
loop = asyncio.get_event_loop() loop.create_task(client.start('token_here')) app.run(loop=loop, port=3000, host='0.0.0.0')That simple ^^
ik it is but it doesnt mean you should ๐ฉ
Well my current websocket system allows for my flask app to easily make requests for information and such from the bot, and serve them very quickly in the same http request. I have a framework partially set up for events from flask to my bot as well, so I think I am going to continue on that.
@topaz finch You know you can tap directly into discord api rgiht?
Thats what the bot does anyway
yes
you looked at https://github.com/Ext-Creators/discord-ext-ipc
๐ An IPC extension allowing for the communication between a discord.py bot and an asynchronous web-framework (i.e. Quart or aiohttp.web) - Ext-Creators/discord-ext-ipc
and also yeah what kiwi said
I am aware that discord.py makes its own websocket connection, have done a lot of browsing through it while ive been going through this process.
Take some time reading the docs
thats not the same as what i just linked btw
You can also do it through http
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
A discord bot using http requests
No
meanwhile im sat here with a custom gateway ๐ Website and Bot bot seeing the same thing
aka what patreon do to add roles to people
the discord http api isnt as powerful as gateway tho from what ive seen. Not as many options. But I dont know why I have not considered directly tapping into the gateway from the flask app itself tbh. THough either way I still need the bot and website to communicate, as the website serves as a basic dashboard for server owners as well, so I need to send those settings to the bot itself.
the discord http api
@rustic pebble ik because I already use the http api for discord
is what the discord.py wrapper uses
the majority of the discord api is via HTTP
only events are via WS because they have to be
true
right
balancing WS are way hard to manage than HTTP which is why the majority of stuff is done with HTTP where they can
true.
Because websockets are a lot, lot lower level than http reqs
You can make an http request with a websocket
websockets are http requests
just with a upgraded connection to keep the socket alive
not really
fuck that, websockets suck, only for live chat
um they can definitely be helpful in many situations tho
websockets technically after they've been established require alot less than http requests which is why theyre generally quicker
Yes
I have never really ever needed websockets too much, I have done huge projects and none of them explicitly required websockets, although in some cases for UX websockets were better

Ill definitely do more research based on everything you guys have mentioned, I appreciate the advice
np
Hi, I have some miscellaneous questions about production file uploads that I haven't been able to find an answer for.
Say you have a form with 2 inputs. One takes an image that is less than 1MiB and a video that is less than 250MiB.
- Should I use client side validation to confirm the file sizes, server size validation of the file sizes, and also set the endpoint max upload size in the webserver configuration to say 252MiB?
I want the image to be 1920x1080 or smaller. I could do client side validation on the resolution, accept the file upload, if it passes the webserver file size check, check the resolution, then return an error if the image is larger than this limit, but I want to allow the user to upload a larger image, and have the web app handle shrinking it.
- How do I ensure that after the resize operation, the resulting file is under 1MiB?
- How should I determine the max dimension for me to try resizing? If the user tries to resize a 10000x10000 image that is under 1MiB (like an all-white PNG), my server will run out of memory.
- How do I account for the possability that multiple users could trigger image resizes at the same time, using up a lot of memory? Do I need to queue these operations somehow?
For the video, I want to be able to serve the uploaded video to other users and have them be able to play it correctly. I can validate the size and extension, but there is a lot of weird codecs/tracks/pixel formats that you can put into .mp4 files that will make the video not play correctly on almost any device
- Do you pretty much always need to re-encode user-uploaded videos?
- How do I make sure that the video will not cause memory issues when I try to resize it?
- How do I account for the possability that multiple users could trigger video re-encodes at the same time, using up a lot of memory? Do I need to queue these operations somehow?
These all seem like issues that sites like Facebook/Instagram/Twitter would all need to be dealing with, but I can't find answers to these question online. Any ideas or resource recommendations? Thanks
With the image resizing, is that something that should be done client-side instead?
- Should I use client side validation to confirm the file sizes, server size validation of the file sizes, and also set the endpoint max upload size in the webserver configuration to say 252MiB?
No, do it server-side, you can pass the metadata if you don't want the user to upload the file to your server since that would increase workload, on the other hand best bet for 100% security that no one is going to upload a 5gb file is that you let them upload it first, analyze it in the server and then come back with a reply, either the file is valid meaning it doesn't exceed your limits or the file is invalid.
- How do I ensure that after the resize operation, the resulting file is under 1MiB?
There are modules out there that can compress images to the exact filesize you want, I am missing the names right now but you can find them with one google search for sure
How should I determine the max dimension for me to try resizing? If the user tries to resize a 10000x10000 image that is under 1MiB (like an all-white PNG), my server will run out of memory.
Same way you would do with the file size validation, let him upload it and check it server-side.
You could perform a client-side check but be sure that it can be tampered with
- How do I account for the possability that multiple users could trigger image resizes at the same time, using up a lot of memory? Do I need to queue these operations somehow?
You need to create a queue, most webserver frameworks try to stack the requests resulting in a memory overflow thus possibly crashing the server
- How do I make sure that the video will not cause memory issues when I try to resize it?
You need to set some limits, you can easily calculate the size of the video and then act accordingly
- How do I account for the possability that multiple users could trigger video re-encodes at the same time, using up a lot of memory? Do I need to queue these operations somehow?
Same answer as earlier
@lofty matrix
Thanks @rustic pebble
No, do it server-side, you can pass the metadata if you don't want the user to upload the file to your server since that would increase workload, on the other hand best bet for 100% security that no one is going to upload a 5gb file is that you let them upload it first, analyze it in the server and then come back with a reply, either the file is valid meaning it doesn't exceed your limits or the file is invalid.
My thought around client size + server application side + webserver side size validation is
client side: Instantly gives error if invalid file is uploaded
server application side: If a user is bypassing the client side validation, this would catch, say, a 100MiB image and a 100MiB video upload attempt
webserver side: Avoids hanging the web application in cases where there is no way the content is valid.
Am I thinking of something wrong here?
You need to create a queue, most webserver frameworks try to stack the requests resulting in a memory overflow thus possibly crashing the server
The queue could be full of other work for the next 10 minutes. Do I need to design the application such that this can be done outside of the request-response cycle? (Add the image job the the queue, return a response to the user that says "your image is being processed. Check back later", and eventually have the image resized once it goes through the queue?
I wouldnt rely on the front end / client validating size
because you can easily get around that
and just bypass it by hitting the server directly
what you should do is stream the body not read it all at once checking the content-length header if applicable or if it's a chunked encoding method check the chunk size first to make sure it doesnt go over the limit
I see these images all the time. Do they have a name?
I would like to buy some SVG/PNG versions of these for my website but I don't know what to google....
stock images
@raw imp those images are from undraw
or something like that
I see them everywhere and it infuriates me
you can tell where the image is from... ๐ข ๐ข
You can buy the image if you don't want the watermark
they don't have any watermarks (at least for the ones from undraw). maybe it's just a personal vendetta but I dislike their style
@native tide undraw yes
Can someone take a look at my urls in django? When a user is being saved as a foreign key and called on, they are saved as http://127.0.0.1:8000/users/logout/3/ rather than just the username
hey guys wanna do background something like this in video https://www.youtube.com/watch?v=DlUV97e51uc&t=47s&ab_channel=Divinector and have got this (at pic ) any other tuts for some background as is in video?
Very Easy and Simple way to create Skewed / Slanted / razor blade div shape using only HTML and CSS
Follow this Channel on:
Facebook : https://www.facebook.com/Divinector/
Twitter : https://twitter.com/Divinector
Instagr...
I need to make an API for a web application that will create rooms for multiple users to participate and it will communicate with the clients
There would be any notable performance differences between using Flask or Sanic?
@plucky tapir Ok, can you paste a code snippet?
models.py https://pastebin.com/WqxfBMZA
users/urls.py https://dpaste.org/1Czd
main/urls.py https://dpaste.org/XCZJ
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
@native tide
If there is more needed just let me know
so what is the issue again?
In the url and the django rest api framework pull, the foreign key comes out as an url rather than just the username "bname": "Spotify", "bamount": "10.00", "duedate": "2020-10-20", "user_id": "http://127.0.0.1:8000/users/logout/3/"
@native tide but in the database I believe it comes out as the username, or at least the user's ID. Here the 3 is the user ID
@plucky tapir show serializer
@vestal hound https://dpaste.org/nYWH
@plucky tapir HyperlinkedModelSerializer
that does exactly what it says it does
Django, API, REST, Serializers
The
HyperlinkedModelSerializerclass is similar to theModelSerializerclass except that it uses hyperlinks to represent relationships, rather than primary keys.
(emphasis mine)
@vestal hound Ohh I see, is using hyperlink good practice for django? Also any idea why logout would be in the url anyway? It should function as the 'logout', not sure why its appearing there
@vestal hound Ohh I see, is using hyperlink good practice for django? Also any idea why logout would be in the url anyway? It should function as the 'logout', not sure why its appearing there
@plucky tapir depends on what you're doing
my API just returns PKs
or nested representations where appropriate
for your second question
look into the documentation of the hyperlink related fields
hello i am new to web-developement........and i have chosen flask library for a startup......and i always connect it to the localhost to run it......but is there a way to run the website in a complete url.....something like www.webpage/home/................can u do that in flask ???
You can yes. Once you get to deployment you will want to learn how to do it.
how to do that
Hi, I am using FastAPI to create an API. I have a requirement I have to generate an xlsx file and then send an email containing the generated xlsx file download link which can be used to download that file. How can I provide a download link? FileRespose provides a file object what I want is to provide a download link. Any help will be appreciated.
@vagrant oasis It is probably best to look for a tutorial
oh tnx i am deploying on heroku.......is that good
this thing is annoythin me a lot on django
so basically I want to login a user on django like this py def login_request(request): if request.method == 'POST': data = request.POST auth_backend = AuthenticationBackend() login_form = LoginForm(data) if login_form.is_valid(): user = auth_backend.authenticate(data, password=data['password'], email=data['email']) if user: login(data, user) # redirect to homepage else: login_form.add_error('password', "Password doesn't match email") else: data = {} login_form = LoginForm() return render(request, 'login.html', {'form': login_form, 'data': data})
however, I get this error that py 'QueryDict' object has no attribute 'session'
How can I fix this? pls help me. It would mean a lot
thanks!
login(data, user)```
this is the line causing errors
pls someone help me
I've asked my question there, too. If someone can help please let them know!!
pls I have spent a lot of time on this a solution will really really help me a lot. Please ping me when help
Hello, how should I connect this to my host?
I have never worked flask and I do not know how to connect this to my host.
I'm wandering around building a web dashboard and have no information
Please help me
https://stackoverflow.com/questions/64766945/querydict-object-has-no-attribute-session-django
@twilit needle is it solved?
pls somebody help me
hey, how can i use django to create a socket server that could be able to call procedures on a client from the server ?
it has to be launched on init, so when i just add a server like this one : https://pypi.org/project/aiohttp-json-rpc/ in the __init__.py
it starts the RPC server, and block django, not allowing the HTTP server to start
import requests
from bs4 import BeautifulSoup
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36'}
page = requests.get("https://bazaartracker.com/product/hay_bale/", headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.find(id='buyprice').text)
someone help me out
so basically
i use this to find the price of smthng
and the output is --- instead of the price
now sure how to fix it pls help me out
I have never used == $0 before. What does it mean?
in html
is that a media query?
I didn't know BeautifulSoup could get DOM elements. I have to look into it.
no one has an answer I suppose
nope
import requests
from bs4 import BeautifulSoup
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36'}
page = requests.get("https://bazaartracker.com/product/hay_bale/", headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.find(id='buyprice').text)
@rare zinc do
one seccond
do
I have heard of beautifulSoup, and that's the one I want to use along with one other framework
what's the other one that goes with that one to use for webscraping?
it still shows ---
import requests
from bs4 import BeautifulSoup
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36'}
page = requests.get("https://bazaartracker.com/product/hay_bale/", headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.findAll("h2", "class":"buyprice"))
like this?
@rare zinc do you use something like this? https://www.pythonforbeginners.com/python-on-the-web/web-scraping-with-beautifulsoup
Web Scraping โWeb scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites.โ HTML parsing is easy in Python, especially with help of the BeautifulSoup library. In this post we will scrape a website (our own) to e...
output is none
import requests
from bs4 import BeautifulSoup
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36'}
page = requests.get("https://bazaartracker.com/product/hay_bale/", headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.find("h2", {"class":"buyprice"}))
@native tide
let me check one sec
@rare zinc wait sorry I was doing the wrong thing
import requests
from bs4 import BeautifulSoup
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36'}
page = requests.get("https://bazaartracker.com/product/hay_bale/")
soup = BeautifulSoup(page.content, 'html.parser')
print(soup.find("h2", {"id":"buyprice"}))
now
you just gotta add.text
or wait
๐ค
I can't find it
maybe because the == $0 think
@rare zinc
i think that's a placeholder for input.
maybe instead of reading to it you should be writing to it.
I found this
so we gotta get the json not the html ig
I've never ran into this before so idrk
Django for making a calendar of you upcoming bills what would you guys suggest?
Hey yo guys! i am 15 and i have the basics of programming and fundamentals ready. I want to know which is the best free way to get started and learn web dev
I am trying to use flask to make an API. It works and can get data from my db (only does GET), but it returns a list of dicts (which I suppose is correct behavior). I want it to return a dict of dicts (or a json of jsons) because i plan to use it for a js app. I want to set the name of each dict to be equal to a field value from the pull.
I start with
[
{'id_': 669551, 'rank': 153, 'pokemon': 'snorunt', 'usage_pct': 0.07347, 'raw_usage': 104, 'raw_pct': 0.127, 'real': 96, 'real_pct': 0.148, 'dex': 361, 'date': '2020-04', 'tier': 'gen8lc-1500'},
{'id_': 669552, 'rank': 154, 'pokemon': 'milcery', 'usage_pct': 0.0672, 'raw_usage': 108, 'raw_pct': 0.131, 'real': 87, 'real_pct': 0.134, 'dex': 868, 'date': '2020-04', 'tier': 'gen8lc-1500'},
{'id_': 669553, 'rank': 156, 'pokemon': 'cosmog', 'usage_pct': 0.0199, 'raw_usage': 26, 'raw_pct': 0.032, 'real': 19, 'real_pct': 0.029, 'dex': 789, 'date': '2020-04', 'tier': 'gen8lc-1500'}
]
and want to get to:
[
'snorunt': {'id_': 669551, 'rank': 153, 'pokemon': 'snorunt', 'usage_pct': 0.07347, 'raw_usage': 104, 'raw_pct': 0.127, 'real': 96, 'real_pct': 0.148, 'dex': 361, 'date': '2020-04', 'tier': 'gen8lc-1500'},
'milcery': {'id_': 669552, 'rank': 154, 'pokemon': 'milcery', 'usage_pct': 0.0672, 'raw_usage': 108, 'raw_pct': 0.131, 'real': 87, 'real_pct': 0.134, 'dex': 868, 'date': '2020-04', 'tier': 'gen8lc-1500'},
'cosmog': {'id_': 669553, 'rank': 156, 'pokemon': 'cosmog', 'usage_pct': 0.0199, 'raw_usage': 26, 'raw_pct': 0.032, 'real': 19, 'real_pct': 0.029, 'dex': 789, 'date': '2020-04', 'tier': 'gen8lc-1500'}
]
is there a way to do this natively in flask or will i just have to python it away? (it's not that difficult but, less work is less work)
oof sorry for the big post
start coding
there's loads of free tutorials just google CRUD tutorial and go from there
pick one of django or flask (or probably some others) but those are the two most popular
thank you so much!!!!
flask is pretty simple, django can get in the weeds fast