#web-development
2 messages · Page 129 of 1
which loads images for portraits
therefore in the view where you see open chats, each person has a thumbnail portrait
just limit uploads to like 2MB?
2 MB is already quite big
so, yeah, I was thinking 500 kb
but anyway the main thing is that there could be as many as 8 images of the small size on screen at once
Mobile isn't a big deal if they are on wifi. But otherwise lighter is better yeah
therefore it makes sense to have a small version that they can load directly
yeah, but they might not be
Dude do you have file limits?
is there a use case for the large photos though?
yes, 8mb
How are you handling files larger than that? It seemed to accept one
yup
elsewhere on the site the larger versions will be used
ive rebuilt the upload widget. it wasnt implemented in that version
so basically I need 3 versions
small/medium/large
large will be the one uploaded by the user and I'll be creating two smaller versions
i have implemented drag and drop with preview
gm your worrying to much about size... size isnt that big of a deal anymore. 4g is as fast as most peoples home connections and 5g is faster then most peoples broadband
If you're not prematurely optimizing are you really developing though? 😛
The US isn't the whole world tho
most phone images are about 7-8mb as it is
you don't have access to 4G everywhere
and it can't hurt to have it run in less than ideal conditions
in particular, subway (I believe this is the equivalent US term) tunnels
and, yes, some countries are still on 3G
Internet not so good
(or 2G? I'm not sure about this)
Nah 2G is dead
I mean you could cache them on the device somehow maybe?
most likely they arent accessing your page over a phone network. trust me 95% of the web cant do anything that slow anymore
Ok but serving less content puts less strain on the server too
How well would your server handle somebody automating spamming image posts? \
of 8mb
the implementation of it puts just as much strain as managing which version is being shown. i dont think you understand how it works....
uhhh
@wicked elbow
[{"id":28,"username":"BubbleTanks","fname":"Riley","lname":"Gillespie","dob":"1900-12-16","ipaddress":"REDACTED","devices":"","geolocation":"","followers":"","following":"","likes":"","created":"2021-01-20T00:33:02.209783Z","lastlogin":"2021-01-20T00:33:02.209819Z","groups":"","description":"bruh, really?","facebook":"None","instagram":"None","youtube":"None","tiktok":"None","reddit":"None","snapchat":"None","twitter":"None"}]
wont be allowed too.
this is not the kind of stuff that you should be giving back as JSON responses in plaintext
cool its in developement. if you want to abuse a developement server ill block your ip
I'm trying to help you
You said you have testers
This is something that anybody you're letting test could have access to, and they wouldn't tell you about it if they were going to scrape a bunch of stuff
im not found in any search engine.... and i do have testers
and changing IP is very trivial
its not for anyones use other then theirs... to see if a foreign ip pinged their account
im guessing you pulled that from redux though. itll be turned off in production, but its a required resource to test the server
ips aren't sensitive info
it's the other stuff that is a concern
This is just a standard JSON response to a GET request to the /api/accounts endpoint
I'm not even the one who sent out the request, it's something you defined as behaivor
what is of concern? firstname lastname? can find that on their facebook? date of birth? can also proably find that on facebook
passwords and actual private info cant be accessed.
devices, geolocation, first name, last name, DOB
Those are generally considered to be private by most people, in comination
devices and geolacation arent implemented yet. but its not private info. dob is a requirement though, because im allowing nsfw content that i have to filter out. again developement. not blocking everything out yet on purpose... thats the point of developement.
as for how you got it im not sure honestly. ill look into because it should only show info of the account your logged into. ill fix it in a second
Just open up your dev tools
i was missing a tab, im getting ready to upload the new version anyways. wont show anyone else information now. but like i said your seeing stuff from redux dev tools being turned on
Found it
When you go to somebody's profile page
you submbit a get request to the /api/profile/ endpoint
with their username as a parameter
this could of course be done anyway, but it's probably not a good idea to do this for a potential attacker
and it looks like my auth token is perfectly valid for that route for some reason
it is for that route. but you are correct, i should move it to a seperate route that only pulls the info needed to fill that page. you gotta understand, ive programmed everything on the site myself. probably about 8000 lines of code or more done it in about a month. still a huge work in progress
It's fine man, I'm not trying to pick on you
I was just helping you test, these are things that are good to discover now
no i knew they were there though. its just a process to get everything going
but this is publically accesible, this server alone has tens of thousands of people ]
I don't think it's farfetched that somebody could scrape servers like these for personal projects that are being showcased on web servers
and looking for vulnerabilities
maybe paranoid, but you don't gain anything by leaving the server in debug mode and posting it here.
your probably right, but id say 99% of people arent looking that deep into it. and the js can always be viewed anyways. youd be suprised how much data you can pull off of major websites. its simply just required data. and its easier for me to debug to keep it up. that way i can see what someone is talking about
I would at least slap a warning or a disclaimer up there
or let your testers know not to use real info if they're at all concerned
if(!src.name) {
console.log(src) // hits here
form_data.append('upload_src', src)
} else {
form_data.append('src', src, src.name);
}
``` why isnt this working. there is a field name with upload_src. its a `CharField(maxlength=100)` on a standard post. i dont get it.
the second works, but not the first one. it wont let me put anything in upload_src
is form_data a list?
I didn't think that append would accept more than one parameter
oh sorry lol
that's JS, not Python
I need to go eat
formdata is formdata. you either pass info as application/json or as multipart/form-data
normally you pass as json, but when uploading images you have to pass the image blob as form-data
i fixed it. it was a backend issue
would you know how to mock a jwt token for a flask route?
[
{
"id": 16,
"product": 1,
"quantity": 234
},
{
"id": 17,
"product": 1,
"quantity": 235
},
{
"id": 18,
"product": 4,
"quantity": 32
},
{
"id": 19,
"product": 1,
"quantity": 2000
}
]
This is the response i get currently from djagno rest framework powered api end point , i wanna change this so that product field which currently has the id of the product should be replaced with the name of the product, i am using DRF generic view
So I'll post the HTML and CSS in a moment afterwards here
I am so very close to having this UI how I want it
It looks PERFECT when in a window (Resized it to be a bit smaller here) https://i.vgy.me/BSb4PC.png
but when maximized, the post is no longer centered https://i.vgy.me/NsHCaD.png
the goal is the post there to be centered underneath the header text
I've been sitting for quite a while trying to figure out what to change to fix it up, but I'm virtually incapable of understanding CSS
Specifically, this started happening as I added the max-width: 720px; to the .post class
as it looks absolutely silly when not limited to a reasonable width: https://i.vgy.me/QuF9cY.png
SOLVED: margin: 0 auto;
sigh
Can I get here any help about php ?
Hello everyone I am writing a project on django(3.0.11)+django cms(3.7.4). I created several applications, and when I try to link the application to a page created via django cms, these applications are not displayed. Has anyone encountered such a problem?
hi this is my colab code to do yolov4 an realtime video in cloud https://colab.research.google.com/drive/1cQa5cBGF8Vouw-fLvS666-V_6zZ4vHO0?usp=sharing
now with flask i need to display the output window to a ngrok page can someone help me with this please ping me.Thank you!
foo['fruit']
you mean like the actual 'fruit'?
anyone here know flask?
i also need help with flask anyone?
@scenic galleon you want to share the flask app via ngrok?
Hello everyone i feel like I've got difficulties with retrieving, many to many objects... Can anyone share some resources that i can read to understand exact logic..? I've tried official doc but it didn't go well i think... Please reply to this message or tag me in case you have resources to share... Thanx
Hello. I just started making a website and could use a decent bit of help with one section I'm trying to implement. If anyone would be able to help me it would be more than appreciated.
no actually in the output it shows the my camera and a yolov4 overlay which draws boundary boxed in the output in google colab now i need to show the page in ngrok
i need to setup flask i have imported it after pip install
thats what my ques is how to run it
is it possible to display the console window in flask?
Nope, not directly
okk
i will send u a screenshot so u can get what i am coming to say
just a min make command is running it takes 2-3 min
Okay
i need to display that output in a flask webapp
Copy the code into a .py file
okk
Hey @scenic galleon!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Yes a lot needs to be changed
and i am planning on running the colab in raspberry pi so i dont think i will ever go for local method
i tried flask with just a html <h1>hello</h1> and it worked but i dont know how to return the output
If you run it locally on your machine, with ngrok your machine will act as a server and you can access the page on the internet
but accessing the page is not a problem i ran flask with hello text in colab it worked!
but i dont know how to return the camera stream in flask
How does colab do it
i will send u a code snippet
`from flask_ngrok import run_with_ngrok
from flask import Flask
app = Flask(name)
run_with_ngrok(app)
@app.route("/")
def home():
return "<h1>hello</h1>"
app.run() `
this worked in colab
and here is the output link http://524fbbc33f9d.ngrok.io/
Yeah
but how do i return the video instead of hello
Call the function that is responsible to stream the video inside the route
i am new to flask i just learnt about it
this is the function name video_stream()
can u modify that flask code?
😶
if i put it like this
i get this
oo it does not return something it actually javascript so how do give it in flask
this is that function https://paste.pythondiscord.com/igiqatumor.properties
I am trying to learn Flask. I am new to python too. Could anyone tell me how can I learn flask?
guys im trying to make a porn site i need a way to check images
like face recog
but for tits'
I have a javascript file in django static directory. I want it to be minified when the env variable debug=false, how can i achieve this ?
wtf is this chat
dude make a seperate file for you html code
don't try to put everything in flask,
you can use render_template for the purpose
i tried but i get that file is not found
put the file in the same folder containing your code
that way you don't have to specify the path
I'm talking about html code
since i am in colab i draged and dropped in the root folder
just a min i will create a new colab notebook with a simple hello world html code and try
try with a simple image first
okk
done that still same error
code
`!pip install flask_ngrok
from flask_ngrok import run_with_ngrok
from flask import Flask, render_template
app = Flask(name)
run_with_ngrok(app)
@app.route("/")
def home():
return render_template('test.html')
app.run() `
if i do ls i am is correct dir
wait it worked when i putted the file inside a folder called templates
Thank you for the help now i will try with my original code
ok now there is a another problem it cant detect the javascript file for no reason
i tried putting it in multiple directories but it says in the website console that 404 file not found displayVideo.js
but i have another problem
if anyone could help me in this flask ping me thank you!
btw i dont get it if i do like this it will show the once camera they use but i want to display the cam of the colab comp when i am connected to everyone
how do i continuously update the temperature variable ?
Hi everyone
Can you please tell me about the best way to learn django
I mean how much time does it take to master it
what are the most important things that I have to know and learn
cuz I have been learning it and I'm not doing great with it
a good free course is great
@late fjord I found brad traversys videos on django and django/react to be pretty good
they're free on youtube
"If the product is part of an order that has not yet been paid and / or shipped, the product will not be removed and the Administrator will see an error message"
What should the code be to apply this? i did remove it .. but it removes everything regardless
@silent owl do you mean this https://www.youtube.com/watch?v=e1IyzVyrLSU
In this Django 2.x crash course we will build a polling app based off the one from the docs. We will look at apps, views, models, urls, the shell and more.
Code:
https://github.com/bradtraversy/pollster_django_crash
Gist With Commands:
https://gist.github.com/bradtraversy/06538da5924882b2cf30fa6310d505b1
Continuation of this app by adding cha...
did you know react before django
a little bit
and is this course full because I think it is really short
yeah I think so, I thought it was a series sorry.
the full stack react/django is more indepth but if you haven't really used react much before that I probably wouldn't recommend diving into that yet
the react course I guess includes django's api framework and react
yeah redux too
its for creating a global state system for using throughout your frontend application
thanks
if you want to rate yourself what do you choose
pro or intermediate I mean in django
junior
that's not in the list I guess hhhh
haha
yeah i work at an agency, not with django though
you haven't made a penny from django
no i'm learning it so I can transition from web developer to full stack software developer hopefully
Delete function
pick up orders on the basis of the product id, then you check for shipped / paid for all orders
ya
thank you for all this information
can I ask a question sort of private how old are you
plz tell me that the profile picture is not yours
I mean that's not you
that's danny devito
Hello, I am currently working on encryption in my flutter app wherein I am using RSA key-pair generator to get public and private key using the following code-
import 'package:rsa_encrypt/rsa_encrypt.dart';
import 'package:pointycastle/api.dart' as crypto;
//Future to hold our KeyPair
Future<crypto.AsymmetricKeyPair> futureKeyPair;
//to store the KeyPair once we get data from our future
crypto.AsymmetricKeyPair keyPair;
Future<crypto.AsymmetricKeyPair<crypto.PublicKey, crypto.PrivateKey>> getKeyPair()
{
var helper = RsaKeyHelper();
return helper.computeRSAKeyPair(helper.getSecureRandom());
}
Now I want to get the keyPair.publicKey in string format but if i print keyPair.publicKey, it shows "Instance of RSA publicKey" . How can I get it in string format??
how do people generally consume secrets from AWS secrets manager in flask? I'm flask apps into EKS that have instance configs, but as those get gitignored is there something people generally do in that case? what comes to mind is having an environment variable specifying "ENVTYPE=development || prod" and using boto in the prod case but is that in the zone of acceptable?\
Is there a good way to integrate celery with flask? My celery worker literally crashes all the time and on top of that requires extra setup to even run in a dev environment (eg. I have to open another terminal window/etc) and it's really annoying. It's also pretty glitchy in general imo and I was thinking I could just ditch celery in favour of regular threading
I have a Django models question on #help-chocolate. I don't properly understand derived attributes in Django (and why there's no standard implementation for that). Can anyone help me pls?
or any feedback on how to improve the question
how would you go about making something like this into a selectable list?
currently using flask. Tried some stuff w/ SelectField and FileInput widget but can't figure it out
even tried some html <select></select> fields
does anyone know how to have flask accept post requests that turn the parameter into an image?
like my client is sending a base 64 encoded image and i want to do some processing on that
Eh whos familiar with uwsgi?
Nvm got it to work
@dim wyvern you can add background image to the select option in its style
Hello, is it possible in django to call a view function with parameter from template?
hey
i cannot post anything to my API and i recieve "responded with a status of 415 (Unsupported Media Type)"
views
`from .serializers import ShitSerializer
from rest_framework import generics
from .models import shit
class ShitCreator(generics.ListCreateAPIView):
queryset = shit.objects.all()
serializer_class = ShitSerializer`
serializers:
`from rest_framework import serializers
from .models import shit
class ShitSerializer(serializers.ModelSerializer):
class Meta:
model = shit
fields = 'all'`
settings:
INSTALLED_APPS = [
'corsheaders',
'rest_framework'
]
MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
]
CORS_ORIGIN_ALLOW_ALL = True
hello everyone im basically wondering if it is possible to make a simple ui in python that i can host on my webserver
Then when i enter certain parameters it runs my python
does anyone know a site/tool that i can use to generate some nice looking webpages all i need is a few buttons a place where i can display some text and a submit box nothing else.i want them to look nicer than what i can do with html
@sage escarp if you actually want to code it yourself, you can use bootstrap. Otherwise theres plenty of drag n drop software out there
@onyx flume can you print your request
Its unsupported media type
So you're probably sending something other than JSON
can you suggest some because i've tried wix and it just gives me templates that don't work for me
this is my lame attempt just so you have a reference of what i am trying to achieve
I dont use drag & drop, so I wouldn't know. I would recommend coding it though - it will help you improve how you design your websites (and that something that has to be learnt, it doesn't come naturally for most).
And in that case, I'd simply say use bootstrap.
You keep all your html, and just change the styles of your elements.
yeah but i have a hard time putting stuff in the right places
i want stuff to be centered and it gets placed in weird places
Bootstrap will solve that for you ;)
You can have rows, columns, centred elements, and premade styles for your elements.
i was planning on making some things wirelessly controlled around the house with a raspberry and i want to make a website so i can have controll from everywhere and the hardest part for me is the site part since i have not worked with websites in my life and i can't find resource to the stuff i need
it took me a few hours to figure out how to make that button trigger a python script
=))))
do u need to control with mobile or from any devise
no i will just use my ip address in browser and there will be a password prompt
i plan to use it from mobile and pcs
okk
if u need mobile only u can go for blynk app to control u can trigger a python code with it
do u need it in local host or public?
hey guys
btw my button tries to access a link and in the views in django i just run my script from there and refresh the page dk if that is the way to do what i tried
Do you guys know how i can serve multiple files with flask? mainly .jpg and .pngs
I know it may sound like a silly question, but all the information online is quite complicated and not very well explained, so i come here
hello guys, anyone has expereince integrating react with django, with babel and webpack etc
how to make a pop up block when a image is clciked using html, css and js?
how do i resolve this problem with webpack
Hey all
I'm making webapps in Pycharm Community, but the js support just isn't great. Would anyone be able to recommend some options, or share how they do webdev where they might need to work on both the back-end/API and client side code in react for example?
I just used VSCode for that
I've only ever used VSCode for purely client side builds, gulp, npm, all that worked like a charm.
How's VSCode with multiple languages?
it works quite well
I'll give it a shot. It looks like if I want to continue using PyCharm for whatever reason and support js well + css highlighting, I'd have to buy Pro, which is fine too.
Thanks @dapper tusk
your import has an incorrect path
validate category
categoryRegex = re.match('([a-zA-Z]{3})',category)
if categoryRegex is None:
return {"message": "Invalid category"}, 401
Why if I test this it doesnt work
- The category name contains at least 3 characters
- If the category name does not meet the validation rules, an error message is displayed
post was wrong
i should have used POST instead
I am asking if it is important to learn django's template system if I am going to learn rest framework anyway
Hello, I use pycharm, I try to import pillow and it doesn’t work, I already downloaded pillow it said “Already downloaded pillow”, and when I try to import it, it says “pillow module not found”
it's module name is pil
oh
as pillow is a fork of PIL
I will try that
@quick cargo can you answer my question please
this one
If you're making purely a rest API using on JSON then not really
the template system isnt exactly hard though
I know but I didn't want to waste my time on it
cuz since I am not going to use it that means I will forget it
I am in the process of learning django
thank you for saving me time I am skipping it
I have another question
Can I also skip static files because I think that is included in frontend
sorry for the mention @quick cargo
I did “pip install pil” and “pip install PIL”
It said
“ERROR: Could not find a version that satisfies the requirement pil
ERROR: No matching distribution found for pil”
@quick cargo
I tried both PIL and pil
I guess you should import by saying PIL
you said you did pip install
and that's not what he or she meant
Because you said it is already downloaded
What did they say then?
It says “pillow module not found”
I tried to import
I will try to download and tell you
I downloaded it
I did “import pillow” and not “import PIL”
I thought they meant to download as PIL
I did import PIL and it worked
@quick cargo thanks it worked
can I ask you something
do I have to learn static files
since I am going to use rest framework
Can anyone explain me how to force flask in heroku to use https always instead of http?
@app.route('/api/GetData',methods=['GET','POST'])
def getData():
if request.method == "POST":
data = request.json
print(data)
return render_template('index.html')
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
it used to work a few days ago and now it doesnt...?
just add else branch
ight thx
You should really use the url_for function
Instead of render_template @true scroll ?
No, you would still use render template
but you would
return render_template(url_for('function_name'))
instead of the .index.html
whatever function you defined in the function that you decorated with @app.route('/index')
What would be the difference?
Right now? probably nothing but if you're building an API you can append queries to a GET request URL, you could use it to more easily build jinja templates, you can specify variables as arguments in cases where you might not know the route of the URL you need a template for until runtime (e.g. url_for('posts', post_id=post.id))
Really there's very little reason not to, there's no overhead really and it comes with Flask
@native tide I'm sorry I wasn't reading / thinking properly earlier
if someone could help me in #help-kiwi that'd be great 😄
hii people,
At this moment I am busy with a webshop made with python flask and I wanna do this;
"If the product is part of an order that has not yet been paid and / or shipped, the product will not be removed and the Administrator will see an error message."
The code you see here .. is that right good? because it don't works..
Hello everybody it's my first time on discord 😉
i'm not sure but i think the chanel is empty ?
I face at an issue with Django, in fact i've 2 model class and one is a foreignkey for the other but in a form to add a element in database the foreignkey display a database object instead of the return of the modelclass return
sorry for my english i hope you can understand me 😉
if i try to explain with more detail i've a model WeekDay so inside only 7 line with ID, Name, Number, DateTimeUpdate
and each line is a day of the week Monday, Saturday etc ...
i've a another model it's for the schedule, one line is for one event with Activitie (is an other model for detail of activitie) and Start Day and End Day.
In a form for add a schedule line everything is ok for choose an activitie (activitie_name are display in the combo box) but for Start_day and End_Day is not working instead of display Monday, Tuesday, etc ... it's display in the combo box WeekDay Object (1) for monday for example or WeekDay (5) for Friday etc
in the class WeekDay the return is WeekDay.name ...
I don't understand
I find my mistake (several days i face to this issue)... i'm a bullshit man sometimes it was my function for return WeekDay.Name i had write __ srt__ instead of str
@glass orchid next time try pasting code here
I have a question on DRF serializers
So the question is
I want to display limited fields of a manytomany field class.
Attached is the tried and tested solution but somewhere I feel like there might be a better solution.
It's not showing any message. And it deletes all products. Even it is not shipped or payed in the system.
And when it is payed or shipped its also deleting.
So it's not reading this code
Anyone who can help in setting up google auth with django web app ?
Hello, I have got problem with CORB when developing web scraping app (selenium)
and I have no idea how to fix it.
basicly web starts to ignore all my commands at one point.
Is anyone tell me what should I do in this or what this statement says -
{The links in the
FAQ section (questions in drop down) on this page are hard-coded (static). Make them dynamic to be configured from the location object.}
I am wondering how to make the input come from a csv for text file. And maybe even delete after use.
Like a line of names or phone numbers on a text file and the input goes down the list one by one every time it runs.
Hey so im trying to make a sticky nav bar with some code i found online but they used plain html css and js but im using react and when ever i try to run the website i get this error. this is my code ```js
import React from "react"
import {Link} from "react-router-dom"
import './App.css';
export default function App (){
const navStyle = {
color: "white"
};
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};
// Get the navbar
var nav = document.getElementsByClassName("nav");
// Get the offset position of the navbar
var sticky = nav.offsetTop;
// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
if (window.pageYOffset >= sticky) {
nav.classList.add("sticky")
} else {
nav.classList.remove("sticky");
}
}
return (
<div className="App-header">
<nav className="nav">
<h3>Logo</h3>
<ul>
<Link style={navStyle} to="/">
<li>Home</li>
</Link>
<Link style={navStyle} to="LogIn">
<li>Log In</li>
</Link>
</ul>
</nav>
</div>
)
}
@tacit anvil so react is trying to call the remove() methood of nav.classList, however it is undefined.
The code you're writing above the return statement executes before your html elements are returned and rendered
so document.getElementsByClassName("nav") probably doesn't exist at the point you are trying to assign it to the nav variable
That's my uneducated guess
so should i put the code below the return statement?
No, no code can be below the return statement
oh ok
Once return executes, you leave the entire App functional component
Yes. When you go to the website it works but it assigns undefined to nav (that itself doesnt crash). But when you scroll you try to use the remove() method of nav which is undefined and undefined does not have a remove method
so then what should i do?
you can try adding console.log(nav); after nav = document..blabla to confirm this
ok, then add it just before classList.remove() as well to see what you have there
oh now I probably see it
i did cosole.log(sticky) and that returns undefined
nav and sticky are probably undefined in your function, because they are not in the same scope
nav is still defined befire class.list.remove()
what about nav.classList
thats undefined
i run the code in a seprate html file and it ran fine
only when i tried to put it in react is when i get errors
document.getElementsByClassName("nav");
this should be the error
this returns a list of elements
so you're probably having a list of 1 elements
Hey guys, I have to switch my fastapi app over to flask, which I've never used before, I was wondering what the recommended way to use flask over multiple files is? Should I use blueprints?
you want to do classList on the element, not the list itself
when i tried to do getelement by id
i got that it was undefined
i think im using the wrong thing
Did you assign an id to the nav element?
It needs an id if you're going to get element by id
I think so
You should use id for something that is unique (you will probably only have one nav bar)
did you add the id to nav?
yes
Let's see the code again
import React from "react"
import {Link} from "react-router-dom"
import './App.css';
export default function App (){
const navStyle = {
color: "white"
};
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};
// Get the navbar
var nav = document.getElementById("nav");
console.log(nav)
// Get the offset position of the navbar
var sticky = nav.offsetTop;
// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
if (window.pageYOffset >= sticky) {
nav.classList.add("sticky")
} else {
nav.classList.remove("sticky");
}
}
return (
<div className="App-header">
<nav className="nav" id="nav">
<h3>Logo</h3>
<ul>
<Link style={navStyle} to="/">
<li>Home</li>
</Link>
<Link style={navStyle} to="LogIn">
<li>Log In</li>
</Link>
</ul>
</nav>
</div>
)
}
it says that nav is undefined
well
null
Not really sure
But I believe you should look into using states
Try moving nav and sticky into your function
You don't really need them in the outer scope right?
ok
did it work?
Hi, i'm currently coding a web application with django 3.0 and trying to override some functions of an installed django apps (Python social auth module). I want to do it because i want to change the default behavior.
I have found some method to perform overriding of a module (monkey patching) and try to implement it but i the following errors when i try to implement it :
File "/Users/***********/code/recrutlocataire/recrutlocataire/core/__init__.py", line 1, in <module>
import core.monkey
File "/Users/***********/code/recrutlocataire/recrutlocataire/core/monkey.py", line 6, in <module>
from django.contrib.sessions.models import Session
File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/models.py", line 1, in <module>
from django.contrib.sessions.base_session import (
File "/usr/local/lib/python3.8/site-packages/django/contrib/sessions/base_session.py", line 26, in <module>
class AbstractBaseSession(models.Model):
File "/usr/local/lib/python3.8/site-packages/django/db/models/base.py", line 107, in __new__
app_config = apps.get_containing_app_config(module)
File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 252, in get_containing_app_config
self.check_apps_ready()
File "/usr/local/lib/python3.8/site-packages/django/apps/registry.py", line 135, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Create my patch in the monkey.py file in my application directory:
Import the monkey file in the init file located in my application directory
It seems that I have this error because I'm trying to import the session module whereas the application loading is not done but i cannot find a proper way to do it.
Could someone tell me how can I perform it please ?
Let's see your code
@toxic flame
Here is my core/monkey.py
from social_core import utils
from social_core.exceptions import InvalidEmail
from django.core import signing
from django.core.signing import BadSignature
from django.contrib.sessions.models import Session
from django.conf import settings
def partial_pipeline_data(backend, user=None, *args, **kwargs):
pass
Here is my core/init.py
import core.monkey
Is anyone tell me what should I do in this or what this statement says -
{The links in the
FAQ section (questions in drop down) on this page are hard-coded (static). Make them dynamic to be configured from the location object.}
@toxic flame I just did and i got the same result
'core' right?
Hey everyone, just noticed mozilla isn't supported backdrop-filter: blur with css
Do we have any way implement it?
The filter CSS property applies graphical effects like blur or color shift to an element. Filters are commonly used to adjust the rendering of images, backgrounds, and borders.
can you use this?
filter: blur(5px)
hello need css related help!
Try adding import inside app.ready
https://docs.djangoproject.com/en/3.1/ref/applications/ has relevant info
hello i have a query,
actually im working on framework7, my questiong is im using css but it isnt reflecting unless i add !important keyword after style
as you can see in it, in mytable class, i have added margin but its nit reflecting but not the same with border
Typically the method is not added by default. You’ll need to add to the apps.py file in the required app and then modify settings.INSTALLED_APPS to include AppConfig from your app instead of app name
Hi, i have this flask code. ```py
Keep Repl Alive by creating a webserver for uptimerobot to ping every 5 minutes
from flask import Flask, request
from multiprocessing import Process
app = Flask(name)
html = """
<html>
<p>
message id
</p>
<textarea id = "message_id"></textarea>
<p>
message content
</p>
<textarea id = "message_content"></textarea>
</br></br>
<button id = "submit" onclick=submit()>
submit
</button>
<script>
function submit() {
fetch(
'https://The-Info-Broker.zorycroft.repl.co',
{
method: 'post',
headers: {
'Accept': 'application/json. text/plain. /',
'Content-Type': 'application/json'
},
body: JSON.stringify(
[
document.getElementById("message_id").innerHTML,
document.getElementById("message_content").innerHTML
]
)
}
)
}
</script>
</html>
"""
@app.route('/', methods=["GET","POST"])
def index():
if request.method == "POST":
print(request.get_json())
return html
``` im trying to get the contents of the two text areas in my webpage, so im setting the body of my post request to be [document.getElemebtById("message_id").innerHTML, document.getElemebtById("message_content").innerHTML] but i just get ['', ''] back no matter what i type into the textareas?
nvm i got it
anyone use streamlight? seems really easy and intuitive. thinking about doing a few ML projects using it
thoughts/opinions?
can someone please guide me achieve this?
I want to setup an events system with django-channels
like discord
whenever an object is created to the database, I want to send an event
to the client
import json
from channels.generic.websocket import AsyncWebsocketConsumer
class BoxEventsConsumer(AsyncWebsocketConsumer):
def __init__(self):
super(BoxEventsConsumer, self).__init__()
async def connect(self):
# add the channel_layer to the requested box's group.
# group names are unique as they include the box-id
self.box_id = self.scope['url_route']['kwargs']['box_id']
self.box_group_name = 'ws_box_%s' % self.box_id
await self.channel_layer.group_add(self.box_group_name, self.channel_name)
await self.accept()
async def disconnect(self, close_code):
await self.channel_layer.group_discard(self.box_group_name, self.channel_name)
async def receive(self, text_data=None, bytes_data=None):
# send event data to every channel_layer
# that is a part of the box's group. global events
# such as box-creation must be sent to every user
json_data = json.loads(text_data)
formatted = {'data': json_data['data'], 'event': json_data['event']}
await self.channel_layer.group_send(self.box_group_name, formatted)
async def fire_event(self, event, data):
# we send events to the box-groups from the
# server. (data-binding is always outbound) so we don't need
# to bother to receive data from clients
await self.send(text_data=json.dumps({'data': data, 'event': event}))
I wrote this consumer so far
now, I need to overwrite a model's save method and then use the fire_event method of the consumer to send data right?
How I do drop down section which is hard-coded static into dynamic in python
Are you using a framework ?
@near bison which framework do i use for this?
I don't actually fully understand your query
@near bison please come in #help-honey
I have a javascript file in django static directory. I want it to be minified when the env variable debug=false, how can i achieve this ?
How to create pagination for multiple serializers in single API in Django Rest Framework?
this is not a java server
java is not even web-development 
Some people think java and JavaScript are the same thing
Hello I have a django question, why is this code producing users_status_rocketchat() takes 0 positional arguments but 1 was given?
def users_status_rocketchat():
api_url = ROCKETCHAT_DOCKER + "/api/v1/users.presence"
# Login admin
login_response = login_rocketchat(os.environ["ROCKETCHAT_ADMIN_USERNAME"], os.environ["ROCKETCHAT_ADMIN_PASSWORD"])
admin_id = login_response["data"]["userId"]
admin_token = login_response["data"]["authToken"]
# Set headers
headers = {
"X-Auth-Token": admin_token,
"X-User-Id": admin_id,
"Content-type": "application/json"
}
api_response = requests.get(api_url, headers=headers).json()
# Logout admin
logout_rocketchat(admin_token, admin_id)
return api_response
from django.urls import path
from django_rocketchat import views as django_rocketchat_views
urlpatterns = [
path('api/rocketchat/users/', django_rocketchat_views.users_status_rocketchat, name='users_status_rocketchat'),
]
Hey all! I’m brand new to Python and was wondering if I learn this language is it possible to use it for Web Development?
yes
Awesome! Thank you 🙂
well this was easy, but my problem is not quite? Maybe I should add decorators for GET and POST requests?
No idea, maybe open up a help chat?
Hi everyone, I was wondering if anyone has tried using the pandas HTML table and run into an issue with the styler?
It seems like it puts all the cell id's on a single row, which breaks on Chrome when exceeding 4096 cells
Hi, I'm trying to implement a new LoginForm in Django. Her's what I'm trying to do. The code does work, but when I redirect to 'Profile' in which I made a markup <h1>{{Log.username}}</h1>, it doesn't show me user's name . Could someone explain me why ? Thanks !
from .forms import UserRegisterForm, UserLoginFoo
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
def register(request):
if request.method=='POST':
form= UserRegisterForm(request.POST)
if form.is_valid():
form.save()
return redirect("PagePrincipale")
else:
form=UserRegisterForm()
return render(request,'Utilisateurs/Inscription.html',{'Usr':form})
def Loginin(request):
if request.method=='POST':
Log= UserLoginFoo(request.POST)
if Log.is_valid():
return redirect('MonProfile')
else:
Log= UserLoginFoo()
return render(request,'Utilisateurs/Connexion.html',{'form':Log})
def Profile(request):
return render(request,'Utilisateurs/Profile.html')```
forms.py :
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import authenticate
class UserRegisterForm(UserCreationForm):
class Meta:
model=User
fields=['username','password1','password2']
class UserLoginFoo(forms.Form):
username = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control','placeholder':'Username'}))
password = forms.CharField(widget=forms.PasswordInput(attrs={'class':'form-control','placeholder':'Password'}))
yourfield = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control','placeholder':'yourfield'}))
def clean(self, *args, **kwargs):
username = self.cleaned_data.get("username")
password = self.cleaned_data.get("password")
#user_qs = User.objects.filter(username=username)
#if user_qs.count() == 1:
# user = user_qs.first()
if username and password:
user = authenticate(username=username, password=password)
if not user:
raise forms.ValidationError("This user does not exist")
if not user.check_password(password):
raise forms.ValidationError("Incorrect password")
if not user.is_active:
raise forms.ValidationError("This user is no longer active")
return super(UserLoginFoo, self).clean(*args, **kwargs)
I believe you need to provide Log in the context
Yeah but I redirect to 'MonProfile' So i can't give an extra arg
You can redirect with arguments?
@dire fractal did you saw my question? I am only a beginner to this kind of level 🙂
No I can't redirect with arguments
Not a clue what rocketchat is, and if so can you provide the exact line its pointing to? As well as some form of docs around it (What your using)
Well Rocketchat is like a discord, I am just using this API: https://docs.rocket.chat/api/rest-api
You will need to allow for arguments
How?
return redirect('MonProfile', log=Log) will be the syntax for redirect and can I see your MonProfile route? Just the urls.py entry and the first few lines of the func
Also what line the error points at specifically
Its a route tho correct?
Yes
Give me a minute to sus the best way to take a form
Can I see your route definition?
Hey @patent ingot!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Your views.py file is where they normally live
Here you go: https://paste.pythondiscord.com/bobafodeko.php
from .forms import UserRegisterForm, UserLoginFoo
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
import inspect
def register(request):
if request.method=='POST':
form= UserRegisterForm(request.POST)
if form.is_valid():
form.save()
return redirect("PagePrincipale")
else:
form=UserRegisterForm()
return render(request,'Utilisateurs/Inscription.html',{'Usr':form})
def Loginin(request):
if request.method=='POST':
Log= UserLoginFoo(request.POST)
if Log.is_valid():
return redirect('MonProfile', log=Log)
else:
Log= UserLoginFoo()
return render(request,'Utilisateurs/Connexion.html',{'form':Log})
def Profile(request):
return render(request,'Utilisateurs/Profile.html')
This one?
Which one does the 'MonProfile' redirect point at?
This view
Which function
Loginin
So it just redirects at itself?
Can I just ask the design choice behind that?
You appear to be able to avoid a redirect, and you already have the form
I'll be honest im getting a tad confused
No
I actually try to get into the 'MonProfile' file which means 'MyProfile' if the user is authenticated
So it doesnt redirect to the loginin function. So where does it redirect, is MonProfile a template?
and with the args, I can add some features on the 'MonProfile' Page. Imagine if the users name is Mark, I'll be able to add Mark on my geml page
No it's Just a route
path('admin/', admin.site.urls),
path('', NewAppli_views.Home, name="PagePrincipale"),
path('Inscription/', Utilisateurs_views.register, name="S'inscrire"),
path('profile/', Utilisateurs_views.Profile, name="MonProfile"),
path('Connexion/',Utilisateurs_views.Loginin,name="Se connecter"),
path('Deconnexion/',djauth_views.LogoutView.as_view(template_name='Utilisateurs/Deconnexion.html'),name="Se deconnecter")```
It's its name sorry
We got there eventually, it actually goes to the Profile function which is what I was looking for... 😂
Do you need anything other then form_instance.username?
from the form
username, password, and whats the name of the other one?
Code
username, password, code
Yup
cool
and since password n such, we now need to use a POST method, since GET would mean url encoded and url encoded passwords arent good
I assume you have a user profile?
Does your form talk to said profile
I think if so, it'd be easier to call your Profile route with the user profiles pk (id) and fetch data that way rather then try mess around with post redirects
@uncut spade
How could I do it?
wdym?
Your form is used to login correct?
So it should be checking agaisnt a stored user profile or somethin to ensure its valid
The idea then is if it is valid, you just provide the user profiles unique primary key as a url param
Then in Profile you fetch said user profile using the primary key
If that makes more sense
try
def users_status_rocketchat(): -> def users_status_rocketchat(request):
Since its a route, all routes get given request as a param
@patent ingot
Ok, i'll try
how do i make an infinite loop run alongside a django webserver or is this not possible and i should just make it a separate program
threading™️
Hey thanks, but now I would like to know how to return json object properly (json requests.get function from request library in python):
api_response = requests.get(api_url, headers=headers).json()
# Logout admin
logout_rocketchat(admin_token, admin_id)
return api_response
Sorry, I am working on this for too long time...
Generating thumbnails for hls streaming links :
What could be the effiecnt way of getting a screenshot of an hls live streaming link in python. I Have tried reading through different packages like this one ffmpeg python lib, but I haven't seen what I need exactly.
A django solution would be better.
REASON FOR THIS
Am having a frontend which has a list of TVs, so these TVs need thumbanils before pressing on them. So in the backend if we could have a possibility of generating them, then we pass them through an API.
?
Hi I'm asking for an advice about moving from django to fast api
I haven't mastered dj I'm just a beginner
And I think that FastApi is the future of web frameworks
I mean, FastAPI is just REST API so if you want to provide UI, you need to provide JS Frontend
@zealous siren I don't think someone is going to use django template system for his website
then FastAPI won't work for you
why
because it REST API
Hello web-devs... I don't know anything about front-end and I main Python; any tips for making a simple CRUD app with Python/Flask look like this? Would I be better off learning React?
https://static.vaadin.com/directory/user1373/screenshot/file2102953444183057054_1530141595507ScreenShot2018-06-28at2.16.26.png
yeah learn react
im not sure where to post this but i have a UserWarning: Current server name '0.0.0.0:5001' doesn't match configured server name 'localhost.localdomain:5001' issue
ive checked on stack overflow
idk what else to do
this only happens when I run my docker container
it's a different kernel so the domains don't resolve the same
i did add this in my run file though
&& echo "0.0.0.0 something.website-name.com" >> /etc/hosts
sooo
i have to do this Use --network="host" in your docker run command, then 127.0.0.1 in your docker container will point to your docker host. @grizzled barn
Okay cool I was about to ask why you were using 0.0.0.0 instead of 127.0.0.1
so I guess it isn't equivalent to localhost
i meant do i have to do this* @grizzled barn
Oh lol yes I think you do
idk what they mean by use 127.0.0.1 in your docker container
@grizzled barn any ideas xD
i even added DEFAULT_FROM_EMAIL in settings.py but it still takes the from email from EMAIL_HOST_USER
@swift sky sorry I think I'm missing something myself
maybe ask #networks?
I'm pretty new to docker myself
is it closed now?
@late gale sorry my mistake i thought this was a help channel, not a topic channel. it was never close sorry
ook i fixed my issue
no no its ok
DEFAULT_FROM_EMAIL = 'My Doamin <no-reply@mydomain.com>'
is it written correctly ?
it shows My Domain in from email but it still shows me the EMAIL_HOST_USER as from email
let me try to screenshot
please mention or reply
so i can get notified
django vs flask. choose only one
Django
flask FastAPI
Django!
real answer: REALLY depends on the use case. flask is way simpler, fastapi is way better for APIs, Django if you want to make a large server-rendered web application
if you want make API, use flask.
if you want to render clientside i personally would go with fastapi though i have little experience with djanog to say it wont work
No, FastAPI is far superior for API
hello! i was wondering if there was a way to put multiple entrypoints into a gcloud instance
i wanted to host a web server and discord bot simultaneously on the same instance (if possible)
in the references there doesn't seem to be any mention of it but i thought i'd ask anyway
so im assuming that you cant put pull .env variables into a dockerfile
how are you supposed to handle that then? like i have a && echo "0.0.0.0 some.site.com" >> /etc/hosts
Flask website ideas?
dildo marketplace
bruh
Easiest way to change password in auth_user table in django? Seems like a million ways to do it, but whats the right way?
@swift sky you can pull arguments into your dockerfile from the outside using ARG or you can get env vars into the final container in a multitude of ways
i would advise you to use a docker-compose file for building where you can then easily add env vars as build ARGs
Im currently using the env file method
But this question was regarding the build file
Which the env file method doesn't work
Idk. I'm getting a 502 bad gateway
So somethings not hooked up. But im too tired to fix it
docker compose automatically gets .env vars and makes them avaliable in the docker-compsoe with the ${} syntax, which you can then pass into the build using the ARGs
example docker-compose
version: "3.8"
services:
web:
build:
context: .
args:
- TOKEN=$TOKEN
works if the .env is in the same or a parent directory
gn
Hello Guys
Do anybody Know 3D reconstruction from 2D images using python?
using SQL only?
I would suggest you refrain from doing that
use User.set_password instead
I did, but there's like a million different examples. Also don't want to force logout on password change either. I read it clears the token when you change the password. Im doing front end verification for password and retype password so don't need to handle that on the backend.
I went as simple as possible, but hopefully not to simple. I just know the auth user table has a lot of built in stuff
Guys, im kinda new into backend and after a long long hours my code kinda ugly works. I tried to filter django rest framework api with url params. This is what it looks like
# views.py
class PostViewSet(viewsets.ModelViewSet):
serializer_class = PostSerializer
queryset = Post.objects.all()
permission_classes = [permissions.IsAuthenticatedOrReadOnly, IsOwnerOrReadOnly]
def get_queryset(self):
query = dict(self.request.query_params)
count = self.request.query_params.get('count')
user = self.request.query_params.get('user')
if count:
return Post.objects.all()[:int(count)]
if user:
return Post.objects.filter(author__username=user)
return self.queryset
# serializers.py
class PostSerializer(serializers.HyperlinkedModelSerializer):
author = serializers.ReadOnlyField(source="author.username")
class Meta:
model = Post
fields = ["title", "content", "date_posted", "author"]
#urls.py
router = DefaultRouter()
router.register(r'posts', api_views.PostViewSet)
now i can filter data like
# get data of 10 posts
http://localhost:8000/v1/posts?count=10/
or
# get all posts of specific user
http://localhost:8000/v1/posts?user=AnyUser6000
but i feel like "i packed a lot stuff in the wrong place", also this solution doesn't allow me to specify url or combine params like http://localhost:8000/v1/posts?user=AnyUser6000&count=10 to get 10 posts of specific user and if i add more f.ex 10 different filters i'll end up with bunch of if statements. Could someone tell me how it should look and guide me how should i organize stuff and to what i should pay attention? Thanks!
how do i put my database generated via python to my sql database from django?
does anyone know how to convert webelement in python selenium into an integer?
yes.
dont ask me how to do it. idk cloud stuff yet. ive just seen it done before tho
hello
can some one tell me how to create a server in my computer and then use that server to fetch data in another computer from that server
using django

Django or Flask ? I am junior
Can somebody help me in this using Flask?
A web application (only API) in Python 3 with one endpoint that accepts (x, y) coordinate values on a 2D plane.The response is a function of the current (x, y) input as well as the previously passed values.
Response:Iff it's possible to make a square using any of the four points plotted so far, return the 4 points formatted as a string.
Otherwise, the response is just an acknowledgement of the input.Once a successful response is returned, further calls to the API should just return the same response.
Bounds:*
Assumption 1: All input points can be assumed to lie in the positive quadrant.* Assumption 2: You only need to consider axes-parallel squares (no tilted squares).
Error: The included URLconf '<module 'app_users.urls' from 'D:\Projects\school website\teaching_blog\app_users\urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
pls help
Better do it in APIView something like this.
I have added pagination as well. Remove pagination part if not interested
tkinter vs pyqt vs kivy for a small project?
#user-interfaces btw and i would choose tkinter for a simple okay looking UI
wanted to know if i can add django csrf_token when im using form in reactjs cause i get 403 error (CSRF cookie not set) if not is there any way so that i can pass this error?
So i only allow 1 domain as input, how would i check if the form input is the specific domain?
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
Can you please provide your code?
FastAPI is fast and minimalist when compared to Django. But in my opinion Django is Best as it contains large user base and lots of online resources. (Haven't worked on Flask)
But I guess you can do anything you want with fastapi
is that right ???
as a beginner do you think I should learn django or fastapi
Django provides ORM, Migrations, MVC pattern where as FastAPI is dedicated to backend APIs
orm is the best thing in django but I can use sql alchemy with fast api
"MVC" what is this ???
Its actually upto you .. in my opinion you should try django..
I tried django
Model View Controller
what makes django good for big projects ???
and what makes FastAPI bad for big projects ???
I think this would give you better idea .. https://codeahoy.com/compare/django-vs-fastapi
Compare popular Python web frameworks Django and Fast API. Explore their differences, similarities and how to choose between them.
thank you
do you know both ???
@oblique kite I read what you sent to me thank
Just another question if you are going to build amozon like website you choose django or fast api, also thank you for everything
I work full time on django but tried FastAPI once
I think django for now as I already mentioned you would get help instantly from internet because of its user base .. once FastAPI gets bigger then yes FastAPI
thank you so much
Getting error?
no i was dumb and forgot to add the infinite loop in my function 😅
lol 😄
Sorry to disrupt this, but i cannot completely agree with @ virus02. To a beginner, Django feels much easier, because it hides a lot in a hidden blackbox. Django is perfect for projects like a simple CMS, or a tiny ecommerce website, but imho, it becomes a nightmare as the project grows. The models are coupled with the database, making everything hard to test. If you're a complete beginner, I would go with Django, sure - it's easy to learn and you can get a working product quickly while understanding fundamentals like request handling, validation or database design. But if you're aiming for a bigger project, a simple framework (like Flask or FastAPI) on top of which you can build a cleaner architecture, will be a relief in the long run. But it obviously requires some understanding of why you're designing things one way or the other.
My point was, if you decide to go the FastAPI way, it will be harder at first, but I believe you will learn a lot more along the way.
just wanna know how can i pass it or how to add it because whenever you dont use {% csrf_token %} in your form django gives error 403 cause of the csrf_token and you cant add {% csrf_token %} to your reactjs app it gives a kinda error because of {%%} so seems like i cant mix the django template engine with jsx. so how do i add the csrf_token?
and of course i need a little explanation😅
I agree with you for some extent but as you have mentioned for beginners Django would be great. Cheers 🍺
boys what does the "||" stand for in js
like if i write
if (a =b || c=a)
what does that stand for
or
bruh
I have never served react within a django template, is it easier or harder than having django just as an API?
I mean, it's that way in like 9/10 languages you can come across...
have no idea :d
i have this js course in my uni and i have to take it
i cant graduate if i dont
Could anyone tell me the best resources to get started with web dev
I have a Flask app that's doing difficulty analysis on Chinese texts given to it through a request.
It uses a large amount of data with Chinese word frequencies to do so, and I'm not sure what the best format would be to have it be fastest.
(approx. 5000 lines CSV, 1mb JSON)
For this sort of work, would it be fastest to use:
- csv
- json
- a python dictionary
or some other format?
Thanks in advance!
Hello how do i use the index method in the django template language
If you are using it inside for loop then you can use forloop.counter variable
Oh thank you so much
I'd like to ask a question if possible I wanna deploy my Django website on either Heroku , Digital Ocean or Blue Host . what do you recommend please for top performance, security , pricing and of course support ? thanks
I have used digital ocean on credits, and have helped some of my students use heroku.
I found digital ocean was much simpler to deploy on (more similar to other ways I had deployed, at least), however it is not free. From what I understand heroku is free and is a go-to for many users, there are also many guides on this. Digital ocean also has a cool mascot.
They should all be similar in security, I would expect digital ocean to have the better customer support. They have their own guides online and they are a paid service.
Alternatively I would also recommend AWS EC2, as they are obviously reputable and I had a good experience with them. It was also quite cheap (It ended up being less than $1 per month after several months of usage)
@late gale
anyone use streamlit?
im have a super stupid mistake and cant figure it out
what the site gives me
import streamlit as st
import numpy as np
import pandas as pd
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier```
how i imported the libraries
am i forgetting something
Thank you didn't know about AWS EC2
and btw should i host my static files on aws does it really affect performance or it doesnt matter
did u install the library ?
lmao
but let me do it again

"requirement already satisfied"
why is it not finding it
what framework is it django or flask?
streamlit
its even simpler
Streamlit is an open-source app framework for Machine Learning and Data Science teams. Create beautiful data apps in hours, not weeks. All in pure Python. All for free.
im just dumb
this is sort of the standard way of doing it, sadly I do not have much experience here. I self host and have my web server (apache in my case, but I do not recommend it) serve the static files.
If you were using AWS anyway, I think it would make sense to set up a pipeline for that, I believe S3 is the service for this.
wait why does it say this:
Installing collected packages: sklearn
Successfully installed sklearn-0.0
0.0 
I like your enthusiasm
oh so i've to host my static files then thanks
is AWS free or paid
it is paid, but it has free tier. I used the free tier and it charges you for resources you use beyond the limits of the free tier. For me it was only a few cents per month, but it is based on usage. (My usage was VERY low)
cool glad there's a free tier so i can try it first
One more question sorry to ask alot but I've recently heard about PWA i found it cooler than normal sites do you recommend to change my site into PWA or not worth
I'm doing more researches recently on it before my judge
I cannot say I am very familiar with what a PWA really is
update: I finished my google research.
yeah, that would be really cool. I do not think it is anywhere near essential though. It appears the main difference is that a PWA is meant to also be installed as a local app. Which as a user is something I usually want to avoid, except for with very special apps 
I will also add that if you are using a JS framework, they are often made with this sort of thing in mind. I.e React yells at me if my site is not install-able.
ahhhhhhhhhhhhhhh why does it run when i call it from the terminal
streamlit run iris_app.py

how come it didnt run when it deployed it from github
Relax.
ok
Most sites now are using PWA such as google and twitter but i don't know i gonna use with django so but i gonna give it a try and see what's happening
also @acoustic oyster sorry to ask but help this poor man lol
i didn't know streamlit until yet so i'm not knowledgeable
its ok ill just cry 
maybe i shouldve learned django or flask instead
they said this was easier
Chill, learn what you you feel right
Sadly I am not familiar. BUT: this is how you learn. When I started out, I remember obsessively trying to get small features to work for hours on end. All while aggressively googling. Most of what I know is from this method. Over time you build the confidence that no matter what the problem is, you will be able to solve it through troubleshooting and likely a lot of googling.
yes this is true
i totally agree with fisher
this how everyone learns
this is how education goes
do mistakes
its probably just a package error or version error
I've also found that PWA can use a shortcut example i can install the web on my android /IOS and can add a post by just long press on the icon and it directs me to the page which i can create the post immediately, that sounds pretty amusing
Yeah, it would certainly be cool. I do not have much experience with it.
The front end for my django sites are always in React nowadays anyway
Wassup guys I'm trying to web scraping a horoscope website but this clickbait abomination requests clicks all over the place to get each of information bit. U guys have an idea how to deal with this without create bunch of html file in memory?
I'm just trying to make a File server with flask lmao
tell me when you find out how

more or less im useing flask as a way to run a website, and from the site it links to a directory where anything in the directory you can download
im just trying to think of cool projects to make
kinda run outa ideas
im in a similar boat
i think im gonna use heroku to host
and streamlit if i can ever get it to work to do most of the work
i guess i could try django but im on a crunch
maybe next project
or i could stay up

lol
I'm using a jsonfile to store my websites information. It's never going to be more than about 600 lines. Is this acceptable, or should I move to an SQL database? Probably postgres
SQL Database
But why? That's like bringing sledge hammer to hammer in a nail
Why are all my front ends react? I like React and usually need the functionality.
I still do static sites if i really do not need much on the front end, but that is only if there is not much of a front end.
No, using Django as backend
Ohhhhh. Yeah, I agree with that.
Lolol, tbh that is how it feels nowadays xD and yes I need to learn fastapi
Hello there I'm having a question regarding implementation of dynamic modals in flask. What I'm looking to achieve is create a password protected modal, that is when a user clicks a certain button on his dashboard, a modal pops up which asks him to confirm his password, and when he does displays some secret data. I'm wondering how to implement this. not the modal as such but the password protection of it. Basically that is really secure data and it'd be nice to pass it to the template only when the user confirm his password. What's a possible way of acheiving this?
Does selenium actually interact with the website or does it simulate what would happen if you do certain inputs?
Hey how do u guys know where a website is taking its data from
For example covid19.who or sth
it automates your browser
Ahhh okay thank you
Hey guys, I am developing web scraping app and at one point browser stops listening to my code CORB is blocking it and I am stuck.
ping me
yeah cors
you can't do much about it
Any django user ?
Yes
Hey, I am trying to figure out an answer to the following question:
Say you have frontend for a social network and all the backend layed out. The app contains a search bar in which you can search basically everything, a user, a page, a group. How would one make an optimised search in the database as, potentially millions of entries would exist. So lets say I typed the word: Kiwi, it would have to search all the users, pages, groups and return with the ones that contain that string in their name. Having multiple tables with so many rows it would take enough time to make the app look slow. How would one tackle with this issue?
@rustic pebble You should look into full text searching. Most databases support it, or you can use an external search provider like algolia or elastic search.
whats the best help guide for web development?
Check your models
Hey guys! I'm new to django, and I'm wondering if it's possible to to detect if a session has ended, and if it has, count a timer for, like, let's say a week, and if the session has never been reconnected, then delete the model?
So for example, if I have a model that has a code, and if I add the code to the url as a param, it will display the models data
Hey guys I'm a new in python and I'm messing around
If I make a website using flask, is there way to get a unique domain name for free. By that I don't mean like commerical sites like wix, I want the server to run on my PC, it won't be a 24/7 server or anything just a server that will run when I run the file.
and if that code hasn't been accessed for a week by anyone, then delete it?
Its possible in flask
Idk about django
ah okay
Id = models.AutoField(primary_key=True)
Username = models.CharField(max_length=100)
FullName = models.CharField(max_length=100)
Email = models.EmailField(max_length=150)
Contact = models.IntegerField()
Password = models.CharField(max_length=100)
Status = models.IntegerField()
RegDate = models.DateField(auto_now_add=True)
UpdationDate = models.DateField(auto_now=True)
class Meta:
db_table="Students_info"```
***How many values i need to pass as user input here ?***
Hey people
I'm building a newsletter
How would I implement mailchimp in Flask?
(if this is not the best way to do a newsletter in python please tell me)
all from Username to Status...
also you don't need to capitalise the field vars.
Django unique, null and blank CharField giving 'already exists' error on Admin page
What should I do...?
Hello. I just started making a website and could use a decent bit of help with one section I'm trying to implement. If anyone would be able to help me it would be more than appreciated.
Hi all. With Flask, I know I can get a URL named param with a request.args.get(<key>)
What is the best way to get the first value of a URL param if there is no key in the URL request? For example: http://mysite.com/?5555
did you makemigrations and migrate?
whats the best guide for html and css?
How do you listen to Post requests from a desktop application?
5555 would be the key in that case, it has no corresponding value
So there is no such thing as param with just a value instead of a key/value? I was asked to handle a URL like the one I mentioned above, and I was scratching my head.
I mean it's fine, you could just iterate through the params and see what's there
whether it's the key or the value doesn't seem like it should matter
hi
I want to store usernames to mysql db and I also need to create files for the usernames. space characters take up space that's just one example. what should I do?
I guess, you can just ask your question
So I was working on my review website and I wanted to add a feature that would allow people to vote. The concept would be that by pressing an icon it would pop a page up and ask them to review the movie out of 100 and then add to a list of everyone's rating and average them out and display it in a circle that would be animated to show the rating.
@silver iris I've just read your message, I am not a complete beginner, and I am not a pro, I know how to handle requests...... so what do you think
I also know what apis are
I keep seeing @silver iris is typing...
It really is a matter of personal preference. With Django, the framework does a lot of hard work for you at the expense of enforcing a certain way of doing things. Lightweight frameworks like Flask or FastAPI let you create your own architecture that may or may not be better than what you'd get out of the box with Django.
I'm not trying to say "Django is bad", I'm not trying to say "FastAPI is great". Anything you can do in one framework can be done in the other.
I've seen larger Django projects become an unmaintainable mess where every change can be breaking. This goes hand in hand with what I've said in the other post - building a testable codebase with django is harder than with a simpler tool.
On the other hand, I do not have experience with FastAPI on a large production-level project. Maybe it will prove me wrong.
thank you so much @silver iris I now know why I kept seeing marinovanec is typing... thank you so much, I myself decided to move to fastapi because I think it is going to make the trend soon and I want to be the one who knows it, I think I took a lot of your time, thank you so much 💝
I also looked for tutorials I didn't find any, I guess I should go for the docs what do you think
I think I've seen something about a tutorial in the docs
but I can't say how good or bad it is
their docs are well above average, though
thank you
I wonder if anyone can help me. I have a form that is posted, and it contains two forms. One for user registration, and another for a product that will be created and stored in the database. I then need to post one of the forms to another routes file called register, and once that is done, I then need to add the product in the original route to the database. I am currently using requests to make the post request, but I need a better solution.
@editor_bp.route('/editor/create', methods=['POST'])
def create():
product = ProductForm()
register = RegisterForm()
if not (register.validate_on_submit()) or not (product.validate_on_submit()):
return redirect(url_for('editor.edit'))
if not requests.post('http://127.0.0.1:5000/auth/register', data={'email':register.data.get('email'), 'password':register.data.get('password'), 'store_name':product.data.get('store_name')}):
print('invalud post')
return redirect(url_for('editor.edit'))
@auth_bp('/register', methods=['POST'])
def register():
## some code here
How can I post RegisterForm() to register without using requests library? is there a way to do it in Flask without another library?
Because when I use requests and login the user on the register route, it doesn't login the user correctly
if it is the same app, no need to use http request, just import register as a module
or if it is in the same file, just call register() with your arguments
then you also do not need to route the register
why django always show ValueError: attempted relative import beyond top-level package whenever i try to import a module from main project directory?
structure is :
you have cross import?
oh, no, sorry
you are trying to import from outside your root dir, probably
your root dir is where your manage.py sits
do you have __init__.py in all dirs?
which one is the root?
oh,and did you add your module to the APPLICATIONS in the settings?
its not an app i want to import, it another package holding critical processing
I am not sure, but I assume, you still need to add it to the APPLICATIONS
Installed apps? in setting.py?
yes
no no, that only contains django apps, not the custom modules
lmao oky
but you may need to put into a dir, I do not think you can use file name in the installed apps
this is pissing me off, it should import from other dirs, if i give the absolute import then it works but then pycharm complains that no relevance found
I didn't even think of that, thanks @olive tiger !
glad to help
generally, it is not encouraged to use relative imports
cannot help you with pycharm, I do not use it
thanks anyway 🙂
what error are you getting when you try to run it?
solved! It was my pycharm configs wrong, the content root was one dir level above than the original one. Lmao spent almost 2 hours for this
I knew it, never use ide's
There are tutorials on FastAPI in YouTube
Django unique, null and blank CharField giving 'already exists' error on Admin page
What should I do...?
I ve used django extensively. How can I help?
Hi everybody! I built a small django webapp for collecting and organizing sport activity data using garmin fit or gpx files. It is designed to run locally to avoid uploading sensitive health and tracking data into any 3rd party cloud. I would be happy to receive some feedback 🙂 https://github.com/fgebhart/workoutizer
What about Flask ? Have anyone tried it ?
Hello who knows django really well?
Because I really need help now I have been stuck for 4 days on the same problem
@native tide #❓|how-to-get-help
I have already post :c
@native tide i been working with django for a long time, i can help you
Niceeee
that project looks really good, well done!
how would you put a python project into the web?
Hi there, I need some help with Django and HTML... first off, I know it's possible to put several forms inside another form, like this:
{{form1}}
{{form2}}
{{...}}
</form>```
I made something similar to this:
```<form method="POST">
<div>
<form>
{{form1}}
<input type="submit" value="submit1">
</form>
</div>
<div>
<form>
{{form2}}
<input type="submit" value="submit2">
</form>
</div>
<input type="submit" value="submit3">
</form>```
When I click "submit3", nothing happens. I already tried putting `action="."`, using jquery `submit()` to do something. Consoles on both Django and browser don't say anything.
The above forms are displayed as a sort-of slideshow, showing the proper div. Submit1 and submit2 just post the form, save the data and clear the form fields, without reloading the page.
Sent my question to #help-burrito
what the fuck
I can't import flask
it hangs
but when I type "python" to console and import it there, it works
import flask
import traceback
import requests
import logging
import ujson
this is my code, when I remove the flask import it works
when I don't, it just stops here:
but works here
did you pip install flask? What shows up when you do pip list (or pip status, I forgot)
If I were you I would change the framework for flask or fastAPI. Let django be 🦹
whats the difference between the two?
You mean django and flask or flask and fastAPI
Well, flask keeps things simple. You're master of your own.
|Have you ever tried to find smtn in django docs?
It's a disaster
nah i have never tried that lol
im new to python and i want to learn a framework instead of wasting my time doing random stuff
lol
If you want custom behavior from your app, like some strange API that does some extra complicated things than it is better to build whole authentication, groups and permissions on your own that rely on django
@native tide pip list shows that Flask is installed
Hahahaha,
Mate if you want to learn Python, than DON'T touch django project 😦
Do you create your custom environment? Like python3 -m venv env?
gotcha so you think i should learn flask or do some regular stuff with python and then once i get better do flask or smthn
Django just is not pure Python, when you're interacting with Django API, you just learn to write djangonic code in python. It's not much an improvement. If you're willing to build an API from scratch than I think that fastAPI will be a good choice, async requests are kinda nice, but than your frontend should be in React/Angular/Vue.js
no @left kraken
Well, have you set global env for FLASK_APP?
hmm ok ill look into it, i just started learning html and css but im gonna learn java soon so ill look into fast API
I would also suggest you to start using one, default python 3 venv should be enough, but pipenv is nice tool too 👌
GL man 
I don't remember having to do anything other than importing to make it work
Also, it's a good practice to keep your workspace clean and up to date 
well it is clean and up to date stilll :D
Can you show the full traceback for this error?
So, you're trying to execute the file from command line and nothing happens
oauthlib.oauth2.rfc6749.errors.InvalidClientIdError: (invalid_request) Invalid "refresh_token" in request for gunicorn / flask / nginx
Well, I'm afraid that I can't help you mate
:/
yup I prefer flask too
Django is more just for fast development of the backend

