#web-development
2 messages Β· Page 218 of 1
Just refresh the page normally?
yes
click on one of the not found links.
The images r whats not found
Yes, click on one. It should show a pane containing the full url
When i click it it just highhlights the red part above
example:
In my screenshot, I clicked DASH_480.mp4, which brought up the pane to the right.
Preview was selected by default, but I clicked over to Headers
Now click headers.
What's the request url?
And please take screenshots. Stop using your phone.
Oh i know how to screenshot
Im saying what should i do next
Or u want a better screenshot forst
post your last image as a screenshot, because I can't read it.
And what's your directory structure?
the website for anyone looking: http://amusaitif.infprojects.fhsu.edu/Pacific Trails Resort website/ch5pacific/
no.
??
Folder structure.
I control it
restart it?
I got the url from your screenshot
Like that code was from google
can you turn on file extensions? Should be in the view tab
Maybe upload to the server and restart it?
the issue isn't in your project.
probably
did u see my code?
Can i send u the zipped file??
Hey @tight pasture!
It looks like you tried to attach file type(s) that we do not allow (.zip). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
where can isend it?
google drive?
can i email it to u
???
@frank shoal
So you need to upload your images.
so when i download and unzip them do you thing the path changes
it's not in the images folder
so how do i add them
I've never used cpanel.
Looks like you should upload your zip, then extract it using cpanel
extract it in cpanel?
yes
:incoming_envelope: :ok_hand: applied mute to @warm aurora until <t:1645740741:f> (9 minutes and 59 seconds) (reason: discord_emojis rule: sent 51 emojis in 10s).
!unmute 407310346257170433
:incoming_envelope: :ok_hand: pardoned infraction mute for @warm aurora.
lol, careful
did he start spamming a bunch of emojis?
ah. that'll do it.
Hahahaaha
π
I was just so happy
No one would helpp mee or figure out the problemm
https://home.goooooogle.repl.co/ how would i check the redirect requests of a flask application?
?
well its simple
i just learned flask today after someone recommended it here
now i consider myself pretty good at flask
i built a full api with it so
what i would do is check the request
get request i think
then log it to a text file or webhook
or smt
sorry, but you don't 'get good at flask' in a day
Question:
Looking to build a website that has a login/registration that brings the user to a dashboard.
The back-end is built with Django and Django Rest API
I know that Django already has awesome built-in admin, user and registration -- but I know that I could also built it with React.
Could someone help me decide what the best route would be for me?
Is another option to built it out in the back-end with Django, and then use React to improve the UI across the dashboard + company website template?
UI will be very important to the overall main website and dashboard.
Yes, backend with Django and front end with React seems like the natural choice, given that it sounds like you need something nicer then you can do without React
the first part of the sentence doesn't seem to go with the second part :) ?
Made a small edit, maybe that's more clear now?
sorry, no. you say django for backend and react for frontend is a natural choice. but next, you propose they don't need react for something nicer. how come?
and if not react, what would you propose instead?
It's been a long time since I've worked with django. from what I remember, the django dashboard can take you far, but only so far. you can customize it and get pretty far with it, but after a point, you will have to fight against django
My point was that you only need something like React if you need a fancy frontend. Otherwise Django is enough
yeah, I agree
Perl for life
who even are you
i dont remember talking to you π€£
Has anybody here used github codespaces for web development?
Hi everyone. I have a general question of python.
just like we import specific module/package of a package/lib (sorry differences are not that clear, anyways) because if we import whole lib and only be using a specific module, it's not worth it, it will only take memory space and increase execution time. Similarly, in exception handling, let's say I corrupted my try block with intentional NameError but I except error-exceptional handling from Exception class on a whole and not just simply NameError, is the former one slower than later or there is no observable execution time delay?
I want to learn how things work internally, as most tutorials just tell us what python has to offer (abstracted high level syntax and it's working). I have learnt C and I still practice some C small C programs, I'm just a student never don't any real world project but I try my best will cooperate if you tell something complex.
hey guys
I want to be able to use extensions from the google console
how can I manipulate such extensions ?
im trying to remove a field from my models and i keep getting ValueError: Field 'occupiers' expected a number but got ''. even tho im trying to remove the field
from .forms import InputForm
def home_view(request):
context = {}
context['form'] = InputForm()
return render(request, "site/index.html", context)
from django import forms
class InputForm(forms.Form):
first_name = forms.CharField(max_length=200)
last_name = forms.CharField(max_length=200)
roll_number = forms.IntegerField(
help_text="Enter 6 digit roll number"
)
password = forms.CharField(widget=forms.PasswordInput())
<form action = "" method = "post">
{% csrf_token %}
{{form.as_p }}
<input type="submit" value=Submit>
</form>
could someone tell me why this isnt loading the forms, all i have is the button
hey im using github pages and it's only showing the readme file when i deploy
can someone help
this is html
π¦
Follow this carefully. If you're still stuck share your repo and details of the problem. https://www.geeksforgeeks.org/using-github-to-host-a-free-static-website/
Any cPanel geeks here.
Need a bit of help.
I'm hosting with namecheap and they have an exclusive hosting service for for Python Apps, can I start/stop my application remotely as a pose to going to my actual dashboard.
My idea is that if my local server stops responding or is turned to maintenance mode, my server running cPanel will kick in.
i created an animation which rotates in "inline-block" but doesn't when i use inline can anyone explain
body{
font-family: Arial, Helvetica, sans-serif;
background-color: black;
}
section{
height: 10px;
}
h1{
font-size: 100px;
color: whitesmoke;
position: absolute;
text-align: center;
top: 50%;
width: 100%;
transform: translateY(-100%);
letter-spacing: 2px;
}
h1 span{
animation: anim 1s linear forwards;
opacity: 0;
display: inline-block;
}
@keyframes anim {
0%{
opacity: 0;
transform: rotateY(-90deg);
}
100%{
opacity: 1;
transform: rotate(0deg);
}
}```
can anyone tell
????
best sites to deploy flask app except heroku?
getting virtual linux machine from Hetzner/DigitalOcean/Linode/Vultr?
Or free tier on any of the big three cloud providers might work
Hii
how to change discord username use request
i try find this info 1day in google
but nothing
i trying
import requests
payload = {
'username:' "UserSwithed"
}
header = {
'authorization': 'Token'
}
r = requests.post(f"https://discord.com/api/v9/users/@me", # cntrl, shift, i
data=payload, headers=header)
where is token ?
headers = {
'Authorization': f'Token {token}'
}
Using sockets, how can I get the position to a users cursor?
Thank you, from tutorials it looks like to integrate and use react as the registration, it also suggests using Webpack and Babel. Is this standard practice?
I'm not the best person to answer that, sorry, but maybe someone else here will know
listen for a mousemove event and send it over the socket...
socket.send( stringify_object(event) );
how would i resolve this
WARNINGS:
reddit.RedditWallStreetBetsHotDB: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the RedditConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
reddit.RedditWallStreetBetsNewDB: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the RedditConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
reddit.RedditWallStreetBetsStocksDB: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the RedditConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
reddit.RedditWallStreetBetsTopDB: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
HINT: Configure the DEFAULT_AUTO_FIELD setting or the RedditConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
its just a warning
this is django
what are your models
I have a quick (hopefully) question. I own a a domain ending in .dev I know there are requirements that I was must have a valid certificate to use this address for a website, but would I be able to create an API using this address and Heroku without a cert?
of course
you only need cert for https
meaning if you want your data you send to be encrypted then you will need to quickly install a cert on the heroku server
and then send calls to your API via https
but http will work without any certificates, but the traffic will not be encrypted so anyone on the wire can technically see what kind of requests you are sending
If you do need https, check out Certbot / Let's Encrypt. It's free and not too difficult. Heroku probably has a tutorial
Thanks @native tide and @golden bone I have a starting point now
Questions for future reference: can I code a websites front end with HTML or CSS and code the back end with python? Is a backend really necessary for some sites?
Howdy! Looking for a library or any advice on Flask maintaining (refreshing when expired) a token to another app. This is not a user facing login but Im not sure if there's something built into Flask or another library already. Any ideas?
can someone help me with my error
I need help
Each time i make changes to my Css file
For some reason it doesn't show
Backend is necessary for majority website.
Its how u store data and scale,
if your website is static you dont need a backend
How to amke beautiful tables like in aave? https://app.aave.com/#/markets
if you want to help, ping me
hey django users, is it possible to insert stackoverflow style code indentation to django posts?
If you want to do in easy way, you need smth like React or Vue.js
your provided table was made with React
Basically it is just a combination of HTML/CSS/SCSS syntax with a bunch of Frontend Framework Javascript in order to hook drag/drop events with rerender of the DOM
Essentially yes. π€
and model variables that are rerendered when their values are changed
Okay thanks!
everything else looks to me implemented at html/css level.
the autohiding of top and bottom? Html/CSS, a bit unsure how to write it though, making strict size of DIV object, and moving children objects inside of it with forbidding overflow? π€
visual effect on hover? CSS
movements of objects? They used CSS transition thing
the rest is obviously just CSS formating too
Alright
Slightly more interesting that they made a feature of Sorting by certain column
Yeah this website is pretty complex
Technically sorting feature can be implemented on the level of just resorting javascript array data without any other complications, just sorting based on different key
but they could have used Client Side SQL libraries to make it in a more advanced way
obviously they did not make requests to server side for resorted data, or they could 
probably the first option was used
it looks simplest solution
i think they said they used apollo graphql
in their docs
Shrugs. I hope it is simple
Simplicity for the win
Definitely
I assume you're talking about the backend.
yes
Mm, itβs complicated to put into words, but for lack of a better term Iβll say a art site but for me and my friends
So, kinda like Newgrounds but for me and my friends only (I guess, not super sure yet)
https://channels.readthedocs.io/en/stable/ django channels and web sockets sound like a good start for chat apps
can anybody pls help me with something pls dm
class Item(models.Model):
fileds
@property
def get_average_rating(self):
#get ratong from comments
return int(round(sum(rate_list) / (len(rate_list) or 1), 1))
how to order by get_average_rating method in my Item Model it also decimal flied in type (Queryset not list )
Assuming you have it as a list, you can do list_.sort(key=Item.get_average_rating) i believe
Not sure if it works with queryset, but itβs worth a shot
hi, some quick help here: I have a django app where users need to connect to an external api. What's the best way to store their api key securely?
if you want to do it purely in the database, you need to do an annotation.
https://docs.djangoproject.com/en/4.0/ref/models/querysets/#annotate
some combination of F Count, Sum...
@stark tartan
Do Python Django "channels" (websockets), scale?
When I say scale, I mean at minimum 3 million concurrent connections.
Goroutines can have 10 million connections
It would be nice to know
No useful info on google
Just conjecture, and opinions, but no real solid info
the best ive found was this
Daphne is not as efficient as its WSGI counterpart. When considering only latency, Daphne can have 10 times the latency when under the same traffic load as gunincorn.
@raw field nothing can honestly scale to 3M connections..
thats not true
It is.
If you have been paying attention on Twitter recently, you have likely seen some increasing numbers regarding the number of simultaneous connections the Phoenix web framework can handle. This post documents some of the techniques used to perform the benchmarks.
pheonix did 2 million
in 2015
its even much mroe now
I think were talking past eachother .. if your JUST going for benchmark porn, sure.
But what I meant by really is more, you cant do anything useful with those connections..
Sending a ping every 5 minutes at 10M connections was roughly the limit of what the server could handle
No one is running 2 million connections on a single server for any non-benchmark workload.
my point tho is
how do you scale django channels
i cant find anything about it
lol
Thats likely because no one, for real world use cases, has that many clients connected, its a tweetworthy metric. You scale out servers in all production cases that are that loaded.
or just load test it π
My goal is to use django channels to build a matchmaking service for my game.
My design concept is essentially that players will connect to the websocket and request a match, it will look for a free match that is available and then if there are enough players in the lobby to start the match it will then trigger an event (through the socket) to tell all of the users in the lobby what ip and port to use to connect
What is the correct path way to follow to become a good web developer ?
Like first HTML & CSS then JavaScript then what?
https://roadmap.sh/
Check frontend/backend and DevOps maps.
Optionally some of the more specialised ones
Basically yes, it is. You can learn HTML, CSS and Git & GutHub for first.
After that, a CSS framework (like Bulma or Bootstrap) and finally JS and a library (like Angular or React)
Those 'steps' has more steps. For example, learn JS is learn EMACS, too
what do i do after i have the roadmap? like even the roadmap seems very confusing to me
Hey fellas, wondering how to make a query selector with multiple values, like document.querySelector(input[aria-label="Search"|aria-label="SearchBox"])
and so on and so forth
First you should choose if you wish to be frontend or backend dev first
then it will define your next things to learn π€·ββοΈ
hey yall, I need some demo testers for a big project I'm working on! Involves cloud torrenting, let me know if you're up to it, nothing illegal lol :P, just testing out my flask skills
i want to get into back end
but the back end map itself confuses me
https://roadmap.sh/backend
Then get started with this mega Flask tutorial
https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
get used to git
https://learngitbranching.js.org/?locale=en_US
and learn how to deploy your application at virtual Linux machine from cloud provider
It should be pretty beginning stuff to begin 
the content isn't intimidating me just what to learn and what not to learn π
i mean, if you want to do in python as backend language (answered like that because you are in python server)
if you wish to use another one... like javascript, replace flask with express or whateve ris their framework
yeah i very much wanna work with node
it uses mongodb and express i guess
but my question is that once i get a hang of basic js where do i go from there?
do someone knows how to use multiple functions in a flask route? for example, i have a route called /dashboard/ and I have one function in there already but i want to add another function, but i dont have any idea how will i do it.
start learning testing, the book contains all the information what to learn about that after that
Code without testing is garbage waiting to be collected π
get used to Jest as example
Learn how to write Clean code
so it would be self documented and readable
honestly i just want to get a job right now and no offence these would only help once i get a job and want to get good from there
learn about OOP, how to have inheritance and etc
And just learn the basics about your chosen language as main one fully
Once you got grasps of OOP, dive deeper with Design patterns
The rabbit hole is deep one, it continues further without any stop
π
In general you can assume there are no backend developers who don't know SQL
at least basics of raw SQL and able to use ORMs
Raw SQL needs to be learned to understand what you are doing in ORM
PostgreSQL is a good database to work with
Get yourself familiar with Linux systems and Docker
Learn how to deploy your application with Docker at Linux server
it should be minimum any backend dev should know
guess ill kill myself because i would never be able to pay my student loan this way
what can I say? Most universities do not prepare us for real life π
We are finishing it only as a... template ready to be filled with real knowledge and skills to use
a year of intensive self studies while being at first any software related work, and in general person becomes ready to be hired without problems later
a combination of a lot of self studies and a real commercial programming experience is the key to be ready
real programming experience can be partially substituted by home pet projects π
plus they help to get hired more easily
Junior positions are less demandful
in theory you can learn and make enough of pet projects practice to impress people for Junior positions
do you have an education though?
what's your background
believe you use a comma. i.e.
document.querySelector('input[aria-label="Search", aria-label="SearchBox"')
but querySelector only return the first thing. so you probs want querySelectorAll?
its an unusual question but how do i learn git... I mean i have seen few vids on youtube but how to practice it?
its easier than you think
like 5 commands will see you good. paste them in a notepad
git init
makes the folder a .git project
git add . --all
takes all the new stuff you changed or added and gets it ready to save
git commit -am "Changed stuff"
saves it.
now. to sync that with everyone elses code. first you pull
git pull origin master
then push back
git push origin master
that's about all you need to know if you work on your own. after that you can learn branching. but get comfy with that first.
ok thanks
i'd avoid using a GUI like vscode plugin until ur familiar with the commands
may i know why cause i usually use vscode to do so
well. maybe ignore me on that. it is kinda useful. i just think it also useful to know what your actually doing first.
also use git status and git log frequently.
like between every other command. just to make sure it's as you expect
makes sense tho
thanks
if it ever goes wrong
delete the folder and reclone it
git clone https;//path to folder
is there any website where i can refer whats actually happening behind the scene
lots. also the .git folder itself has all the blobs in and configs etc
i.e. when you do git init it makes an invisible .git folder take a look in there
due to all the changes on github and not being able to use a password unless you gen a ssh key etc. it might be easier also if you just install git desktop... https://desktop.github.com/
and clone with that
hii, I want to display only the first few characters of the URL
basically this is my ques https://stackoverflow.com/questions/29053875/how-do-i-render-a-urlfield-nicely-in-a-template?answertab=votes#tab-top
But the answers given there is not working, pls tell how to do?
Iβm trying to build an api with flask and was trying to use marshmallow, marshmallow-dataclass, and marshmallow-dataclass[enum] to do serialization before returning objects from the api. I canβt seem to get any EnumFields to have by_value set to true on them
Has anyone done something like that before?
hello hello
I deployed my web app on Heroku and now I want to see database file, how can I see that ?
try unplugging it and plugging it back in
any one knows about message passing in chrome extensions?
how can I pass the content_script document to the background
both
like I want to develop a skill
already learning ML so thought web dev being the hype felt a good field
So u might be familiar with Python
I mean expert in Python
i cant express how important this one is. my boss gets on my constantly about this
in larger organizations writing clean code is important
Somebody needs to maintain the code written by previous developers
and even develop further
Clean code matters how long they will be trying to read your code
Hell, it matters how long you will be reading your own code you forgot after few months
yeah
If you know the basics of Python, pick a framework and build something. Django is the most powerful, Flask and FastAPI are a bit easier to build something simple with
@golden bone do you know anything about Django Channels
socket.send()socket.on("message", data => { console.log(data);});
socket.emit()socket.on("greetings", (elem1, elem2, elem3) => { console.log(elem1, elem2, elem3);});
This is socket.io
No, never heard of it
Dang
My main experience with websockets is ith socket.io
And I love the syntax because you can do stuff like i just pasted above
custom 'event' based work
so like you can send a signal to the websocket on "message" or whatever
and the websocket will send a response lol
but django channels doesnt seem to have this built in functionality
you have to do it yourself
it makes the development really beautiful and easy to work with
Just, to give an overview, I am trying to build a number based chatbot(like predefined one) where you get a list of options and like it will ask how may I help you and give a list of options :
- Seeking for career advice
- Seeking jobs etc
and the user will enter a number according to what they are looking for.
So what I did is created a form and tried to route it with the python file.
Now the thing is I'm not able to route the logic and send it back to display it.
Trying it in django
ya
well not expert
would anyone know if its possible to force load all the elements in a page (or specific elements) using selenium? Because on a website I'm trying to scrape some elements only load when you scroll over them and considering the size of the website, it would take far too long for selenium to scroll through the entire site and make sure the elements properly load. Thanks
Current flow:
- mysql >> CREATE {DATABASE} db_name [create_specification] ;
- change database info in settings.py
- python manage.py syncdb (assuming we have ready-made models)
Isn't t...
i refuse to believe this
ruby on rails has a setup command to create the database
rails db:create and rails db:setup
create creates the db and stops, setup creates the db, runs migrations and adds any seed data
does django really n ot have the capability of creating an initial database?!
I donβt think so.
Sounds like this may be intentional. You can tell Selenium to scroll/click/wait as needed, or you can use an API if that's an option. But no, Selenium doesn't have a feature that magically loads data that isn't supposed to load
I have used a while loop to scroll until multiple attempts do not increase the length of the document, that's probably about as good as you can do I guess
Tysm man
let response = await fetch(url);
let commits = await response.text(); // read response body and parse as JSON
alert(commits);```
Keep getting error "SyntaxError: await is only valid in async functions and the top level bodies of modules
at /script.js:3:16"
Anyone know why this is?
well, await is only allowed in async functions
how do i call an api and set a variable to the value i receive?
Where is this code from?
You can only use await in an async function
okay
how would I call an api and save the response in a variable
because i dont want it to be Promise {}
when do you want the request to happen?
or undefined
wdym
i want the api call to finish
and then set the variable to the response
when do you want to make that call? when the page loads? when you click some button?
async function doSomething() {
const response = await fetch(url)
const commits = await response.text()
alret(commits)
}
doSomething()
okay
wheres the variable tho
would like to assign the value of response.text() to a variable
You can work with the variable in the doSomething function
Do you know how promises and async/await works in javascript?
no i dont
so i can only use the response.text inside the async function?
is that correct
You can set a global variable:
let commits = null
async function doSomething() {
const response = await fetch(url)
commits = await response.text()
}
doSomething()
but then you'll need to wait until the variable is set before you can use it
is there a way I can stop loading the page until the request goes through?
the website contains a table, all the values are from the api call, I create the table in js and use all the values from the api call to fill it in with data
async function main() {
const response = await fetch(url)
const commits = await response.text()
// create the table here
// for example:
createTable(commits)
}
window.addEventListener('load', main)
okay
thank you man i appreciate it
ill research promises await and async now i think
If you want to learn about promises and async/await:
- MDN tutorial (not sure how good it is) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises
- videos by FunFunFunction (they're generally good)
Excellent thank you
I have 2 servers, one for API one for WS and I cannot combine them into one ( financial issues ) how would I communicate between these 2 servers at lowest cost possible?
People said just build another API on the WS and request it, and some people said using Redis pubsub which I also have to host on the cloud
I think one single pubsub channel might be better than API calls in long term?
If your cloud provider has a message queue that would probably be the easiest solution that does the job well
Client -> POST -> api/channels/channel_id/messages
api -> db -> Success? -> POST -> WS serverβs API
WS server -> dispatch MESSAGE_CREATE event to client
This is my current flow chart
I want to individually animate strokes in an svg, someone have suggestions as to what I am doing wrong ```js
let svg = document.getElementsByClassName(".draw")[0];
interStrokeDelay = 0.1;
strokeSpeed = 0.05;
timePassed = 0;
for (let stroke of svg.children[1].children){
if (stroke.nodeName == "path"){
console.log(stroke);
let strokeLength = stroke.getTotalLength();
let strokeDuration = strokeLength * strokeSpeed;
stroke.style.strokeLength = strokeLength;
stroke.style.strokeDuration = strokeDuration;
stroke.style.strokeDelay = timePassed;
stroke.style.strokeDashArray = String(strokeLength) + "px";
stroke.style.strokeDashoffset = String(strokeLength) + "px";
stroke.style.animation = "stroke" + String(strokeLength * (0.1 / strokeSpeed)) + "sz` linear" + timePassed+ "s forwards";
timePassed += strokeDuration + interStrokeDelay;
}
}```
I realized I was missing a space in the text for animation
serves me right for writing it like that ^^
I'm interested in learning about web development in Python, but 90% of the job/internship postings related to Python in my city seem to be about data science, and rarely anything about web development. Should I learn Javascript instead even if I do like Python?
if you want to do web dev some amount of javascript is basically a must
since the frontend will inevitably use js
but for the backend python exists
most jobs in my area are java spring or nodejs though
ymmv
Hello I am using Flask for a project
I need help plz
there are two user roles
admin and normal user, normal user can post their complaint and admin can see them all and can also give feedback( or respond) to those posts
here posts are some type of complaints which user have on a specific topic
MY PROBLEM is that when admin gives respond to the complaint then that complaint should not be visible on the admin dashboard in future( means just after giving response)
How to do this
I hope i am able to justify my problem clearly
hey guys [[1,2]] how can i get the acces of the element 2 in this list?
Hey i need to know how to use stegnatography to hide a code inside an image and when omage opened by someone it pastes a code inside the browser console , pls this is the imformation i required for my project if u know pls help
django help...
storage setting ManifestStaticFilesStorage breaks my admin panel and causes ValueError exceptions related to the static files for the panel... why?
your_list[0][1]
what's difference beetwen let and var?
I doubt anyone can help without seeing the code
the scope of the variables are different
they both declare variables in JS, but var is old. let is recommended in the present day
but legacy browsers donβt support let so you might still use var if you are making websites to support legacy browsers
This too^
Why does each element remain on top of the others?
HTML: https://hastebin.skyra.pw/ebavineviq.htm
CSS: https://hastebin.skyra.pw/uyazukidur.css
quite trashy code
it would be easier to delete it
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
you used float: left and display: flex
without knowing what is it, just in every element
I bet all other things you used in the same style
you should read this book in order to gain basic understanding what you are doing
and building stuff bit by bit with elements you know how to use
and not just copy pasting from some random place
hiho, I am building a django + react project. I want to do the following:
- User goes to 127.0.0.1:8000/book/<TITLE HERE>
- Django gets info about this book from some other API
- User sees info about the book in react frontend
I heard I should use django rest framework to communicate django with react. Though, I don't know how to do that, since I won't be storing any data in my DB. How to pass info fetched from some other API to react frontend?
If you're not storing any data in a DB, why does the data need to pass through Django at all? But the easy answer is write a REST API endpoint in your django server, where all it does is run the request to the other API then return the same data the other API gave it
lets say I want to enable user to add the book to database using a button
could you navigate me to how should the return look like? until now I only worked with models and serializers
it's probably very simple but I'm inexperienced with Django and I'm not even sure what to search for
Hello, how can I see my database file after deployment?
I deployed my web app on Heroku and now I want to see data and tables and the records inside table, how can I see that
def error_404_view(request, exception):
return render(request, 'pagenotfound.html')
this is my view for a 404 page handler
handler404 = 'thedogenet.views.error_404_view' added this to urls.py, and also DEBUG is false. this was working until idk what shit I did and then it now shows a Server Error(500). I don't know why this is happening
A server error occurred. Please contact the administrator. okay
other than 500
we will need to see the full
error message on the server's side
ok
I don't know your codebase, so I don't exactly what you'd want in the return from the REST API POST call initiated by the button press. But standard behavior would be to return HTTP 200 on success. If no other info is required by the frontend (or other API users), that's all. A typical pattern in API design is to return the serialized database object that was created by your POST call tho. Ideally, the API implementation should be totally independent of how it is being called on the client side - by frontend, other server, or curl calls. All http hits to POST myserver/book/title are treated the same
thank you! could I tag you once in a while if I get some more concise questions?
[28/Feb/2022 21:30:32] "GET /aaaaa HTTP/1.1" 500 145
idk if thats what you want
do you want the error raised when using the inspect element?
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
didn't see anything in the console particularly concerning
only the Server Error
just ask on the channel, there's plenty of knowledgable people willing to help around
no need to tag me or anyone else individually
often there's plenty of people asking about stuff and some questions go by unanswered, some of mine were omitted in the past also
having someone tagged (if he agreed) helps, especially when the questions are not big
I understand your stance though and respect it, thank you for your help!
enable debug=True
there should be a full error message
oh nvm then
thanks for trying to help π
In flask I want to run a script and if someone requests to run it again it will display that its already running. How can i achieve that? I tried to setup a variable and increase it on script run but if someone leaves the page while the script is running it never resets so you cannot run the script again despite it is finished
if you're checking against the increased variable, just decrease it after the script is finished
not sure how you're doing that atm, but you should use something outside of flask to store the content of this variable
you'll be running multiple instances of your flask app in production
Hello. Is it a good practice for a PUT request to return the modified resource besides returning 200 OK? Or should it only return an HTTP code and call a GET method?
its a good practice for APIs that are "models" oriented
so for something like django rest api
https://channels.readthedocs.io/en/stable/topics/channel_layers.html
They do not allow you to enumerate or list the channels in a group; itβs a pure broadcast system. If you need more precise control or need to know who is connected, you should build your own system or use a suitable third-party one.
Does anyone know another system that can do this? I would like to be able to know how many users are in a group
And some information about some status info of a group
No, of course not. You're in the web development channel. Why would anyone here know anything about web development?
Just kidding... What I mean is, don't ask to ask, just ask
Or just ask your question. How can I know if I can help or not if you don't ask anything?
I'm gonna need you to sign this contract saying that you will help after I ask though
#help-falafel for a falafel
in pycharm whenever i try to run a code it says Unable to create process using(blah blah blah files)
anyone know a fix?
Hi Everyone, I'm building Doctor's App using Django. I have trouble with time slot system
Any idea about it?
How can I provide that ":focus" event work for "select" element when I click inside It's parent element ?
https://codepen.io/mehmetguduk/pen/vYWVGPK
active will work too
&:active {
outline: none;
}
I think focus is working only for specific html elements like input
that's the issue
this is not what am I asking
okay. you wish clicking div to activate select then... π€
at CSS level you have option only to use target
otherwise it requires already javascript
frontend framework like Vue.js/React for easy way, Vanilla JS/Jquery for hardway
https://developer.mozilla.org/en-US/docs/Web/CSS/:target
CSS target and smart anchor usage
there is no information about triggering select here. Also I know that this is impossible with only html and css. JS should be solution. but how ?
attaching necessary listening event and adding/removing CSS class to the necessary object when it is triggered
in frontend framework this action is heavily simplified π€
There is an option to use frontend framework as static library, so I could I guess write and show you it without complicated installations
i'll write solution a bit later
I would love that π
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>
body{
background-color: lightgray;
margin: 100px;
}
div{
display: flex;
justify-content: center;
align-items: center;
width: 600px;
height: 200px;
background-color: green;
}
select{
width:300px;
}
select:focus{
outline: none;
}
.ActiveSelect {
background-color: red;
}
</style>
</head>
<body>
<script src="https://unpkg.com/vue@3"></script>
<div id="app">
<div @mousedown="is_select_active=true" @mouseup="is_select_active=false" @mouseout="is_select_active=false">
<h3>Cities</h3>
<select :class="{ActiveSelect: is_select_active}">
<option>Berlin</option>
<option>Paris</option>
<option>London</option>
</select>
</div>
</div>
<script>
Vue.createApp({
data() {
return {
is_select_active: false
}
}
}).mount('#app')
</script>
</body>
</html>
https://vuejs.org/guide/essentials/conditional.html that can be useful too.
Hmm, we have even focusin and focusout events
we could try them
it is just changing background color of select. not showing option elements
I got ('CheckoutView' object has no attribute 'object') while I'm registering
def dispatch(self, request, *args, **kwargs):
if self.request.user.is_authenticated:
return HttpResponseRedirect(self.get_success_url())
return super().dispatch(self.request, *args, **kwargs)
def post(self, request, *args, **kwargs):
form = self.form_class(data=request.POST)
if form.is_valid():
user = form.save(commit=False)
password = form.cleaned_data.get("password1")
user.set_password(password)
user.save()
return redirect('accounts:login')
else:
return render(request, 'accounts/doctor/register.html', {'form': form})
This is the code
you can customize further to have it focusing effect
the principle of technology is the same
well, i guess i could write it to for you
I understood what you want to say but i guess its impossible to trigger select to show it's options. Bc its not as simple as changing it's background-color
u just need to use a bit more custom html/css thing, a moment
okay
:incoming_envelope: :ok_hand: applied mute to @inland oak until <t:1646147048:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 110 newlines in 10s).
!unmute 370435997974134785
:incoming_envelope: :ok_hand: pardoned infraction mute for @inland oak.
!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.pythondiscord.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.
Please use this for large code blocks
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
thanks
fully custom dropdown menu
broken link
there is some mess in css, not sure what is not necessary π€ a bit lazy to clean π
.option:nth-child(1) {
top: calc(-1px + 49px * 0);
}
.option:nth-child(2) {
top: calc(-1px + 49px * 1);
}
.option:nth-child(3) {
top: calc(-1px + 49px * 2);
}
this thing needs to be wrapped into for loop from scsss
@for $i from 0 through 5 {
.option:nth-child(#{$i}) {
$number: $i - 1;
top: -1px + 49px * $number;
}
}
Gaja linux
By control +U erase whole line π
I seen it π€£ π€£
π
You have mac lg
No it is worst ever
are you talking about windows terminal, or cmd?
Both are same
Fuck things
no they are not.
windows terminal is a terminal application that supports many shells
cmd is the original windows shell
But can't compare with linux terminal
you mean bash?
It is awesome bro
Yeh
What do you think WSL is?
Mixture of linux terminal and windows cmd π«
What is that
We only have one terminal that does all jobs π
Only one?
gettin some old school mainframe vibes here
let's count all the shells linux has. csh, tcsh, sh, bash, fish, zsh
I am using Linux mint as primary Dextop
Ohh cool
WhY you use windows
because that's what work gives me
What's your age
lolwut
Lol
Why are you asking?
I think you are pro coder
because I use manjaro at home?
So I am asking
I am 29
Yeh
Hey guys I have an existing django project with three js front-end. I want to use webpack for the front-end however am a bit confused in how to change the file structure. The example projects for the django-webpack-loader have very few files (see snapshot for the assets) https://github.com/django-webpack/django-webpack-loader. Is there a way I can maintain the current structure and convert on build? thanks in advance
does anyone know what dispatch function does in django class based view
can someone help me with this
That's a Google question. Here's the official doc, and there is more explanation on StackExchange if you need it. https://docs.djangoproject.com/en/4.0/ref/class-based-views/base/#django.views.generic.base.View.dispatch
It's telling you that you haven't allowed the PowerShell script to execute. This may help:
I'm trying to use an API which takes a session ID header with each request for authentication. Up until now I've been manually copying it over from a session cookie, however I'm wanting to upgrade the program so I can add in my credentials in some sort of configuration file (less preferable) or create some sort of "integration" which allows me to authenticate more securely than that. All I know so far is that I log into the account using a Microsoft account integration, but I'm not sure how much that helps. So far, I've got a capture of the web traffic during the login process, but it might as well be in Latin for me. Does anyone have any pointers? Thanks in advance.
(I'd rather not supply the capture, as it contains potentially sensitive information)
access it via os.getenv("CONFIG_KEY")
i created a new a custom user table in django but it does not have id column can anyone guide?
I want to make an svg by letting the user draw on a html canvas, but instead of listening for mousemove events while mouse is pressed I want to sample the mouse position regularly (like say 50x second) as long as the mouse is down and update a variable with the delta x and delta y
You'll want to make a tick loop. Though I'm not sure if that exactly is web dev
Oh, html
You can use setInterval(func, delay)
I'm at my wit's end. I have apache up and running with a django installation on windows. I can't seem to get them to connect--error logs show "no module named XX", so I'm sure I messed up somewhere but I haven't had luck debugging this. Any hints?
specifically, wsgi.py seems unable to find my modules
hey guys! i am a beginner and have been facing lot of small issues with every other step i take. lot of errors have been popping up. I am unable to setup virtual env in specific locations. Do you guys recommend me to delete literally everything (after backing up important projects) and installing each software again. If so how should I proceed?
how to merge 2 list of dict and remove duplicate?
Hello, I need to make REST API for my python program to make it possible to link it with 3rd party web services. Can anyone recommend any course to learn how to make APIs? I have no background...
!e
x = {'a': 1, 'b': 2}
y = {'b': 10, 'c': 11}
x.update(y)
print(x)
hello sir
@inland oak :white_check_mark: Your eval job has completed with return code 0.
{'a': 1, 'b': 10, 'c': 11}
the nature of dict is not needing to remove duplicates
dict is data structure that has unique hashable keys
data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]
how to find duplicate and extract it expected output is
{"pet" : "cat", "name": "ivan"}
clarify your definition of duplicates
duplicate dict in a list
to be duplicate, do you need to have identical pet and human name?
example
data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]
output = [{"pet" : "cat", "name": "ivan"}]
yes sir
!e
data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]
import json
ans = {json.dumps(i):data2.count(i) for i in data2}
print(ans)
@inland oak :white_check_mark: Your eval job has completed with return code 0.
{'{"pet": "dog", "name": "mark"}': 1, '{"pet": "cat", "name": "ivan"}': 2}
you are trying to count duplicates in a list, not in a dict
sorry
!e
data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]
import json
ans = {json.dumps(i):data2.count(i) for i in data2 if data2.count(i) > 1}
print(ans)
@inland oak :white_check_mark: Your eval job has completed with return code 0.
{'{"pet": "cat", "name": "ivan"}': 2}
but can we extract what has dup?
!e
data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]
import json
duplicates = {json.dumps(i):data2.count(i) for i in data2 if data2.count(i) > 1}
for duplicate in duplicates.keys():
print(duplicate)
@inland oak :white_check_mark: Your eval job has completed with return code 0.
{"pet": "cat", "name": "ivan"}
Thank you so much sir @inland oak
date_created = db.Column(db.DateTime(timezone=True), default=func.now())
Output = 2022-03-02 09:11:49
So I have this and I want to show how much time has passed since then and I'm having trouble find a solution...
Hi I'm need of help. I'm currently making a project in Django, but the question isnβt specific to Djangoβ¦ In adapters.py, Iβm trying to import model classes from models.py (see image below). Iβve tried using
from ...grandfather.app.models import *
, but I get an error saying that βattempted relative import beyond top-level packageβ.
In general I donβt fully understand the path system fully + I don't know what the best practice is for this problem.
Any guidance would be much appreciated.
update:
I've also tried adding 'init.py' files to the grandfather and project directories too, as suggested by somebody on StackOverflow.
I would strongly recommend to not do what you are trying to do. Even if you get the βabove top-level importβ to work, it will be extremely brittle to any changes in the folder structure or, from which working directory you run the βpython manage.pyβ commands used to run the Django server. Consider either making an installable library out of whatever is in βgrandfatherβ, or moving it into a child directory of βappβ.
And yes, you should always add dunder-init files in every directory containing python code
Thanks for the advice. The allauth redirects that I'm trying to use require this directory structure:
"# project/settings.py:
ACCOUNT_ADAPTER = 'project.users.adapter.MyAccountAdapter'
project/users/adapter.py:
from django.conf import settings
from allauth.account.adapter import DefaultAccountAdapter"
- is there a workaround to this then?
https://django-allauth.readthedocs.io/en/latest/advanced.html
I'll give it a go.
It's in the grandfather
2 seconds, just going to attempt the relocation
No I was confused- you shouldnβt move project into app if project is already a child of the Django work directory
So you were trying βfrom β¦grandfather.etc import blahβ. Just get rid of the ββ¦β
As long as youβre launching the server like βcd grandfather; python manage.py blahβ there shouldnβt be any issue
Sorry for the lack of transparency here. I'm going to add another layer of confusion here, but 'project' is not the directory with 'settings.py' in.
So I think the naming conventions might be confusing me. If I place users inside my true project directory, will it still work. I've remained with topic/users because it specified in the docs
Also the redirects work when 'project' isn't the true project name
So the parent directories are called 'project', 'actual project name' (with settings.py in), and 'app'.
Its in the grandfather
Sorry, I really appreciate the help, I'm lost myself .. haha
also the redirects
get_login_redirect_url(self, request)
get_logout_redirect_url(self, request)
Not sure why youβre bringing that up it seems entirely irrelevant to the import issue
I want to import my models as I have a cookie session and want to set a cookie session on login
Scrap the models for a second. How can I set a cookie session in these redirect views?
Maybe you're right about trying to import the models in general, and I should rethink the approach.
Itβs been a a solid year since I played around with Auth in a Django app. I donβt remember how I did it. Sorry
And yeah so βwhat You want to do with the code you importβ is entirely irrelevant to βhow to write the import statementβ
Agreed.
Hopefully next time I can really figure out what I'm trying to ask too.
I think that what I want to do can probably be done via signals and I'm trying something impractical. Back to the drawing board ... xD @steel night thanks for your time, and advice.
Does web design falls under web development?
@native tide see the channel description.
you can ask about stuff that is referred to in the channel description.
"Help with web technologies such as FastAPI, Flask, Django, HTML, CSS, and JS."
Hey π What's your favorite admin panel solution for Django? Django Admin or something else?
Do you guys know any tool or extention that I can automatically put my scss properties in order like this : https://fordinteractive.com/2009/02/order-of-the-day-css-properties/
Heyy
@frank shoal
?
@frank shoal
Ask your question
My question is if u have to modifiy the last codes how do i do that while i keep it zipped
Why is it zipped?
Because otherwise the images wouldnt upload
No each assisgnment we upload a new website link
So like we build on last weeks code
You should make a new zip file each time.
I didnt make the first one
And you should be able to copy a folder
Ik but its not workin
I just dont understand the problem
As in why the images dont upload if not zipped
They do upload, but they upload to the folder you dragged them to
i.e. not in a subdirectory
the folder doesn't get uploaded. Each file in the folder gets uploaded
So inside last weeks zipped file theres 5 things⦠images folder and then file 1 file 2 file 3 and file 4
Files 1-4 r different this week but the images r the same
I tried to replace files 1-4 but it wouldnβt work
windows explorer doesn't support updating zip files. Use 7-zip instead
Any chance anyone know how to fix this
https://py-dle.herokuapp.com/ what do you think about this site I made using flask? It's kinda like wordle but for daily python challenges
I currently use pypyjs to compile the python code in the web so I ownt have to send it to the backend server then people would be able to do all sorts of stuff with it
But maybe there is a better solution
guys, how do i start my api in procfile (heroku, fastapi)?
my server is on file, now boot is on another
Hi guys, I have a doubt about Django. I have a BlogPost model in which I have three attributes (author, title and content). Both title and content are editable when I want to create a new post with CBV, such as:
model = BlogPost
# hits .save() after all the fields are validated
fields = ["title", "content"]
# looks for model_form.html if template_name isn't specified
template_name = "pages_app/blog_form.html"
success_url = reverse_lazy('pages_app:blog') ```
but one thing I'm not sure is how to use the current logged in user's username to use as the "author" attribute. I'd love to know what to do from here, thanks in advance!
if you have extended the user mode, and author is a model field, try user.author
you should be able to use it in a view like this: request.user.author
same with if you wanted to access a user's email: request.user.email in the view logic
how do I extend the user model? Not sure if I got this correctly. Because it doesn't seem like I can use request from inside a ClassBasedView
Hey there Friends ! I need help. I'm creating A django app,where after search data is fetched from the api and rendered as list content cards
But I want to create a seperate page,where when user clicks each card is redirected to the page of that card with more data in it
How should I do that ?
how to lock a user after 5 unsuccessful login attempts in django?
@views.route('/delete-comment/<comment_id>')
@login_required
def delete_comment(comment_id):
comment = Comment.query.filter_by(id=comment_id).first()
db.session.remove(comment)
db.session.commit()
return redirect(url_for('views.home'))
I have tried fixing this for a while and Im not sure what is the problem
Easiest thing to do is use a package like https://pypi.org/project/django-axes/
Depends if you are doing this on the django-admin login or your apps login. I like to use the django-allauth package for my django projects for all authentication needs auth security. https://django-allauth.readthedocs.io/en/latest/
If you're using Flask-SQLAlchemy, it's delete that you want, not remove.
https://flask-sqlalchemy.palletsprojects.com/en/2.x/queries/#deleting-records
Remove is to remove the session itself
https://docs.sqlalchemy.org/en/14/orm/contextual.html?highlight=remove#sqlalchemy.orm.scoping.scoped_session.remove
thanks
I'm finding flask more flexible and versatile than django but since I'm relatively new to python as it I'm getting more people's opinions that django is used more than flask. Although I don't think that there are any drawbacks using django over flask but I want some overall opinion especially in terms of demand in the market and usage. Which one do you prefer over the other and why?
Hi I need some assistance, using python3, flask, apache2, mod_wsgi
my .wsgi file doesnt work with the supplied code at the bottom of https://flask.palletsprojects.com/en/2.0.x/deploying/mod_wsgi/
activate_this = '/path/to/env/bin/activate_this.py'
with open(activate_this) as file_:
exec(file_.read(), dict(__file__=activate_this))
will not work for me because I dont have activate_this.py
i got it but it didnt work
im using python3 venv
not virtualenv
activate_this is meant to be the file you run that activates the venv
Hi @crystal pelican so if its the regular venv bin/activate it doesnt work, it has to be python
virtuenenv has an onld file flask docs refer to called activate_this.py
i downloaded it and put it in bin like stackoverflow said because it should work
but it did not solve my issue
my issue is
I cant import local python files to my flask app.py
I sorted out venv pip imports
which now work
so i guess it is using my venv
idk
im lost
local files wont import
pip files will
front
βββ app.py
βββ frontvenv
βββ func.py
βββ __pycache__
βββ static
βββ templates
is my layout in /var/www
app.py is flask app
imoprt func
does not work
ModuleNotFoundError: No module named 'func'
WSGIDaemonProcess app python-home=/var/www/html/front/frontvenv python-path=/var/www/html/front
doesnt work
still not importing
fixed it
whats this issue
Target WSGI script <path> does not contain WSGI application
this is in my .wsgi
from app import app as application
Hi
I am using function based APIs (in views.py) in DjangoRestFramework and want to access variables from one API to another using request.sessions
However, I am able to add into sessions for only one API at a time and when I access the session dict in another API, it is empty.
If anyone has any clue on how to get this working please contact me. Thanks!
If you know any other way of doing (except global variables) it you're welcome to answer
Vague/Open-ended question, what is the neatest way to make a website chatbot?
Flask is fine if it suits your use case. Django is more powerful but also more complex so it really depends on what you are trying to do. You might also consider FastAPI, again it all depends on your use case
I can't help you there but if you show your code maybe someone can
Looks like a Rick Roll error to me
i m getting this error, i assume this is because i haven't given view name
path('captcha', include("captcha.urls")),
BHAHAHHAHAHHAHAHAHHA
def cap(request):
if request.method == "POST":
form = MyForm(request.POST)
if form.is_valid():
print("success")
else:
print("fail")
form = MyForm()
return render(request,"cap.html",{"form":form})
Are you using blueprints?
no
Duh, that's for Flask. But you're right that it's just not pointing to your route, some gotcha somewhere
i m using django
i think this is the issue
https://www.tutorialspoint.com/how-to-add-a-captcha-in-a-django-website
I m following this
How to add a captcha in a Django website? - Captcha is one of the modern ways used for verification in websites; it is very cool way and every second website is ...
There's a lot of code in that tutorial you haven't shown... I would just check what you have against it line by line
<!DOCTYPE html>
<html>
<head>
<title>Captcha</title>
</head>
<body>
<form method="POST" novalidate>
{%csrf_token%}
{{form.captcha}}
<input type="submit" value="submit">
</form>
</body>
</html>
from django import forms
from captcha.fields import CaptchaField
class MyForm(forms.Form):
captcha=CaptchaField()
Hello, I'm working on 2 apps. App (A) only accounts(login/signup), and App (B) is for e-commerce(sell) .In-app B (e.g when the user try to add to cart it shows an error regarding on No User exist) but the user is logged In, in App A
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/addtocart?id=1
Django Version: 2.2
Python Version: 3.7.9
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'appointment',
'accounts',
'bootstrapform',
'myuser']
Traceback:
File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\env\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)
File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\env\lib\site-packages\django\core\handlers\base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\env\lib\site-packages\django\core\handlers\base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\myuser\views.py" in addtocart
88. cart(User = request.session['User'],item_id = id , item_name = objmeds.name, quantity= quantity , saleprice = objmeds.sale_price, totalprice = (int(objmeds.sale_price) * int(quantity))).save()
File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\env\lib\site-packages\django\contrib\sessions\backends\base.py" in __getitem__
54. return self._session[key]
Exception Type: KeyError at /addtocart
Exception Value: 'User'
Hey guys. When making an API, what framework would you say is the most in demand in the professional scene: FastAPI, Flask or Django?
There's data you can find on this and I think Django is probably #1 but it doesn't really matter that much. The concepts are similar enough that if you know one well you could be hired for another
OK, thanks
Hi, got a question.
I'm trying to make a simple Flask app which saves to SQLite, but every time I try to save to the db, I get some error about the initiating thread and the thread adding to the db being different
Anyone here have experience using Microsoft Authentication Library (MSAL) for authentication with fastAPI as backend and a React frontend?
What is the idiomatic way to have a long-lived connection to the database?
hi
im a new python programmer
and i want to know how can i improve my power of write code in python in any platforms
can somebody give me some info ?
Build stuff. Whatever interests you, it doesn't matter, just keep coding
set up a connection pool in your application, and grab a connection from the pool when you need to make a database request
Yes, but I've been having a hard time figuring out how that's done.
I think I did find something though
what database library are you using? are you using asyncio or not?
some of them do connection pooling for you
also sqlalchemy does connection pooling
Not asyncio. Sqlalchemy also looked a little heavy for what I'm trying to do.
I think I found a way to do what I want using Flask's g object
g is more or less scoped to a single request
technically it's scoped to an "application context", but the lifetime of an application context is not much bigger than a request context https://flask.palletsprojects.com/en/2.0.x/appcontext/#lifetime-of-the-context
so you can use flask.g to set the connection to be used, but you will still want a connection pool that survives between contexts
a global, or an instance attribute on your flask app object, is fine for this
I'm trying to interact with a website API, however I'm a bit stumped on authentication. When I use this web service, the only way to authenticate is via a Microsoft integration, however I'm not sure how to do that programmatically. Is there a Microsoft endpoint I have to utilise? Do I have to look into OAuth2? Or would the best way be to replicate the user's process in navigating the page sign-in?
Sorry that my question is a bit open-ended, I'm pretty clueless on this topic and don't know what direction to head in to proceed. Any help is greatly appreciated!
@runic sparrow that's an unusual problem. is this some kind of automation task for your job?
Sort of - I'm trying to create a command-line tool to access various information from our VLE such as announcements, homework tasks, etc.
VLE?
virtual learning environment
like Google Classroom
however, we use "Firefly Learning" instead, and to be honest it's quite a pain
i see. this is teetering on the edge of rule 5, so honestly i'm not sure we're allowed to help with this
let me ask
I doubt it's breaking any rules - I'm not web scraping or acting as an user, it has a proper REST API (https://[SchoolName].fireflycloud.net/api/v2/)
Since the wheel isn't available yet on Selenium, how do I scroll to bottom?
Thank you
Authentication isn't covered in the documentation for the API?
There's absolutely zero documentation
even their own developers seem to struggle - the mobile app implements only around a quarter of the site's features
thanks for the advice.
to reiterate, would SQL Alchemy be the simplest way about this?
I'm looking for as simple an answer to this as possible
aka, no ORM or anything needed
@app.route('/add/<int:n1>,<int:n2>')
def add(n1,n2):
sum = n1+n2```
here instead of n1 and n2 just , i want to take a whole list or tuple of integers
idont know how to do that
You might be better served using something like a POST request
with the numbers you're looking to add in the request body
i m building a rest api
well the existence of an api doesn't mean you're allowed to use it π
in general you'd have to inspect the network requests to see what headers and other payload information is sent
maybe an auth header, or an access token as a url query parameter, or something in the request body even
add doesn't sound like a "resource" in the sense of REST
this is more like a procedure call
that i'm not sure. you might be able to roll your own, or there might be some general purpose 'resource pool' package out there
but this is more of an #async-and-concurrency question: "my database library does not provide connection pooling, how can i build a connection pool? what problems do i need to watch out for?"
Hi guys excuseme, is there another way to create a Relational Database without using Mysql and ForeignKeys?
You could use Postgres or another flavor of SQL. Relational DB more or less means SQL with foreign keys. You can use a non-relational db if you want to instead
Hi please assist me
I'm using flask, apache, mod WSGI, I can run the same set up locally and everything works fine. on my VPS I get error 403 Forbidden
You don't have permission to access this resource.
I have 755 file permission on /var/www/html where my files are
and 644 on files
chown is www-data:www-data
still doesnt work
what do i do please
wheres the flask experts
default pfp gang
try sudo
π
have u never used linux
oh
u cant use flask with apache i think
oh u can
mb
im not good w flask
lmao
try gunicorn
yeah, I see. Appreciate the advice!
Probably caused by your application running as the wrong user. Make sure the folders the application needs access to have the proper privileges set and the application runs as the correct user (user and group parameter to the WSGIDaemonProcess directive)
user=www-data group=www-data
doesnt work
I might try gunircorn
I want to use apache
why is flask trying to serve my files from /var/www/html instead of the dir configured in apache which is /var/www/html/data
i get 403 on /var/www/html/requestedfile instead of /var/www/html/data/requestedfile
Hi, apache and mod_wsgi are trying to serve my flask routes at /var/www/html/requestedroute instead of /var/www/html/data/requestedroute wihch is configured in my apache configruation and site conf. as a result I get 403 error. how do i fix this please?
How would I go about storing a requests (the http library) Session between requests in Django?
I'm using a pre fork worker gunicorn setup
what about it
any easy to digest resources for learning how to let others see my app? all I know is that I need a web server?? so I installed apache, and I now need to somehow find a way to throw my app in front of port 80 but this feels a little over my head
Hello, I have a question more focused on web hosting. If you created a Django RESTful API & created a seperated Frontend to request Django API endpoints to get responses, is it possible to host it on one webserver like making the Frontend & the Backend on the same Domain or create subdomains for it? Also similar situation is it possible to host 2 or more Backend apps (APIs) on one domain/webserver as I mentioned above? (I usually use Heroku because it is free, if there is a free alternative to achieve my goal or even a paid provider, good to share).
Yes, it is possible
in any configuration
usually there are two approaches
- Using two domains for one host. Frontend from example.com, Back from back.example.com
- Using subpaths. Front from example.com/, back from example.com/api/
Web server/Reverse proxy like nginx will allow you to configure it
Do you have any idea how to achieve that on Heroku? Because it requires to detect the language you used in the file (Like Python) and do some configurations so I dont know if I had a node js and a Django file how it would work
no idea, i assume that people in general use VPS, Virtual machines
Linux server like Ubuntu 20.04, is all that is needed for simple setup
For more advanced setups people deploy stuff like that to Kubernetes ;b
Okay. Thanks for helping!
U a welcome.
I would advice getting a hang of..
Docker + Docker-compose should be a good start for simpliest setup
usereditview() missing 1 required positional argument: 'form'
this err comes to me
and this is my
views.py
def usereditview(request, form):
UserProfileForm(request.POST, request.FILES, instance = Profile.objects.get(user=request.user))
if request.method == 'POST':
if form.is_valid():
form.save()
return redirect('profile')
return render(request, 'registration/useredit_form.html', context={'userprofile_form': UserProfileForm})
can any one help me to fix it
django
I should learn this I always delay learning ci/cd, devops, testing and cloud services
You are passing form parameter why?
I could advice you using Hetzner cloud provider
it is cheap and quality provider to get started
and concentrating first on... getting used to linux+docker
and testing is good idea too
Okay will look at it. However I am not a fan of configuring my own server setting if that is the case
People use Infrastructure as a Code stuff
everything is automatized to setup servers
u just aren't probably ready for this yet, regular Linux + Docker/Docker-compose should be a start on this road
ΨΉΨ΄Ψ§Ω Ψ¨ΨΉΨ―Ω Ω ΩΩΨ±Ω Ψ§ΩΨ¨Ψ±ΩΩΨ§ΩΩ
ΩΩ Ψ§ Ψ¨Ψ΄ΩΩΩΨ§ Ψ¨ΩΨ¬ΩΩΩ Ψ―Ω
Ψ§ΩΨ±ΩΨ± Ψ¨Ψ±ΨΆΩ
Okay. Thanks again!
Just give me a min
k
form = UserProfileForm()
if request.method == 'POST':
form = UserProfileForm(......)
if form.is_valid():
ΩΩ
Ω Ψ§ΩΩΩΨ― Ψ§ΩΨ¨Ψ§ΩΩ
how do i get prev 6 months data from django models?
TheModel.objects.filter(dateField__lte=<date>)
#Or
Sample.objects.filter(date__range=["2011-01-01", "2011-01-31"])
hi i have two user models (A and B) in flask, and i'm trying to figure out how to use flask-login's user loader to login either A or B, any idea how to do that?
how do i apply strftime or something similar to get only month from my DateTime field while filtering a django model?
graphs = graph.objects.filter(organisation__name = username, month = prev_mon)
Here, month is a datetime field, so it is in the format 'YYYY-MM-DD' , and prev_mon is 'Feb'
How do I compare only month of the month field?
Try graphs.TheDate.strftime('%M')
def register_collector_process():
"""Process collector registration."""
if request.form.get('Collector'):
return redirect('/register_collector')
if request.form.get('Store'):
return redirect('/register_store')```
Keep getting a 405 that it wont redirect after I check one of the options in the checkbox. Any ideas why?
didn't understood
Your variable graphs returns a querset right?
Yes
Whats the field on the model graph that holds the date?
month
Uts name is month?
class graph(models.Model):
organisation = models.ForeignKey(organisation, on_delete = models.CASCADE, null = True)
active_assets = models.PositiveIntegerField()
inactive_assets = models.PositiveIntegerField()
vul = models.PositiveIntegerField()
dataleaks = models.PositiveIntegerField()
month = models.DateField(null=True, blank=True)
Ok try graphs.month.strftime('%M') after this
it is giving error in month = prev_mon while filtering as i told
['βFebβ value has an invalid date format. It must be in YYYY-MM-DD format.']
.
No this is the model
I mean
The fields on the db
Go to the admin
And scrnshot
Oh I see
prev_mon = "Feb"?
Yes
If you notice the Month field is "2021-06-15" So prev_mon must be the same way
can't we do strftime like we do normally?
I think it gives you a number not a name
Okay, thanks for the try though
You want to get all the data for the prev month right?
Yes
you can with graph.objects.filter(month__lte = "2022-02-28")
lte stands for less than or equal
okay thanksπ
your welcome
token is a variable you defined in your for loop statement so it only exists within the loop
after loop is over its gone
so after you print each token on each line token doesnt exist when the loop ends
oh
Can anyone help with this: apache and mod_wsgi are trying to serve my flask routes at /var/www/html/requestedroute instead of /var/www/html/data/requestedroute wihch is configured in my apache configruation and site conf. as a result I get 403 error. how do i fix this please?
<Directory /var/www/html/front> <<---- this is my directory block in front.conf
this is the error in apache logs
AH01630: client denied by server configuration: /var/www/html/buy
my flask app is supposed to server /buy from the root level
i dont get why it says /var/www/html/buy when it should be /var/www/html/front/buy
and also, does this indicate flask routes are working