#web-development
2 messages · Page 51 of 1
That's the gameplan (connecting them with other data as well)
Right, need any other help with that?
Let me see if this save works, I would be curious to see how you would do it but I feel confident in doing that if this save works
Sure.
saved, but pic didn't show up let me check something else
I think it is something with upload_to='/images'
The obj points to the /images but I didn't have image in there
So I need to just put all my images in there
Where is upload_to? Is that in the ImageField definition in the model?
Surely you can simply change that?
image = models.ImageField(upload_to='images/')
Why isn't it media/?
Or is media reserved for the site images? I can't remember the distinction, exactly.
No good reason, just trying to get this workign following an array of tutorials online
I guess I need to change my template now to fit media
but I keep running into that same problem!
when I save it prefixes the url with media
and then the file path of image
image at /home/name/project/site/media/image.jpg
I set the newbook.image = path
when I type newbook.image.url I get media/home/name/project/site/media/image.jpg
Hmm, this shouldn't be so diffcult. Let me quickly take a look.
Appreciate it ❤️
@frosty mauve Ah, see if this helps - he has a model with an ImageField too, https://medium.com/@ksarthak4ever/django-models-and-shell-8c48963d83a3
I need help with Flask. Im learning templates and im doing easy stuff. Someone can help me? Extends method of jinja doesn't work
Thats the app
app = Flask(__name__)
@app.route('/')
def index():
return render_template('base.html')```
That is the base html file
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Homepage</title>
</head>
<body>
{% block body %}
{% endblock %}
</body>
</html>```
@queen bough I think it's just a pathing issue, I will mull over this for a few more hours and let yyou know if I get it resolved 🙂
@frosty mauve Sure, sorry I couldn't help any more.
And this is the derived.html
{% block body %}
<body>
<p>HELLO</p>
</body>
{% endblock %}```
Thats pretty easy, but it doesnt work. Have i done some mistakes?
@toxic marten Is it block body or block content?
I have never seen body, just trying to help
I am working with Django and I am using some includes, haven't messed with extends yet but all the blocks have been block content
ok
my book says body is for content of the body tag, and content is for user defined page content
so should i use content?
wouldnt hurt to try it real quick
I am still trying to figure out these webapps too 😛
👍
Flask is my first backend framework that i use. At first, i wanted to start with django, but a lot people say me that is better if i start with flask, cause it is more simple
I think I probably should have done that 😛
I heard the same
bottle-> flask -> django
Exactly
hello, i need some help, do you know how o put an expiring date to a post, so that after the expiring day the post autodeletes?
hi everyone! Hope someone can help. I'm making a practice project, it allows users to store their meds in a database and I'd like to add some sort of alarm or reminder (probably a notification, or email). I'm working with Django and I really don't know how to link the time selected with the notifications or email, or how to even add that functionality... Any guidance you could provide would be helpful.
You'd need to schedule a task to run in the future I imagine
I've not looked into how to do that with Django
However, Django 3.0 does support async AFAIK and generally it is possible to accomplish that with async, so that is one avenue to explore
Celery could also do this but it sounds like it may be overkill?
Hey guys, does anyone know the solution to this bug?
I have this code in my models.py file so im not sure why im getting that.
The bug comes every now and again and im not sure why. My code runs perfectly at times then randomly this shows up so I'm not sure.
How to convert html animation to mp4?
I have a django model that stores the date & time when an object is saved. How can I get the total saved in the lpast hour, day, seven days, month and year? I think I can use pandas to do this but it's kinda heavy. What's the best way to do this?
how do i make the labels go directly above the rectangles
so that there's no space between the label # and the rectangle
@mighty herald can i see your models?
@errant spindle use bootstrap or put every input with its label in a separate <div>
whats bootstrap
This is a kinda library
You can even put every input and its label in the separate <div>
<div>
<label>label1</label>
<input type=“text” />
</div>
<div>
<label>label2</label>
<input type=“number” />
</div>
Hey guys, I'm trying to understand urllib, and it feels like the simplest thing would be to request the active browser URL, and save it as a variable.. but the answers I got on stack didn't make much sense, or work when I tried to run them. Any tips?
Read the docs
@nimble epoch Seriously?
Any doubt
Someone who is deflecting questions with "use bootstrap" shouldn't be throwing rtfm around
Good morning @nimble epoch heres a picture of my models
i have it but the user_login error is still showing up every now and again
Can i see the whole error
its not showing up anymore. but it shows up sometimes
Oh
On a different note i set up my schedule page and its functioning well except the same data is getting displayed on every users account even if im logged in diffferent accounts.
You are not getting data from different user id probably
Does it show the whole data?
It shows every input i have made. So everything in the database im guessing. But heres my view for my schedule page
is it possibly because of line 26 where im query.all() ?
Yeah you are adding whole data to dict
db.query.filter_by(current_user.id) ?
Better use db.query.filter_by(user=current_user.id)
If im right because i haven’t practiced flask for months
It worked! Thanks a lot man 🙂
Yw
Hey @nimble epoch if your still around, heres the error that i was talking about.
Can you send the files that you are working whith because i cant find it like this
If possible
which files in specific?
Your project
In a kind of cloud
Or sth
Line dropbox
Because i have never got this error
sure ill try dropbox
Tnx
can I store some static files for my website in heroku, like a gnu dbm file
I think yes
thanks
does anyone use Flask on Debian? I am having a hard time getting flask-sqlalchemy installed despite trying multiple things and searching for the error
Are you running it on a regular amd64 plateform, or on a arm device (like rpis)?
amd64
here are the steps: python3 -m venv env. source env/bin/activate; pip install flask; pip install flask-sqlalchemy
Can you try to update setuptools and pip?
And setuptools?
havent tried that yet. let me do so now
same error....it did update setuptools from 44.0.0 to Successfully installed setuptools-46.1.3
@nimble epoch how should i share you my files?
There gotta be a share link
@wintry lava flask-sqlalchemy doesn't support 3.8 yet, the latest release is from Sep 24, 2019, before the release of 3.8 
ahh!
Oh ok let me check
Thank you
@jagged lark did the same steps with python3.7 ...same error 😦
python3.7 -m venv ~/.venv/flask
python --version
Python 3.7.7
command: /home/abc123/.venv/flask/bin/python3.7 /home/abc123/.venv/flask/share/python-wheels/pep517-0.7.0-py2.py3-none-any.whl/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpehh2wnwl
actually let me update setuptools here too
nah..same problem
I don't know the solution sorry, but you should try to reach the developers https://github.com/pallets/flask-sqlalchemy/issues
i guess it doesnt buildSQLAlchemy
will do. Thanks for looking!
@jagged lark found something relevant: https://github.com/sqlalchemy/sqlalchemy/issues/5207
yes it worked with : pip install --no-use-pep517 sqlalchemy and then pip install flask-sqlalchemy
I cant run your project
No i mean the error
I have you files but the error that it gives you
ohh okay
Because i cant run your project
No changes yet
I was looking for a file name
Sorry man thats a little complicated i still dont know why you get that error
Ill keep doing my research, but i appreciate your time man
I really hope youll find it
Thankyou ill let you know when i do
@mighty herald
I got sth but not sure
@login_manager.user_loader
def load_user(id):
return User.query.filter_by(user_id=id).first()
Of course be sure add this after app initialization
in my models file?
Yeah
You have got your project so complicated and i guess that the orders are not correct
it initially got rid of the user loader issue but i got this
Rhisnis because you dont have User and user_id
You gotta replace them base on you database
You add it like this
@login_manager.user_loader
def load_user(user_id):
return User.query.get(id=user_id).first()
If it didnt work
Use
@login_manager.user_loader
def load_user(user_id):
return User.query.get(user_id).first()
Whats the result?
I got it to work by deleting from flask import request that I wasn't using. Looks like it was missing a request_loader because of that.
Yeah! Except knowing this issue that it keeps coming back im not so sure. lol
You can fix that too😉
👍 thanks for your help again
would i come here for help web scraping?
I'm using css grids
display: grid;
grid-template-columns: 5fr 6fr;
grid-template-rows: 1fr 10fr;
grid-template-areas: "header header" "corpus corpus";
}
This is my code
But it always leaves a bit of space on the right of the grid
make sure to ask your actual question with any issues and code you have @modest elk it makes people more inclined to help
from flask import Flask, render_template, json
import requests, json
app = Flask(name)
@app.route('/')
def index():
r = requests.get('https://coronavirus-19-api.herokuapp.com/all')
data = r.json()
data = json.dumps(data, indent=2)
deaths = data['deaths']
return render_template('index.html')
if name == "main":
app.run(debug=True)
So i am trying to build a flask web app
to fetch this json api, and show it to my app
But i am finding it difficult
How i show it to the index.html
In js i would do for example {data.deaths}
data = r.json()
data = json.dumps(data, indent=2)
deaths = data['deaths']
This bit isn't right.
just ditch the second line
and it should work how you expect
dumps is dumping the json to a string. loads is loading a json form a string, but thats called by r.json(), so you don't need to do it
You should also pass varibles into the render call. For instance render_template('index.html', foo=42), or deaths in your case.
yeah, thats how you want to show it in the template
you can pass the whole dict
you can do return render_template('index.html', data=data) then access data inside html by doing {{ data.deaths }}
File "C:\Users\Irdi\Desktop\flask\app.py", line 12, in index
deaths = data['deaths']
TypeError: string indices must be integers
I get this error
i dunno why
I explained why above
dumps is dumping the json to a string. loads is loading a json from a string, but thats called by r.json(), so you don't need to do it you want a dictionary, not a string. and r.json() returns a dictionary
I have a problem with heroku's ssl certification. When I deployed my site, the logs shows it is running perfectly but I can't connect to it because of some ssl issue
Any idea why this is happening https://openutils.heroku.com/
looks like the domain wasn't heroku, it was herokuapp
dumps is dumping the json to a string. loads is loading a json from a string, but thats called by r.json(), so you don't need to do ityou want a dictionary, not a string. and r.json() returns a dictionary
@rigid laurel When i remove deaths = data['deaths'] it loads the app but not the number of deaths. when i leave the line than it shows the error, i will try my best
Let me try and make sure I understand your problem. You're trying to get the number of deaths from the json into the template right?
If so, you need to pass the dictionary result of r.json() into the template. For your case you can do that with something like
def index():
r = requests.get('https://coronavirus-19-api.herokuapp.com/all%27')
data = r.json()
return render_template('index.html', data=data)
Then inside the template do
<div class="deaths">
{{data.deaths}}
</div>```
Does that still give you an error @modest elk ?
No error but it's blank
Can you paste your template here?
I know that i disturbed you i am sorry
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
<div class="deaths">
Death number:{{data.deaths}}
</div>
</body>
</html>
def index():
r = requests.get('https://coronavirus-19-api.herokuapp.com/all%27')
data = r.json()
print(data)
return render_template('index.html', data=data)
Could you check that you're receiving the data correctly?
When i try with request only it works
try thispy def index(): r = requests.get('https://coronavirus-19-api.herokuapp.com/all%27') data = r.json() return render_template('index.html', deaths=data['deaths']) then access it with {{ deaths }} inside the template
Nice
return render_template('index.html', deaths=data['deaths'], cases=data['cases']) to show cases
Finally i got it
thank you so much @rigid laurel
You might also want to cache that if you are pushing this to public? 🙂
Hm, I'm slightly confused. You should have been able to do it the first way with data.deaths/data.cases - but I'm glad I could help
not sure what was going wrong
but glad I could help
Guys I wanna ask you... So im trying to make a mp3 song downloader using flask but I don't know how i can upload the files to the users after its converted?
You might also want to cache that if you are pushing this to public? 🙂
@pure token First time i did it with Svelte JS and it was easy, now that Charlie explained that to me i find it easier to do it in Flask too
Cache with redis?
So you want the user to be able to click a button and download an MP3 @feral minnow ?
or the user uploads a file, you process it, and they get the file back?
I want the user to click a button and download the files
@modest elk at least make a function with a cache decorator or something that stores the value for a short duration so it does't do http request for every single page visit
@modest elk at least make a function with a cache decorator or something that stores the value for a short duration so it does't do http request for every single page visit
@pure token That's a good idea, so i don't ping the api a lot
I tried <a href="{{filePath}}" download>Download File</a> but it didn't work
For example update data every 5 min
https://flask.palletsprojects.com/en/1.1.x/api/#flask.send_file you want to use something like this @feral minnow
display: grid;
grid-template-columns: 5fr 6fr;
grid-template-rows: 1fr 10fr;
grid-template-areas: "header header" "corpus corpus";
}```
https://gyazo.com/4e11459ef064a32d2b5bb6957b3193ab
This is my code
But it always leaves this bit of space on the right of the grid, why is that?
I think you can just do return send_file('path_to_your_file.mp3') or similar
might need to set as_attachment to True
oh
I will try it thx
@rigid laurel i tried send_file but its playing the video its instead of downloading it
I think thats why you want as_attachment=True
oh
I haven't actually used this myself
I have to put it after the file name?
return send_file('path_to_your_file.mp3', as_attachment=True)
should be that
hopefully
you can also set a filename with return send_file('path_to_your_file.mp3', as_attachment=True, attachment_filename="magic.mp3")
You mean that when it download the file it will download it with this name?
yeah
nice...Thanks again you really helped me
Excuse me,
what's the difference between flask run and just doing python main.py
?
Not sure but i think the difference is in their version
Hi guys!!! I am trying to find some help with this issue: I am usind Djangos paginator and when i click Next, instead of having the second page I receive my 'else' code
here my view and template:
Your code does not make sure the q variable in the url persists through a next-page click
Because of that it becomes none, and you see what you're seeing. Your next page links should include the q value of the current page to make sure it persists appropriately
To deploy our apps online https://www.qovery.com/blog/qovery-is-free-for-open-source-projects
Hey, Im trying to adjust the form-control width that bootstrap provides without messing up the other attributes. How can I do this? I have tried using a custom css class but then the website look changes completely.
A question about Django
What is generic view or as_view() method AND what its used for?
@nimble epoch This may help: https://docs.djangoproject.com/en/3.0/topics/class-based-views/
You'd have to understand views to be able to understand it.
Guys anyone know how to center card from bootstrap
tried everything but nothing work????
Try:
class=“row justify-content-center”
Yw
It's also very dependent on your use-case, and thus difficult to explain out of context.
How can I center a button that is in a bootstrap card
Try:
class=“row justify-content-center”
That didnt work
@nimble epoch Yup. Start with functions and refactor to classes if/when you need them.
I centered the card with that but the button wont mov
Put your button in a <div> and use that class in the <div>
Worked?
You can even use html <center> tag
Really?
Sometimes i think bootstrap doesn’t match with html and css
Even with itself
@queen bough i dont think that class based is useful, is it?
It is, very. When you want to connect it to a model then they are.
I can't remember all the reasons off the top of my head, but there's definitely a place for them.
Function-based are a lot simpler though.
But you can use models in function based too
@nimble epoch its a photo of the website he's trying to make
He's trying to center the login button
Add that class to your base div that has rounded the form
If didn’t get me send me the file to help
If got me so everything is alright
Can i see the code?
the problem is he's offline now
Because i cant tell you where i meant
Oohh
You see the login form with the button?
yes
Yeah
I remember that he tried that already but it didn't work
Surround your whole code after body tag with a div and and add that again to that div
This will probably work
Thats great
I rolled back, delicately tried it again, then spent the next 20min unfucking it all
thank god for newrelic
Guys im trying to make a drop down button I copied the link from bootstrap but when I click at it nothing happen?
i'm implementing a flask restful backend for a mithriljs webapp and trying to do auth. everyone says to use jwt, but is that a really a better solution than just flask-session?
it seems like a pain to have to mess with refresh tokens and local storage to get session to persist
like regular acco0unt auth ?
yeah, normal accounts
jwt sounds like the better option, but i'm wondering if sessions that persist like normal session cookies are possible
@stable notch yes flask implements a cryptographically signed session cookie
@fresh dock but would this be the correct use case for it? i'm not sure whether to use it or jwt plus refresh tokens
it's acting as the backend for a single page app, so cookies are implemented
So, I'm building a local hosted (on a raspberry pi) Django web server that will have a landing with different buttons on it, similar to a bookmarks or quick launch page, and the other app will be a page that controls an LED strip attached to my raspberry pi. I don't believe either of these apps require much at all, if anything, to do with database storage besides maybe for the superuser account (is that even stored in the database?). For now, can I basically skip over messing heavily with Models and the database stuff?
Me: pushes engine optimizations
Heroku: have a middle finger made out of your performance stats:
from flask import Flask, render_template, url_for, flash, redirect
from flask_sqlalchemy import sqlalchemy
from forms import RegistrationForm, LoginForm
app = Flask(__name__)
app.config['SECRET_KEY'] = '5174d34305f9ee68dadd141092a2985e'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db '
db = SQLAlchemy(app)```
is returning
```Traceback (most recent call last):
File "/home/turtle/Documents/VSCode_Projects/flask_test/flask_test.py", line 9, in <module>
db = SQLAlchemy(app)
NameError: name 'SQLAlchemy' is not defined```
sqlalchemy != SQLAlchemy
I have 2 migrations of one Model that I removed. How can I remove/modify these migrations?
what is the easiest way to get the song name and current dj off this site? i tried lxml, but there is a stupid pop up.. so then i tried selenium to click the 'let me in' button. now im thinking that's overkill and it can be done with just lxml since the webpage is still visible behind the pop up... any hints as to how i could get them? https://plug.dj/4204681060305555241 is the link, and here is a screenshot (blue circle) of the variable i need with the pup up in the middle of the screen
They have an API
It's not documented though
I started working on documenting it myself but I don't think I covered anything related to this
Was more concerned with playlist management
Have a peek at the network requests to see if there's a useful endpoint
thank you
do you have a link to any of your playlist documentation? i may be interested in that as well
Sure though I think it's incomplete. I lost interest in the project I was going to use it for https://gist.github.com/MarkKoz/0e67689346308f0e91787918bc569249
plug.dj Playlist API. GitHub Gist: instantly share code, notes, and snippets.
Also I don't think I wrote downn how the auth works anywhere
thank you so much!
What do you need an explantion for?
An IP address has a host part and a net part
The net part comes first and defines the network
the host part defines the number for that client
which part of the number is which, is defined by the subnet mask
@white pewter
Random?
Can i take 21 bit net id and 11 bit host id
you can, if the selected subnet allows it
10.0.0.0/8 is a subnet
It's a private ip subnet
You can take this, and divide it into smaller chunks
So, 10.0.0.0/21 would be legal
No i m newbie and this is from a book
You've never set the IP on your computer?
Ifconfig shows my ip
yes and it also shows your subnet mask
That is the part that defines how many bits are for the network and how many bits are for the hosts
So an IP has 32 bits
So what decides that net id is 20 bit and host id 12 bit
You
forget the internet for a seconds, that is too complicated
lets stick with private IPs
Ok
Ok
It defines the network with the number 192.168.0.0
Ok
Because netID is an IP and i need a broadcast IP which is always the last IP
Oh
So, how many bits do I need for 10 IP?
3 is too little
so I need 4
32 bits - 4 bits = 28
192.168.0.0/28 = 14 max hosts
Well i will complete the book then again come here , its little complicated
You are on linux right?
install ipcalc and toy around with it
user@ras:~ $ ipcalc 192.168.0.0/28
Address: 192.168.0.0 11000000.10101000.00000000.0000 0000
Netmask: 255.255.255.240 = 28 11111111.11111111.11111111.1111 0000
Wildcard: 0.0.0.15 00000000.00000000.00000000.0000 1111
=>
Network: 192.168.0.0/28 11000000.10101000.00000000.0000 0000
HostMin: 192.168.0.1 11000000.10101000.00000000.0000 0001
HostMax: 192.168.0.14 11000000.10101000.00000000.0000 1110
Broadcast: 192.168.0.15 11000000.10101000.00000000.0000 1111
Hosts/Net: 14 Class C, Private Internet```
Ok
I have setup a django server, when I run python manage.py runserver I get: "Watching for file changes with StatReloader", and it seems stuck at this stage. when I do ctrl + c then I get performing systems check > starting development server etc.. but the server is not up
@white pewter That subnet can contain 62 hosts, the max number is 255, so 255.255.255.192 can contain 4 networks
How did u know 62 host it canhave
Because 256/64 is 4
Remember, 62 hosts, + 1 ID + 1 Broadcast = 64
Ok
I was reading this
255.255.255.192 are 26 bits
255.255.255 = 24
192 = 128 + 64 = 2 bits
Because bits order is 128 64 32 16 8 4 2 1
Fucking bits
it all comes down to the bitwise addition
Fuck binary
TO subnet, you are splitting a number in half
Basically
so you need to go down to the bit level
Ok
Take a piece of paper, make a table with the bits
Then insert your desired netmask into it
calculate the number
Once you get the hang of that, you'll be subnetting without even doing math
It's the same
Then use subnet mask for determining net id
Yes i had confusion in Cidr and submet mask but now i m not
I feel easy
Also i learnt how to determine net id from cidr
I dont know what is broadcast or broadcast id
Broadcast is the last IP in the subnet
That is really all it is
What it is for is irrelevant for now
So, got a net with 192.168.0.0/16
ID is 192.168.0.0
Broadcast is 192.168.255.255
See #announcements
There are lot of announcement which in particular to see?
@patent cobalt
I mean like 100s of them
The very last one
Ok
So i cant talk because of covid 19
Do they spead from discord
@patent cobalt
You'll need to confirm you've washed your hands in #bot-commands and you'll be able to talk in off-topic
Anyone uses FastApi can tell me if we need to use both pydantic models and SQLAlchemy models or only one of them?
Guys i wanna upload a youtube downloader to a server to be hosted on the web how i can create folder in that server and download files?
Hi, I want to ask why I got the 'refused to connect' message on web? I'm using django and I've set with 'xframe_options_exempt'. I can view the file with
<p>Open a PDF file <a href= {{ content.file.url }} >example</a>.</p>
after click the button. but not able to view directly with
<iframe id="iframepdf" src= {{ content.file.url }} width="100%" height="500px"></iframe>
Do I have any wrong setting? Thanks
It's the screen shot.
need help error is too short Its not helping
It looks like it's not properly finding an associated view or URL path, maybe
@gilded dragon yep but I'm not getting it can you help?
No, I am not good enough at Django yet to help you adequately. I'm just helping how I can. It looks like the URL you're requesting is kind of... Weird? Maybe check out what's going on there? It's possible the link you're requesting from your server is not in your urlconfs so maybe fix that or see if it's correct
@native tide %5E is ^ , so there is somewhere an extranious ^ in your code
Probably in the http request he's making, yes?
in the url...
Right, I know
But where would that ^ be, code-wise? In the request he's putting to the server, yes? He's "asking" to go to ^Like/$ somewhere
this is url path ```
path(r'^like/$', views.like_post, name='like_post'),
Theres your problem
and If I change it it gives this
The ^ is still in your url
Yep
do you not see that your url is malformed?
how do I solve it?
Also media has a ^ in it too, not sure what that's about but you might want to fix it now or resolve why it's there in the first place
The thing you're requesting with is asking for a url with ^ in it
I remove ^ but it didn't work
Perhaps a button?
Remove the ^ from the request that the button or whatever it is you're trying to send to the server
I wonder why you are trying to regex a url anyway?
An Url is not a suggestion, it is hardcoded
@gilded dragon The running commentary is really not necessary
I'm trying to make a like button Its working but whenever I press it it give this error working means I can see likes in admin page
ok, but why the ^like/$ as if you are regexing it?
Just do /like/postid/ done
Or the id of whatever is getting liked
Anyway, your issue is that the url is malformed due to the ^ and I don't see your code, so you gotta somehow fix that. Your routes seem to have a /like/ path, maybe adjust to what I suggested or simple remove the ^ and figure it out from there
Hi, how can i download a file to a flask server?
I would like to download an online video to the flask webserver then send it to the user. Ik know how to send the file just not how to download it specifically to the sever.
Use a request
It didn't work dude
You didn't what?
oop
look at this ```
Page not found (404)
Request Method: POST
Request URL: http://127.0.0.1:8000/like/postid
Using the URLconf defined in django_project.urls, Django tried these URL patterns, in this order:
admin/
register/ [name='register']
profile/ [name='profile']
login/ [name='login']
logout/ [name='logout']
password-reset/ [name='password_reset']
password-rest/done/ [name='password_reset_done']
password-reset-confirm/<uidb64>/<token> [name='password_reset_confirm']
password-reset-complete/ [name='password_reset_complete']
[name='blog-home']
user/str:username [name='user-posts']
post/int:pk/ [name='post-detail']
post/new/ [name='post-create']
post/int:pk/update/ [name='post-update']
post/int:pk/delete/ [name='post-delete']
announcements/ [name='blog-announcements']
about/ [name='blog-about']
^like/$ [name='like_post'] #This line here
^media/(?P<path>.*)$
ok, but now the ^ is gone from the url, so thats good
postid was actually a sample variable to denote the id of whatever post or image you want to be liked
it wasn't literally
I was a suggestion how to structure this
ik but I tried it cuz I'm pissed off and nothing is in my mind
The route would be something like /like/<int:postid>
Then use that post id in your code to increase the like count
however you do that in your project
ye
hm?
it is recommended to use proper web server in production, not python app.py
yup
okay
first, install gunicorn
pip install gunicorn
and put it in your requirements.txt
install it on my pc?
Im downloading it
done
Procfile declares types -> (none)
I put it in requirements
@vagrant adder
And installing a web server on his personal computer will help him how to deploy his app on Heroku, @vagrant adder ?
I am very interested in that answer tbh
So...You know how to use the Procfile file??!
I don't use HEroku, so no
np
hmm I don't if this will help but Im scraping youtube using flask
Go ahead... let me see if your tutorials can help
What are trying to scrape??
For me I made a youtube scraper first then I copied the code to flask and just modified it a little bit
check your code line 50
here is the view where its taking error from ```
class PostDetailView(DetailView):
model = Post
def like_post(request):
post = get_object_or_404(Post, id=request.POST['post_id'])
post.likes.add(request.user) #This one is line 50
return HttpResponseRedirect(post.get_absolute_url())
make sure you write it in the right way
maybe post_like or post_likes
I don't anything about django but maybe this will work
this is the url path So ...
path(r'like/', views.like_post, name='like_post'),
``` like_post maybe?
I'm trying to make a like button for my blog site
oh
In this article, we show how to
add like and dislike buttons to a post with Python in Django. With this functionality, a user can like or dislike a post.
maybe this will help
okay lemme check
did you fix it @native tide ?
yep I fixed it but I got new issue
I changed some stuff in views.py and it worked but when I set @login_required and when the user login It gives error
to avoid that I need to change it to previous page so how can I refer him to previous page? @feral minnow
is there something called redirect or something like that in django?
yeah I think its href you're talking about
not html
actually djengo is just backend the main thing is html
@feral minnow yep I've absolute.url() already
screenshot you code pls
to the post detail page
okay so lion
wait I figured
do you have gunicorn installed
can you do gunicorn main:app in terminal?
my pc cmd?
yes
@feral minnow This is better isn't it?
back
@native tide dose it save the things that the user enter ?
@vagrant adder I run it
ModuleNotFoundError: No module named 'fcntl'
@native tide try return redirect('the function you want')
oop I messed up again this function shows the like button only for post author
@vagrant adder
Hello everyone, i am new here, not to python(covered till oops) but new to django, what would you recommend the best resource to learn Django for a beginner??
A flask tutorial 😛
@feral minnow install fcntl then
It give an error
when i try to install it
@vagrant adder I put my files on github and connected it to heruko
Why I have to install it in my device ??
you don't have to install it on your system, you only have to have it specified in requirements.txt
okay, do you have procfile
Hi all, and thanks for the help in advance. I'm facing an issue with Flask and I would really appreciate the thelp.
Just le me know when someonse is free so i dont clutter the channel.
Thanks and sorry for my English (im from Argentina and spanish is my native tongue)
yes
what I have to put in it?
something like this @vagrant adder ?
its not working
here is the error
you can use hasebin or something
1s
@vagrant adder can I borrow 5 min from you once you are finished with @feral minnow ?
sure thing
you need something?
Essentially Im practicing while creating a team builder based on players attack and defense stats; and the return_template call is not being passed when I post to the /teams form
`
from flask import Flask, render_template, request
import csv
import random
app = Flask(name)
app.config["DEBUG"] = True
file = "XXXXXXX"
allPlayersData = []
with open(file, 'r') as data:
csv_data = csv.DictReader(data)
for row in csv_data:
allPlayersData.append(dict(row))
shownPlayers = []
for item in allPlayersData:
shownPlayers.append(item['name'])
print(shownPlayers)
def searchPlayer(name):
for p in allPlayersData:
if p['name'] == name:
return p
def buildTeams(playersList):
selectedPlayers = []
for item in playersList:
playerData = searchPlayer(item)
selectedPlayers.append(playerData)
teamAtkDelta = 4
teamDefDelta = 4
team1 = []
team2 = []
while teamAtkDelta >= 4 or teamDefDelta >= 4:
sampling = random.sample(selectedPlayers, 16)
team1 = sampling[0:8]
team2 = sampling[8:16]
team1Defense = sum(int(item['defense']) for item in team1)
team1Attack = sum(int(item['attack']) for item in team1)
team2Defense = sum(int(item['defense']) for item in team2)
team2Attack = sum(int(item['attack']) for item in team2)
teamDefDelta = abs(team1Defense - team2Defense)
teamAtkDelta = abs(team1Attack - team2Attack)
return render_template('teams.html', team1 = team1, team2 = team2)
@app.route('/', methods=['GET', 'POST'])
def availablePlayers():
return render_template('players.html', shownPlayers = shownPlayers)
@app.route('/teams', methods=['POST'])
def buildDamnTeams():
selectedPlayers = request.form.getlist('selectedPlayers')
if len(selectedPlayers) >= 16:
buildTeams(selectedPlayers)
else:
return "missing players, should be 16"
`
everyhing is working fine except that call to buildTeams() on the /teams call on POST
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
it does that when you select 16 or more players?
correct, when you select at least 16
okay i found a problem
been reading and probably has somehing to do that the render_template should always have app context
could that be the issue?
so when you select at least 16, you call function but never return anything from route functions
but the buildTeam function returns render_template and stuff, right?
your buildTeams returns already rendered html and such, but it returns to route level, not outside it
i would do like this:
- make that buildTime only returns teams
so it ends in return [team1, team2]
and in your route:
if len(selectedPlayers) >= 16:
team1, team2 = buildTeams(selectedPlayers)
return render_template("teams.html", team1=team1, team2=team2)
else:
return "missing players, should be 16"
cheers man
Again, we don't help with things like that
@feral minnow, @tired root is angry again i think he didn’t have enough sleep
Just Don’t notice
@nimble epoch That has nothing to with angry, we do not help with violations of TOS
<@&267629731250176001>
This will finish it
scorcher is right, we won't assist with that.
@nimble epoch don't be sarky like that
oh okay
youtube
Per PyDis' Rule 5, we are unable to assist with questions related to youtube-dl, commonly used by Discord bots to stream audio, as its use violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2019-07-22:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
Is this for pytube too?
yes
It's the act of downloading, not the script you use
any service which pulls content from youtube not using the official API
(the official API does not have that capability either)
Thank you
Wlc
Does anyone know the answer to this question?
oh
1s
This flask SQLAlchemy tutorial will show you how to update, delete and add rows in an SQLite3 database. It will also discuss how to properly query and search for entries in a table.
Text-Based Tutorial: Coming Soon
⭐ Kite is a free AI-powered coding assistant for Python that...
Watch this video I think it will answer the question
@kindred glacier
@feral minnow I'm using sqlite
oh
you can use sqlalchemy with sqlite
Is there some fundamental difference between serving a static image, and using send_file() to return an image?
Ideally I would not like to store a bunch of static images, but generate them dynamically on the fly (specifically using this: https://github.com/kebu/py-avataaars, combining a few svgs to render a png). I've set up an endpoint to send_file(image_bytes, mimetype), and it appears its working as expected when testing in a browser, but for some reason a mobile sdk that I am using it doesn't understand the image format.
If I curl my same endpoint to download an image, and serve that as a static file the mobile sdk understands the image as expected.
I feel like I am missing out on a tiny detail. Ideally I would prefer not having to generate some static file for every combination of avatar (very large amount), but generate them as needed.
sounds like one of the response headers differs
see what headers your server sends in both cases: send_file, and static file
gonna try that now, thanks for the response!
looks like the content-length isn't being sent with send_file() since I'm not passing a filename, time to do some digging
hmmm, it appears extending a flask restplus Resource for the endpoint was somehow causing problems. I attached the endpoint directly to the app instead of extending a Resource and it looks like its working now, thanks again
💐
I have made this website with backend as node. I want to shift to a python web farmework and show analytics using Scipy. Any suggestions for how should I go ahead. Regarding choosing a famework ...
http://covid19.vshsolutions.com/
Anyone knows about FastApi and how to update data in it ?
div{
width: 50px;
height: 50px;
background-color: lightcoral;
line-height: 50px;
text-align: center;
animation: move 2s infinite alternate linear, change 2s infinite alternate linear;
}
@keyframes change{
0%{transform: rotate(0deg);}
100%{transform: rotate(90deg);}
}
@keyframes move{
0%{transform:translate(0px,0px);}
100%{transform:translate(100px,100px);}
}
anyone know why these 2 animation arent working at the same time
@turbid glen Because you can only apply one animation to one element at a time with css
but if i change the @keyframe move to 0% background-color red to 100% bg color green it works
both of them work at the same time, i mean
make a fiddle of that because that'd be unusual that it suddenly works when changing the color
i mean its true tho... https://jsfiddle.net/9hf4tpj3/1/
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
Still doesn't move in chrome
yea
Also does not work in Firefox
Because you can only apply one transform at a time
And if you do it at once,the result would be moving in an angle
Because the matrix didn't get reset between
erm so can we write like this transform: rotate(xx), translate(xx,xx)
combine them together
As I said, it would be moving in an angle
If you'd do something like this in a game, you'd need to reset the modelview matrix in between rotation and translation
The same principle applies here
BUt you can't do that, and which is why I said only one animation per element
the background-color isn't such an animation
ok then
it's a simple property
ty
Im working with Flask, and i discovered (with miguel grimberg course) that there is a dedicated extension for bootstrap (pip install flask-bootstrap). This extension will add some bootstrap folder and files in templates folder. But the problem is that i can use only bootstrap 3, because the extension is based on this version. Instead i want to use bootstrap 4. I found another extension (pip install Flask-Bootstrap4), but it doesn't create any folder, files, etc in templates files. It should add some files used by the extension, but it doesn't. I dont understand
Does someone use bootstrap 4 with flask? If yes, can you explain me a little bit, in general, how bootstrap and flask work together
Yes, ive done that, the problem is that flask-bootstrap extension has some features (macros) that are stored in some files. But there no files
flask has templating engine that interacts with templates
flask bootstrap interacts with templating engine to give you more css (in a nutshell)
Yes. But im not referring to that. Flask-bootstrap has some features (macros), for example render_field(), render_form(), render_nav_item(), etc that are stored in bootstrap/form.html
But there no files. Theres no bootstrap folder. The problem is this
However i dont understand at first if flask-bootstrap is the version 3 or 4 of bootstrap. Documentation says that is version 3. A lot of tutorial says that is version 3, because all of this tutorial are old (most are old 3 years ago or more). But now for example i found this doc that says it is bootstrap version 4. Im really confused
Hey @toxic marten!
It looks like you tried to attach file type(s) that we do not allow (.pdf). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .m4v, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .svg, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .md.
Feel free to ask in #community-meta if you think this is a mistake.
https://readthedocs.org/projects/bootstrap-flask/downloads/pdf/latest/ This say that it is version 4
But here says that it is version 3 (or also 2) https://pythonhosted.org/Flask-Bootstrap/
I am looking in Django for an elegant way to destroy all user related active sessions. Preferably maybe I overlooked to do it in Django way? Currently I am using password_change from django.contrib.auth to change password and in addition after that I would like to destroy all the user sessions for security reason. I was shocked that Django default mechanism is not doing that.
Hey, I'm trying to get into webautomation with python but I'm running into this problem where if I use the element of i.e a searchbox, and try to execute a method "send_keys" to it, the autocompletion doesn't register that for me.
The weird thing is that there are 0 error pop ups after I - manually - write out the whole command. However, it consistently executes a "element not interactable" error when I try to either click a button or send information.
When I try to instead use it as a script, it suddenly works fine and I can click on buttons as normal. Why does this happen?
@cunning prairie I'm not very familiar, but here are some links which may help:
https://dev.to/fleepgeek/prevent-multiple-sessions-for-a-user-in-your-django-application-13oo
https://stackoverflow.com/questions/6656708/most-optimized-way-to-delete-all-sessions-for-a-specific-user-in-django
@cunning prairie I'm not very familiar, but here are some links which may help:
https://dev.to/fleepgeek/prevent-multiple-sessions-for-a-user-in-your-django-application-13oo
https://stackoverflow.com/questions/6656708/most-optimized-way-to-delete-all-sessions-for-a-specific-user-in-django
@queen bough thanks, I stumbled upon the stackoverflow entry and wanted to follow it however I don't know how to integrate it with change_password ready form/view
@cunning prairie When change_password occurs successfully then call delete_all_unexpired_sessions_for_user. Should be that simple.
But, as I said, I've not done this before.
In this case it seems that I would need to mess with django.contrib.auth.* files which I wanted to avoid. As I see password_change works pretty automatically, template is just {{ form.as_p }} and view with form comes from the lib
Why would it mess with the contrib.auth files?
How could I attach the code without modifying django.contrib.auth.* files?
To use password_change, I did only {% url 'password_change' %} in my html file, {{ form.as_p }} as template to render the form and path('account/', include('django.contrib.auth.urls')), to attach urls from the lib
that's all my code, I am not sure from where to execute delete_all_unexpired_sessions_for_user
Ah right. You might have to create a view that extends contrib.auth (perhaps by passing stuff to it), though honestly I don't really know.
https://docs.djangoproject.com/en/3.0/topics/auth/default/#django.contrib.auth.views.LoginView - might also help.
I'll try to do it, thanks for a direction.
@cunning prairie These are the view functions: https://docs.djangoproject.com/en/1.8/_modules/django/contrib/auth/views/
And this may also be relevant: https://docs.djangoproject.com/en/3.0/topics/auth/customizing/
Yep, the following view class PasswordChangeView(PasswordContextMixin, FormView): I am trying to change
https://readthedocs.org/projects/bootstrap-flask/downloads/pdf/latest/ This say that it is version 4
@toxic marten Can someone help me?
Is it possible to run aiohttp web servers asynchronously instead of blocking?
Can anyone experienced in github API v4 help me to define scopes for my app? I tried some combinations but every time it failed.
@peak thicket run it in a thread
You can't run a main loop non blocking
The only solution for that is a thread
or having to do the loop yourself
Most asyncio applications have 2 ways of starting. 1 blocking method and an async method.
Like run() and await start().
Guess I'll just use Sanic or something.
Is there some reason requests.get() wouldn't add parameters to my url? I'm trying to get a response but it's like my parameters are just ignored:
import requests
placeId = 286090429
url = "http://roblox.com/Games/GetGamePassesInnerPartial"
params = {
"startIndex" : 0,
"maxRows": 50,
"placeId": placeId
}
data = requests.get(url, params=params)
print(data.url)
# Ouput: https://www.roblox.com/Games/GetGamePassesInnerPartial
# Expected output: http://roblox.com/Games/GetGamePassesInnerPartial?startIndex=0&maxRows=10&placeId=286090429
Huh
Wow
My initial thought was that url is only the base url, but I was obviously wrong there
I though the IDE might not be updating the script but my script is observing changes correctly
Running the script directly through cmd line outputs the same thing
Hey guys anyone know how download files to heroku servers?
...
I didn't say "youtube files"
A download is the same thing as downloading a web page
it is a http request
so use request from flask or the requests package from Python
pip install requests
then do a get request on the file you want
If Heroku allows that, idk, I don't use that service
oh
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.
Dose that mean that heroku doesn't allow to download files?
How can we tell without context?
1s
Django question real quick. Setting up a simple website/webserver. Should my apps be initiated in the same directory as my "base" project files (so like, settings.py, wsgi.py, etc.) or above a directory, where manage.py is? I'm still kind of confused on that.
apps initiated? what?
Like when you start an app.
You don't start an app
It creates the directory with the app's files.
The webserver runs the python code
The command is "startapp". So what else do you want me to call it?
When an app is first created, I'm trying to figure out where in the directory hierarchy it should be created/initiated in.
Right now, I have it in the same directory as my "base project app", or whatever that's called. So the new app's directory is in the same directory as the base app, and manage.py.
When you run it locally, you launch manage.py
from the same directory
On a webserver, things are different
I don't think that's relevant to the question
ok then
I'm just looking to get my directory hierarchy set up correctly right now
You said you are looking to setup a web server. Excuse me for giving you an answer to what you are asking 😦
I appreciate what you told me, but I need to get square 1 figured out first my dude
So, if you are willing, can you tell me if my directory hierarchy looks acceptable for ensuring that my apps are where they belong? I just want to get this right early on, so that it doesn't cause problems later.
Hey wanna get started with flask!, to creata a webhook!
Any docs to get me started
@shadow orchid discord webhook?
Is it possible to download an image off the web to like a web server, ex: heroku?
@dusk zodiac maybe dryscape?
Anyone have good tutorials or advice for getting up to speed on a Flask/Graphene/Postgres/SQLAlchemy web app? I'm confused on how everything is working together (Front end is REACT, graphql)
I've been using flask for all of my webapi purposes but I've had a chance to take a more detailed look at aiohttp, I've made the move from requests to aiohttp to stop thread blocking and saw it also has several server functions, would I be better off moving my api to aiohttp over flask?
for context, better in terms of speed and ease of use from my POV
namely writing code for streaming content
Hello
I wanna return a wav file using flask
Any ideas?
It's an external file in the system btw
I tried send_file but It actually returned an invalid file :/
~
I have a simple web application that was built with flask and sqlite3. I have form, user can enter a name of grocery and quantity and it will get inserted into my database and on to list of grocery items. The problem I have is how to delete an item and how to implement this. I'm new to flask and having a hard to figuring this out
Well deleting an item is probably equal to deleting a row
Model.query.filter_by(name=target_name).delete()
Model is your db model, target_name and name are just place holders they can be whatever the columns you have are and delete is self-explained
I created new Django project with PyCharm how I can login now into Admin?
Does someone use flask-wtf or flask-bootstrap?
@toxic marten No to flask-wtf, because writing my forms is faster in HTML than that library. No to flask-bootstrap, because I am not going to burden my users with megabytes of code for something I can do by hand.
Ok ok. I just only want to ask about csrf protection
Without flask-wtf, how can i do this protection?
import uuid
def generate_random_string():
return str(uuid.uuid4())
That is one way
but just read up on it, explaining the whole process is too much for a chat
one important thing: Always use POST, never anything else
Also make sure your site is protected against XSS attacks
Thinking about it, you could also generate a session secret and encrypt the random string with that
So you can decrypt it when it comes back and make sure it is legit
Thank you
I really need help with memcache 😦
Can someone who has the time and the patience and the courage pm me to mentor me on how to use caching with the Flask app that I'm coding? Tyvm in advance!
WE are not doing dm help
also, this belongs in #414737889352744971
And I am giving you this free warning: open memcache servers are dangerous
make sure you know what you are doing
Akamai is aware of a new DDoS reflection attack vector: UDP-based memcached traffic. Memcached is a tool meant to cache data and reduce strain on heavier data stores, like disk or databases. The protocol allows the server to be queried...
@tired root thanks and I'm sorry for the wrongdoing on my part!
How can i disable browser default alert? Here there are at the same moment, the chrome alert and my custom alert that inform the user that must fill the form (im working backend side)
I want that only my custom alert is displayed
I didnt use required property, but it is rendered in the page because i use DateRequired()
name = StringField('Username', [DataRequired()])
email = StringField('Email', [DataRequired(), Email()])
submit = SubmitField('Submit')```
Does anyone know how to get the Recaptcha from a website, solve it somewhere else, then use post the solution in the original website
Like how 2Captcha and anti-Captcha work
Django models question -- i've got a model (Cart, as in shopping) which has a ManyToManyField to a Product, using a CartItem as the intermediary model. in the process of building a feature, I've discovered there are some number of Cart instances whose ManyToManyField appears empty (i.e., no relations to Product instances), but for whom cart.cartitem_set (the intermediary relation) is not empty. Trying to decide how much to care about this before digging into how that happened and whether it needs to be fixed...
@rustic pebble I don't understand how I can implement it to my HTML
You will do that on the server-side of things. usually that means app.py
@rustic pebble The way I add an item is I use request.form['form_name'] and add that to the sql query placeholder.
but not sure how to do that with delete
How does my app know which item I want to delete?
You need to create a model
After that you can use an identifier, it can be w/e u want to be able to choose what row you want to deelte
Does Flask have a way to save a session ID in the client?
@toxic marten the pop up is an HTML5 feature you added a DataRequired() validator to you form which adds the required field
@cosmic lantern yes flask can manage sessions. in the session variable or you can use flask-session and let it handle the sessions for you
oh, so flask-session just simplifies this?
@toxic marten the pop up is an HTML5 feature you added a DataRequired() validator to you form which adds the required field
@native tide Ok thank you @native tide . So i dont have to use required
But how can i implement the feature that input must be filled
yes flask-sessions is built on top of the session it makes it easier to manage user sessions the docs are also pretty good
If i dont use DataRequired(), will i use a rules created by me?
Do I understand it right, that sessions can store a session ID which can be used to authenticate API calls, so that the user doesn't have to log in again every time they visit my site?
@toxic marten if your field is required then add DataRequired
@cosmic lantern the session is a dictionary that has a csrf token added to it by the flask api apart from that you can pretty much add anything you want. user settings/ username etc
well I have a DB on the server that stores that SessionID along with a user ID that identifies a user. The client should only have that session ID and sends that along with a request every time it contacts the server
but i highly recommend using Flask-session coz you can get current user by defining a user schema that the Flask-session can use
so youre generating a sessionID for the user yourself?
can I store the corresponding user ID in Flask-Session?
no, currently not as I haven't implemented that yet
but I plan to
yes you can store it in the flasksession
since I want, as i said, to store a corresponding user ID for that session ID in my DB
okay
you can store and entire user object in the session
@native tide the problem is that i want that user must fill the input, but i dont want to use the default browser alert, generated by required. So, if use DateRequired(), it will render with required feature. I want to create a custom alert, for example the bootstrap alert that inform users to fill to fill the form. But if i dont use required and DateRequired(), what should i do?
Sorry for my bad english
flask session doesn't seem very popular 🤔
I mean this
@toxic marten yes you can add that too
but what are the advantages of using flask session if I am storing the session ID in my db anyways?
but if you submit a form without any data in it the required alert will pop up
@cosmic lantern then you dont have to waste time querying the DB
the session object also persists which means once the user closes the browser and logs back in you dont have to redirect them to the login page.
is that the right package?
https://github.com/fengsp/flask-session
Oops, i dont mean alert, i say a bullshit. I mean valid-feedback and invalid-feedback classes
@cosmic lantern https://pythonhosted.org/Flask-Session/
@toxic marten yes you can add that too
@native tide Yes ok. But i dont understand, sorry its first time that i try custom required
okay, thanks!
@toxic marten the required attribute basically prevents you from submitting an empty form
Yes i understood that
Im not very good with english, so maybe i dont ask you the question very well
But the problem is:
I want that user fill the input, BUT i dont want to render default browser alert, instead i want to do something like with bootstrap, i mean a text under the the input that says if input is ok or not. But if i cant use required and DataRequired(), how can i say to flask that the form must be filled. Because if i cant use DateRequired() what should i use?
@native tide I tried to write the best possible in English
you should use DataRequired(). once the user has submitted the form you should check if the form is valid by calling form.validate_on_submit()
then if there are any errors you can then send the form object to the template where you render your custom error
well, what should I use as the session ID? is it fine to just use a randomly generated string?
whats the users primary key?
it's a user ID (also the _id of the user in my mongodb DB)
or what do you mean by "key"?
the _id should be fine
but I shouldn't just store the password and the username in the session, should i?