welcome to 2021 - checkout https://fastapi.tiangolo.com/
FastAPI framework, high performance, easy to learn, fast to code, ready for production
2 messages · Page 150 of 1
welcome to 2021 - checkout https://fastapi.tiangolo.com/
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Reading through https://devcenter.heroku.com/articles/limits - i do not see any problems running on heroku
Unexpected closing tag "body". It may happen when the tag has already been closed by another tag.
this is the error I am gettin even when I am closing all the tags
what should I do?
Hello!
i try to build a web scraper for a friend for me with Scrapy and i don't know where my error is...
The Scraper do catch the prices from items on the steam market.
The printed array is empty by run the programm...
My Code:
import requests
from bs4 import BeautifulSoupurl = "https://steamcommunity.com/market/listings/252490/Blackout Vest"
response = requests.get(url)
html = BeautifulSoup(response.text, "html.parser")
buyPrice = html.find_all("span", class_="market_commodity_orders_header_promote")
allBuyPrices = list()
for price in buyPrice:
allBuyPrices.append(price.text)print(allBuyPrices)
Have anyone a idea?
Thank you a lot!
Buy and sell Rust items on the Steam Community Market for Steam Wallet funds.
is anybody knowing solution perhaps, where do I do wrong?
I surely succeded with customer-list though being outputed to wiki
something is wrong with my customer-detail due to more difficult path perhaps
hi, I checked your code and you need to change
buyPrice = html.findall("span", class="market_commodity_orders_header_promote")
to
buyPrice = html.findAll("span", {"class":"market_commodity_orders_header_promote"})
However it returns empty list, because I am not sure if you can scrap data like that
notice big "A" in findAll function
idk webscraping or the return type of smth like that but i dont think you can do it like that.
What I suggested was smth like that:
if(driver.find_element_by_xpath('//*[@id="error"]'):
print("Found an element")
else:
print("Nothing found")
idk if you tried it yet but if not pls try it and see if that atleast gives you "Nothing found" and if so try instead of "by_xpath" "by_id". mby that gets you some results
nevermind, I managed DRF to work
oh thank you! 🙂
Hey, I'm trying to create a django model to store data about web pages e.g. their titles, urls and meta data. I'm storing each page's source HTML externally in S3 and recording the key for each page as such:
class Page(models.Model):
url = models.URLField(unique=True)
title = models.CharField(max_length=255)
html_s3_key = models.TextField()
meta_description = models.TextField() # Extracted from the page HTML
...
However, since the meta data is derived from the page HTML I'm thinking this would break normalization. Is this a good use-case for a one-to-one key? For example:
class Page(models.Model):#
url = models.URLField(unique=True)
title = models.CharField(max_length=255)
html_id = models.OneToOneField('Html', on_delete=models.CASCADE)
class Html(models.Model):
html_s3_key = models.TextField()
meta_description = models.TextField()
...
Did you use link too put css file in html?
Oh ok,np
Could anyone kindly help me out in #help-rice ? I'm looking to make #hastags linkable in my Django Twitter clone. Thanks!
How to add small animations and transitions effect in website?
Check out CSS animations
Hey I was learning React and trying to make a basic math game....it seems to be working fine but whenever I submit the form it just changes the numbers for a split second and works as its supposed to but then goes back to the default (1+1) thing...
[HMR] Waiting for update signal from WDS... this is the message that the console shows
function App(){
const [num1,setNum1]=useState(1);
const [num2,setNum2]=useState(1);
const [score,setScore]=useState(0)
const checkit =()=>{
if (parseInt(document.querySelector('#answer').value)===num1+num2){
setNum1(Math.ceil(Math.random()*10));
setNum2(Math.ceil(Math.random()*10));
setScore(score+1)
console.log(num1,num2)
}
else if(parseInt(document.querySelector('#answer').value)!==num1+num2){
setScore(score-1)
console.log("wrong")
}
return false
};
if (score<10){
return(
<div>
<div className='Game'>
<h1>{num1}+{num2}</h1>
<form onSubmit={checkit}>
<input type="text" name="answer " id="answer"/>
<input type="submit"/>
</form>
<h2>{score}</h2>
</div>
</div>
);}
else{
return(
<div>
<h1>YOU WON</h1>
</div>
);
}
}
export default App;```
any good tutorial for django, react and websockets??
Djangi has perfect documentation
Official one
Tutorial to get started is included there
I'd also recommend Corey Schafer's tutorial series on YouTube.
<!DOCTYPE html>
<html>
<head>
<link href="styles/main.css" rel="stylesheet" type="text/css"/>
<title>COVALENT</title>
</head>
<body>
</body>
</html>
body {
background-color: #000000;
}
it's not linking to the css file. what could be wrong?
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
this is how i link to my css file inside static folders
and it works fine
its because the way u try to access the css file is a bit different
so i went back and check mine
i am newbie
we can't name it something else instead of static?
it gives error werkzeug.routing.BuildError: Could not build url for endpoint 'styles' with values ['filename']. Did you mean 'static' instead?
Guys, what is the best front end frameworks in the actual days?
would you mind shows us you code
You are indian?
yep
In flask, how do I statics the total patient instead of total new patient from sqlalchemy?
lol
ok
lol
I was thinking to learn web developing and make basic or high level websites
And earn some money
How to make animations
Like when we move cursor over the text it bounces up something like that
html {
background-image: linear-gradient(to bottom right, orange, blue);
}``` how can i stop this from happening (im very bad at css)
do i need redux with nextjs?
i know people use redux with create-react-app
but was curious about nextjs
Is this a framework?
the error tells you exactly what's wrong. You're trying to input a string exceeding 50 characters into a field of your model (where you have max_length set to 50)
redux is agnostic of the react framework you use... using it is your choice.
but it is recommended to use redux, yes 🙂
hmm
url = models.URLField(unique=True)
title = models.SlugField(max_length=255, blank=True)
img = models.SlugField(max_length=255, blank=True)
description = models.SlugField(blank=True)
latest_chapter = models.FloatField(blank=True)
latest_chapter_link = models.URLField(blank=True)
latest_upload = models.SlugField(max_length=255, blank=True)
latest_views = models.IntegerField(blank=True)```
I did change it
all above 50
but still no luck
did you makemigrations & migrate?
so for all my state should i be using redux? or only for specific states that I need accessible for all my components?
if you have a bunch of components across your app which use the same state, use redux. If you have a one-off state isolated in one component, just use useState.
ahh i see, thank u
are there any alternatives to storing JWT in the web browser? i'm going for a login auth system which works so far, and every time a user logs in, it's for a certain amount of time before the JWT expires
Font style
I am thinking to make a covid website
How to make covid counter
Real time counter
Well it will take months to make
As I am new to it and I have my school work also
yes
however there is a problem
when I makemigrations or migrate it will ask where django_heroku is but I already installed it
its weird 🥲
U can use the api thing
Api?
what grade u in?
yes
10
nice
Nice
u can use api to access the data, or using json
import COVID19Py covid19 = COVID19Py.COVID19() covid19 = COVID19Py.COVID19(data_source="csbs") latest = covid19.getLatest() print(latest)
I use flask
what kind of web u want to design
i mean it must look good
well u need some css for that
ok
you can learn any languages
just do
python manage.py makemigrations
than do
python manage.py migrate
make sure directory is correct
you have to save the file
if you are using shell you have to specify by
Modelname.object.save()
and if it's just vsc hit control +s
uh how do i do that? with python manage.py or something?
can I see your code?
sure, what do you need exactly?
first of all try to use crtl + s and than use both migration commands with order that makemigrations come first and than migrate
this might work
the are inbuit if i know
Ok
what is ctrl + s supposed to do? I'm not using vsc
just save the file?
yep save the file
just save a file with name.html or name.css extension
file is saved
i'm trying to apply migrations for models i just created
bruh
Ok
really
What are migrations
hahaha really
it's because i have my pointer there
who know flask better?
@toxic echo when you run python manage.py makemigrations does it make a file in pychache directory?
it doesnt change anything but i had some files there already
your pychache folder doesn't have migrations parent directory
this is a possible solution
delete all migration files
except for init.py
and than run migration commands
within your app directory there is a folder called migrations within that folder there is another folder called pychace in pychache folder delete all files but init.py py and than run migration commands
which version you are using
yeah it does
I want to see your migrations folder within your app directory
and tell me if your app is registered in settings directory or not
actually...
that might be the problem😅
feels so bad🥲
It's not your fault even finest developer make tiny mistakes
do you know how to register your app if not I can help you
i don't, searching for it rn lol
it's easy
in settings.py directory go to installed apps
create a new element in that list such as
'yourappname.apps. '
after .apps. you have to copy paste this thing from your apps.py
the highlighted one
my app name was social app so it would be
'socialapp.apps.SocialappConfig'
let me try
i think it is 'WikiumaApp.apps.WikiumaAppConfig'
can I add you as friend
sure
so we can help each other as a friend when we need cause I am still a begginer
Ight so my problem is this that im trying to make a website with flask i have already pip installed flask and other thing but when I run my code I get an error saying "can't find 'main' module in '[File desination]' "
Who want to speak?
im a beginner to
can I see your code?
I never used flask framework
!paste use this
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
here you go
sure
from website import create_app
app = create_app()
if __name__ = '__main__':
app.run(debug=False, )
I also have another python file that has this line of code
from flask import Flask
def create_app():
app = Flask(__name__)
app.config['SCERET_KEY'] = 'BAKI HANMA'
return app
@naive crater
i can help with flask
sounds good🙂
I think the issue may be with the two files. Try removing if __name__ = '__main__': and see what happens
make
oh wait
True
dude
not False
you have the wrong equal sign
and scobe
it's if __name__ == '__main__':
solve?
nope
i get the same error 🤔
same mistake
and see what happens
waor
show ur code again
wait
your updated code*
wait a min
if name == 'main':
from website import create_app
app = create_app()
app.run(debug=False)
debug is set to false by default I believe, that's not the problem
try making the app in the same file
They are
yes
from website import create_app
app = create_app()
if name == 'main':
app.run(debug=True)
Would you like me to send a screen shot?
Sure
did i not send the right thing?
you need the underscores
it should be if __name__ == '__main__'
yeap
but that's not where it's coming from
do you have a file called python.exe in your scripts folder?
and if so can I see its contents
sure let me check
thank you
sorry this is my first time so how should i open the file?
hold up did you not make that file?
which file?
python.exe
PANJ go to the voice
Yea i think it came in when I used pip install
i wiil help
that's... strange
@sleek crest so it worked?
@native tide can u go ti the voice?
vc?
not sure yet, i am busy with homework so ill try it later
yea
sure
your issue is not in the two files that you sent; I think that code is valid. Something is happening in those external files
@sleek crest oh ok gl with homework and your webscraping project
dang :/ i have tried deleteing and reinstalling flask
i add you
k
I've got to go, but try isolating main.py and running it in something like IDLE (after putting it in a separate folder with your other python file)
alright
Guys is it possible to build a website using python and add a game on it?
what are models for in django, the docs dont rlly explain it
maybe
What are the tools that I'm going to need for that? 
Alot of client side
web based games are gonna be either JS or more recently WASM
in the end it would likely be more of a static page with Python doing api stuff
Need assistance with a web app I’m building . It’s kind of a lot. I think.
I’m using Flask to build it out
is there any sort of django equivalent to get a value of a form field? using this in flask worked just fine x = request.form["fpnum"]
Creating and handling forms can be a complicated process! Django makes it much easier by providing programmatic mechanisms to declare, render, and validate forms. Furthermore, Django provides generic form editing views that can do almost all the work to define pages that can create, edit, and delete records associated with a single model instance.
what is wrong with:
<link rel="shortcut icon" href="Downloads/favicon.ico" type="image/x-icon">
```?
Try
<link rel="shortcut icon" href="/Downloads/favicon.ico" type="image/x-icon">```
I'm guessing it's having trouble resolving the favicon?
I use linux
the icon doesn't load
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="style.css">
<head class="head">hello world </head>
<body class="b">
This is my first website using css
</body>
</html>
.head {
color:aqua;
}
.b {
font-size:2em;
color:black;
background-color: rgb rgb(14, 94, 14) , rgb(62, 204, 62), rgb(35, 248, 16);
}
idk why it is not working
the font size is changing
not the colors
Hello
hi
anyone here that can help me with a django problem?
well i dont even know what it is
oh fuck me nvm, I found the problem
and no errors are showing up
now only bg color is changing
wt hell
try using only one rgb
done
so like background-color: rgb(100,100,100)
solved it
Hey guys, new to Django, wondering how much time took you to be able building a website from scratch?
hm
that depends on how complex a website
Hi guys i am getting a error in deployement of my django app in heroku server.
If somebody could help please dm me.
Alright
the error is literally right there...
what is it??
Yeah i did 3 times
...and what does it tell you?
i am not able to set bg image
read the 3rd line in the screenshot.
not showing any errors
what do you think?
the first step to solving a problem
is understanding what the problem is
I think that i shall change the version
yeah, you can try that
Ok fine should i use 3.8.6?
if you have to ask that question
then it makes me feel like you're not really understanding the problem...
because
if you did
No actually i have 3.8.6 installed
...
why do you think this is relevant?
please help me understand that
what's your answer to my question?
I think that because 3.9.4 is the latest version and it might not have all features whereas 3.8.6 is a stable one. Is this the answer??
...not really?
my question is
you have 3.8.6 installed
okay, fine.
but
that's on your local environment
you are deploying to Heroku
so why does your local version matter?
you're not deploying your Python installation itself
only your Python code
correct?
Hmm right
wt hell
so this is irrelevant.
those words are hurting me
therefore
you are asking the wrong question
you should be asking
how do I tell Heroku which version I want it to use?
think about that.
Yes thats right bro
it's important
to think about the questions you're asking
whether they make sense.
so you can solve your own problems
i am not able to set bg image
So should i change my reqirements.txt??
and it is not showing any errors also pls help
Bro send screenshort of ur page
i mean runtime.txr
.txt
can anyone tell me how to parse this type of content <html>\\n <head></head> \\n <body> \\n <p><img 10-14\\nto=\"\" 10-3=\"\" added.\\nhin=\"\" alt='\\\"The' and=\"\" as=\"\" constant=\"\" dissociation=\"\" follows:\\n=\"1.0\" hc1-5.6x=\"\" hcl=\"\" is=\"\" m\\nassum\\\"=\"\" of=\"\" reaction=\"\" src='\\\"//d2vlcm61l7u1fs.cloudfront.net/media%2Fbb5%2Fbb5b5285-b37b-44ad-ae44-5feb873a4ec7%2FphpTaH4Ws.png\\\"' style='\\\"height:453px;width:567px;\\\"' this,=\"\" water=\"\" x=\"\"/></p> \\n <p><img (1.32x10=\"\" alt='\\\"Solve' as=\"\" calculate=\"\" follows:\\nph-logh]\\n-log=\"\" for=\"\" h7.6x10-=\"\" m)\\n\\\"=\"\" m+(5.6x10-*)=\"\" m\\n1.32\u00e3\u201410-7=\"\" m\\nnow=\"\" m\\ntotal=\"\" ph=\"\" src='\\\"//d2vlcm61l7u1fs.cloudfront.net/media%2F022%2F0226e5b7-47fc-4d27-907a-57c0a3759188%2FphpmIT4cp.png\\\"' style='\\\"height:510px;width:392px;\\\"' the=\"\" x.\\nx-7.6x10=\"\"/></p> \\n </body>\\n</html>
When using Scrapy pipelines, all items are sent to all pipelines? There's no way to determine what items goto what pipelines?
do you put your Python version in your requirements.txt?
I really fail to grasp this concept.
honestly I don't know the answer to this but I saw you asking that question
and my gut feel is no (you can), but I haven't worked with Scrapy
sorry
you want to turn the HTML into a Python object?
BeautifulSoup
Looking under the hood, this seems to be the cast. I just don't understand why.
no
you need to show your CSS
Thank you for the response.
then?
I want to parse this type of content on html string
what?
No i meant runtime.txt by chance i wrote requirement.txt
like I have to convert this type of content in a html code
try it
I said
this is how it is coming
show CSS
.head {
color:blue;
font-style:oblique;
}
#b {
background-image:src("https://wallpapercave.com/wp/wp3850825.jpg");
}
it's not really clear what you expect the output to be
your CSS isn't even well-formed
unless there's some other stuff I'm missing
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="style.css">
<h1 class="head">HELLO WORLD </h1>
<body id="b">
</body>
</html>
I want to parse this content in a simple html code
how?
oh never mind
hm
your body is empty
put some stuff in your body
it should work
like you're repeating yourself but I still don't understand so unless you can show an example or something...
i did
like some text
sure
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="style.css">
<h1 class="head">HELLO WORLD </h1>
<body id="b">
This is my first website using css
</body>
</html>
see
even after this
.head {
color:blue;
font-style:oblique;
}
#b {
font-size:2em;
color:black;
background-image:src("https://wallpapercave.com/wp/wp3850825.jpg");
}
<html>\\n <head></head> \\n <body> \\n <p><img 10-14\\nto=\"\" 10-3=\"\" added.\\nhin=\"\" alt='\\\"The' and=\"\" as=\"\" constant=\"\" dissociation=\"\" follows:\\n=\"1.0\" hc1-5.6x=\"\" hcl=\"\" is=\"\" m\\nassum\\\"=\"\" of=\"\" reaction=\"\" src='\\\"//d2vlcm61l7u1fs.cloudfront.net/media%2Fbb5%2Fbb5b5285-b37b-44ad-ae44-5feb873a4ec7%2FphpTaH4Ws.png\\\"' style='\\\"height:453px;width:567px;\\\"' this,=\"\" water=\"\" x=\"\"/></p> \\n <p><img (1.32x10=\"\" alt='\\\"Solve' as=\"\" calculate=\"\" follows:\\nph-logh]\\n-log=\"\" for=\"\" h7.6x10-=\"\" m)\\n\\\"=\"\" m+(5.6x10-*)=\"\" m\\n1.32\u00e3\u201410-7=\"\" m\\nnow=\"\" m\\ntotal=\"\" ph=\"\" src='\\\"//d2vlcm61l7u1fs.cloudfront.net/media%2F022%2F0226e5b7-47fc-4d27-907a-57c0a3759188%2FphpmIT4cp.png\\\"' style='\\\"height:510px;width:392px;\\\"' the=\"\" x.\\nx-7.6x10=\"\"/></p> \\n </body>\\n</html into this <html> <head></head> <body> <p><img alt="The dissociation reaction and constant of water is as follows:= 1.0 x 10-14To this, HCl is added.Hin HC1-5.6x 10-3 MAssum" src="https://d2vlcm61l7u1fs.cloudfront.net/media%2Fbb5%2Fbb5b5285-b37b-44ad-ae44-5feb873a4ec7%2FphpTaH4Ws.png" style="height:453px;width:567px;"></p> <p><img alt="Solve for x.x-7.6x10 MTotal H7.6x10- M+(5.6x10-*) M1.32×10-7 MNow calculate the pH as follows:pH-logH]-log (1.32x10 M)" src="https://d2vlcm61l7u1fs.cloudfront.net/media%2F022%2F0226e5b7-47fc-4d27-907a-57c0a3759188%2FphpmIT4cp.png" style="height:510px;width:392px;"></p> </body></html>
AH
okay
let me think about this for a moment
👍
shouldn't that be url("https://wallpapercave.com/wp/wp3850825.jpg");
okay
my gut feel is that
ok
so, is there any solution to that?
doubt it
like you can tell that the words are alphabetically ordered
yw 👋
sorry but I can not understand
okay you see
in the result
th text goes
"The dissociation reaction and constant"
but in the first one the order is "and", "as", "constant", "dissociation", "follows"
a to z
right?
the order of the original is lost
I want to scrape content from the site and want to parse it in my own html file.
why is the HTML even scrambled like that
I don't know 😅
are you here?
@vestal hound
what?
can you help me pls?
Bro stop thnx you did helped me a lot bro
yw
why is it that when i give:
return redirect("accounts/login")
it searches for the current url + "accounts/login"
but when i do:
return redirect("login")
it searches for login for the base url + login from the urls.py of the apps folder in django?
hi i need help
i have a small page which shows data from database
also it has print button
when i click on button nothing happen
i need to print the page
can someone help me
in .net
SCRIPT16389: SCRIPT16389: Unspecified error. rptHRDScholarshipsProvinceWise.aspx (518,20)
at this line
var printWindow = window.open('', panel, 'height=400,width=800');
thanks, i did it
#help-mango if anyone has a second to just answer a question 🙂
Hi, everyone!
I am behaving strangely from an html page. Only inside the Iphone does it behave this way, zooming in when opening the content. Does anyone know if this could be a css problem?
Did you set the appropriate size
I'm not sure if this is the right place to ask, but here's what I'm wondering. For one of my classes we use a website that has physics questions, however while the questions are the same for everyone, certain values change. My guess is that for each question, the system has a problem specific formula that it uses to grade the problems and determine the correct answer (I don't think that the people who made this website sat down and manually calculated every option). Theoretically, if you had access to the whole website would these formulas be visible? Would it be stored in the backend with password stuff?
My understanding of web stuff is VERY limited so tell me if I'm completely wrong
maybe it could be done in javascript, like var = input_1 + input_2 then return var
Yes, you'll most likely be sending a POST request to an API endpoint with the user endpoint, the API checks if the answer is correct / incorrect and returns a response. Either that or it's all client-side (which is unlikely).
from the docs:
The arguments could be:
A model: the model’s get_absolute_url() function will be called.
A view name, possibly with arguments: reverse() will be used to reverse-resolve the name.
An absolute or relative URL, which will be used as-is for the redirect location.
https://docs.djangoproject.com/en/3.2/topics/http/shortcuts/
It will redirect to the URL that the login view serves.
ok. theoretically, could you...find a way to get access to the API so that you can test answers without actaully submitting that answer?
no
are there any free smtp server which don't ask us to provide all the company info and personal info during siignup?
What am I doing wrong?
is the app_name folder your root directory?
Well I have 2 folders with app_name 1 as the root directory and one as the app folder django created inside the root directory
have you provided names for each or your paths?
Yeah
so why don't you just redirect to the name of the path?
Sorry I’m on mobile rn or I could’ve showed u the error
Basically it said it went through all my paths in the urls.py of the app_name folder and couldn’t find the path with path_name
Here the name of the path is login
Wait nvm I think I found the error
Ty @opaque rivet
if you could show the urls.py I would be able to answer the question, if you have:
urlpatterns = ['my_url', view, name='redirect-here']
you can redirect, via redirect('redirect-here'). Other than that you may have forgot to include an other app's urls in your root urls.py.
where can i learn creating a website wide login authentication in flask
youtube
I don't know if this is the correct place ot ask, but how do I host a html page with aiohttp? Whenever I run it and have it serve the HTML, it just shows the actual html.
?
I checked and couldnt understand it, they showed authenticate to one page, or authentication for each page individually
The code I have is ```py
import asyncio # Parallel loops
from aiohttp import web # Running servers n stuff
f = open("html/mainpage.html")
mainpage = f.read()
async def handleMainsite(request):
text = mainpage
return web.Response(text=text)
app = web.Application()
app.add_routes(
[
web.get('/', handleMainsite)
]
)
web.run_app(app, host='0.0.0.0', port=8081)
im not sure how that works
would u mind share ur code
I didnt "code" anything yet, was just watching the videos
as i wasnt sure what does what
nvm i got something
ty
Soo, my CSS just run away from me, how can i put the Admin CSS from django again?
Hi
u can add a urlfor in html to find the css file
How to change position of text and images
I know the tags but don't know how to use them
Even after seeing multiple examples
The only thing I am lacking is with width,height,size, alignment
isnt that all u need? lol
But its the admin page of django
How can i put this?
are you by any chance running django in production mode?
Anyone know why I'm getting TypeError: on_delete must be callable. if my model has no on_delete in it?
game_played = models.ForeignKey(Game, "Game Played", help_text="Game Played", null=True, blank=False, default="")
If I add it, then it says there are multiple values conflicting for on_delete.
Hey anyone know how to set up the file structure for a flask app? I currently have everything in one big file (i know its not optimal), and I want to separate it into separate files. I know where to put my routes and models, but I have no clue where to put the config and imports... does it go in __init__.py or ?? And also which file do i define as FLASK_APP after i seperate them?
hmu with an @ :D tyty in advance
Hello fellas,
First of all this question is about django.
I have two event type defined as model. Admins can create one of that event whatever they want.
I need to do this;
When created an event with one of that event types, i want to add the event to a table in database. I am stuck with this. May be i am thinking wrong i don't know.
Thanks for any help or any comment
im getting spammed with this Not Found: /manifest.json [23/Apr/2021 17:32:22] "GET /manifest.json HTTP/1.1" 404 2307 using django and react. any ideas on what i would need to look for to fix this?
I'm justing running "runserver" on my local computer like i always do
if you're running a server, you're going to get scanned by people trying to find silly vulnerabilities, such as exposing a secrets file for everyone to read.
perhaps ask in #cybersecurity
oh okay. i dont know how or why it even started doing this. i dont have any sensitive information was just trying to figure out how to get it to stop spamming 🙂
ill ask in there though if thats the best place
it is just on django side i dont get it just running the react on it's own.
i assume its not pointing to the manifest.json properly some how?
Can anybody please help with deploying a flask app to heroku?
Stupid question (I just don't know how to phrase it in Google): Can someone point me to the right resources if I would like to create a Django app that would have interactive element like when I program with JavaScript. For example,
function example() {
$("id").innerText = "test";
}
Or changing states or animation
no i solved that problem by doing
path('accounts/', include('django.contrib.auth.urls')),
in my urls.py of the app_folder
having problem with static files?
Why you using default="" if you have null=True?
anyone proficient with flask?
send me ur code
@native tide send ur code asap
and ping me when u sent
Can we test the facebook login api on other than the test users
Like we have to write coordinates?
you mean alight ?
text-alight: <position>;
What is the position value
Ik that
But I don't want to set it too center or right or left
I want it to be customised
then make it bottom: 0;
top: 0;
right: 0;
left: 0;
u can customize like this
and note it those are oppsoite in css if u make top 100% it will go bottom
like that
it is opposite in css
@modest swallow if you want to learn flask you could watch the video series by Tech With Tim
Have anyone done week view calendars in Django?
If there isn't one, maybe I have to create one myself using python datetime and calendar, but if there is that would be huge help.
hey guys i need some help ..so this is the view file as you can see i successfully stored the image url in the link variable
so how can i add the url of the image inside this html img src
so that the image can show in this page?
look into flexbox
I am also making a mobile website
its not only for mobiles...you can search anything from laptops to cosmetics..evrything and it will fetch the prices from the two websites
Ohk
Nice
How are you thinking to write the details of the product
Specifications
using bs4 and html requests i can just find the div and class name of the description they are in(in the amazon website) so that i can print out the description of the prdct
yeah i made it with the help of beddimcode youtube channel
https://youtu.be/ic2k1bXhju8 fully responsive
Responsive Product Card Landing Page HTML CSS JAVASCRIPT | Mobile First
Source code ⤵️
https://github.com/bedimcode/product-card-sneaker-air-max
Subscribe for more! 🔔
https://www.youtube.com/c/Bedimcode?sub_confirmation=1
Follow me ⤵️
Instagram: https://www.instagram.com/bedimcode/
Facebook: https://www.facebook.com/bedimcode
Support me, buy...
is there something like @login_required() to check if a user isnt logged in in django
there is always option to write own decorator, if you will not find how to do it properly
this one I wrote to check for super user rights for admin actions
@superuser_only
def make_saved(__, request, queryset):
"admin action: save farhub table as json"
save_serializer('json/farhub.json', 'json', queryset)
def is_superuser(request):
"check if user has superuser rights"
if json.dumps(request.user.is_superuser).lower() == 'true':
return True
return False
I guess you can check whatever request has, may be you have there user too
I wrote it a little bit horrible in term of checking for true, be sure to make it better)
Hi everyone—I'm new to django, long-time JS/Rails developer.
Is there a standard way of accessing a model instance from a Form subclass?
class RatePlanForm(OrgFormMixin, forms.ModelForm):
cancelation_policies = forms.ModelMultipleChoiceField(
# TODO Scope this to the current org
queryset=Policies.all(),
required=False,
widget=forms.widgets.CheckboxSelectMultiple()
)
class OrgFormMixin(object):
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
self.org = kwargs.pop('org')
I want to scope Policies to something like org.policies, but not sure how to go about it
:incoming_envelope: :ok_hand: applied mute to @native tide until 2021-04-24 13:26 (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).
It seems like I can do this by overriding the __init__on the form subclass and doing something like:
class RatePlanForm(OrgFormMixin, forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['cancelation_policies'] = forms.ModelMultipleChoiceField(
queryset=self.org.policies.all(),
required=False,
widget=forms.widgets.CheckboxSelectMultiple()
)

Yeah?
What data are you trying to access? Better yet what are you trying to do?
424 lines of css!!!!!!
you can download from git hub for free
modify it and you got yourself a webpage
responsive one
i thought lines were terrifying....
Yeah but the result is also very good
so what r u working on ?
I am creating a mobile website
It will show a phone with all its specifications
Phone at the center and around it squares will be there showing the features
First I was thinking to make card effects but it was very advanced for me and I didn't understand
Gradient background
maybe this will help
same as my current project
Yeah
But I haven't done anything yet😓
Except placing phone and meeting background colour
you might have to learn python and django so you can use bs4 and html requests to scrape data from other websites and make your webpage dynamic
You mean to update details from different websites?
I have learned basic python
After learning average web developing I will learn python
What is django used for?
no need to update on our side ...
django is a webframework for python
it my final year project for college
Ok
if all goes well ...i will graduate
You will
yeah maybe ...
the teachers are saying my project is so simple
and nothing interesting in there
all they care abt is work done in php
<!DOCTYPE html>
<html>
<h1 class="name">Realme 8 Pro</h1>
<link rel="stylesheet" href="style.css">
<body class="body">
<div class="logo">
<img src="https://www.starshopping.in/image/cache/catalog/r-228x228.png">
</div>
<div class="phone">
<img src="https://cdn-files.kimovil.com/phone_front/0005/86/thumb_485898_phone_front_big.png">
</div>
<div class="camera">
<h4>Camera</h4>
</div>
</body>
</html>
.body {
background: linear-gradient(to right, #9c279c, #8ecdff);
}
.logo {
margin-top: 1%;
margin-bottom: auto;
position: static;
}
.phone {
display: block;
margin-left: 45%;
margin-right: 50%;
margin-top: 1%;
}
.name {
text-align: center;
font-family: sans-serif;
color: #ffffff;
margin-top: 20%;
font-size: 5rem;
}
.camera {
width: 300px;
border: 15px black;
padding: 50px;
margin: 20px;
background-color:black;
}
the only thing it is doing is displaying logo phone image and model name
idk why it is not showing the box
no error is coming
Which bit of the code do you expect to display a box?
.camera one
Try 15px solid black;
Can anyone see why my relationship isn't working:
class Inventory(db.Model):
__tablename__ = 'inventory'
id = db.Column(db.Integer, primary_key=True)
inventory_id = db.Column(db.String(10), unique=True)
tracking_number = db.Column(db.String(100), nullable=True)
user_inventory = db.relationship('Ticket', backref='ticket_assigned_to', lazy=True, uselist=True)
class Ticket(db.Model):
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
user_inventory = db.Column(db.String(10), db.ForeignKey('inventory.inventory_id'))
t = Ticket().support_users_tickets()
for i in t:
print(i.user_inventory.tracking_number)
'str' object has no attribute 'tracking_number'
its not getting the relationship.
I have checked the database, and inside ticket, it has the correct inventory_id value
Lol I don't even know one word of this
I want to create a button that sends you to the particular part of the website
So I have to use anchor and href or anything else
for borrower in Borrower.objects.all():
stid = borrower.student.id
bid = borrower.book.id
student1 = Student.objects.get(id=stid)
book1 = BookName.objects.get(id=bid)
if parse(borrower.return_date) <= timezone.now():
student1.total_books_due = F('student1.total_books_due') - 1
student1.save()
book1.available_copies = F('book1.available_copies') + 1
book1.save()
borrower.delete()
here why are the values of total books due and available copies not getting updated
also if i change the if condition to if True: it is working fine.
and there are no errors in the console
guys in which channel should i go for webscraping ?
idk if you should but most people with webscraping question ask them here
ok, im trying to webscrape info from a json in a website but iget this exception raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
for some reason when i use json.loads(string) it just doesnt seem to work
bc u cant compare datetime objects like that. I thought so too but I know better now.
I solved it by subtracting them and checking if the difference is greater than a second like so:
((self.end - datetime.datetime.now(tz=pytz.UTC)) > datetime.timedelta(seconds=1))
and self.end is your books due date
If you wonder where to put the code. I just put it into models.py as a property method
but when i print the statements its returning true and false when required
ok then mby your reassigning is false.
F('student1.total_books_due') - 1
idk what that F does and never saw it by reassigning so mby thats false
it just avoids race conditions and the syntax is also correct
if i just change the condition for if to be true its working fine else it just ignores the update code but deletes the borrower object. it's like skipping 4 lines of code while running
ok but that means the reassigning is not working and therefor its not saving anything but bc it doesnt throw an error it still deletes the borrower
class User(db.Model, UserMixin):
__tablename__ = 'user'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(20), unique=True, nullable=False)
medicines = db.relationship('Medicine', backref='doctor', lazy=True)
class Medicine(db.Model):
__bind_key__ = 'medicine'
__tablename__ = 'medecine'
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) ```
This is mine and work fine
if i make the conditions as default as true its reassigning fine. Btw i figured out the problem. I had installed django-sslserver to make https site but i just used the http server and it started working fine.
so i think something in the sslserver package is interfering
ok great for you but how you explained it, it sounded like the reassigning is false even tho it worked when if is equal to true
Can someone point me to the right resources if I would like to create a Django app that would have interactive element like when I program with JavaScript. For example,
function example() {
$("id").innerText = "test";
}
Or changing states or animation.
I am just not sure what to search to find a way to attach css and js to my html templates.
yeah that was the problem. I still dont get why just changing a condition will change what is happening inside the if block
Is it ok to store sensitive info in the session data?
is possible to add / setup django celery outside django proyect?
what do you mean an external databasea?
like a 3rd-party API?
what do you mean "outside of the project"?
well
it has to have some sort of interface
for you to interact with it
e.g. HTTP API
okay
how about you explain
what exactly your problem is
if you want anything more than basic JS, you might want to consider django-rest-framework instead
I just want to add interactive elements to the html files. I know that normally, you can attach the js and css to html, but I am not sure about django.
they're just HTML files
you can do whatever you would normally do
why?
wym
why is the structure like that?
becuase it is
in short, yes
how do you know it's being ignored?
So, django will compile the external css and js and send that over to the client side too?
it doesn't need to be compiled
but basicall
y
a Django template is just a HTML file with "holes" in it that a view will fill
it's more or less a big f-string
why not?
!e
from datetime import datetime, timedelta
print(datetime.now() > datetime.now() - timedelta(seconds=1))
print(datetime.now() > datetime.now() + timedelta(seconds=1))
@vestal hound :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | False
I see, thanks @vestal hound !
yw 👋
yo could i get some help for HTML & CSS?
so im using this site called codeacademy
Take a look at index.html. Cut the CSS code ruleset in between the opening and closing <style> tags and paste it directly into the file called style.css.
Delete the remaining <style> element (now empty) from index.html and press the Run button.
Hmm, the font changes didn’t take effect? Click the Next button to find out why.
You can connect your django to multiple databases
(Or just change default db connection to external one)
You can use inspect command, in order to re create classes of inspected db
You can use raw sql commands in order to go without classes
("INSERTI INTO...")
Basically... you aren't restricted by anything
setup multiple database
Hmm I don't find any errors in the html and css
Try to write it inside body tag
In the image line there is no need of /
Bruh why have you written title inside head
need some help
const UserProfile = {
name: 'userprofile',
template: `
<div class="profilecard1">
<img>
<h1> Full Name </h1>
<p> username</p>
<p>bio</p>
<p>email</p>
<p>location</p>
<p>joined</p>
</div>
<div>
<h1> Cars Favorite <h1>
</div>
<div class="cars-favorite">
<img src="./static/">
</div>
`
};
const NotFound = {
name: 'NotFound',
template: `
<div>
<h1>404 - Not Found</h1>
</div>
`,
data() {
return {}
}
};
// Define Routes
const routes = [
{ path: "/", component: Home },
{ path: "/register", component: Register },
{ path: "/auth/login", component: Login },
{ path: "/cars", component: Cars },
{ path: "/upload", component: UploadForm },
{
path: "/users/{user_id}",
component: UserProfile
},
// Put other routes here
// This is a catch all route in case none of the above matches
{ path: '/:pathMatch(.*)*', name: 'not-found', component: NotFound }
];
app.component('app-header', {
name: 'AppHeader',
template: `
<nav class="navbar navbar-expand-lg navbar-dark fixed-top">
<a class="navbar-brand" href="#">United Auto Sales</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<router-link to="/home" class="nav-link" to="/">Home <span class="sr-only">(current)</span></router-link>
</li>
<li class="nav-item active">
<router-link to="/cars" class="nav-link">Add Car</router-link>
</li>
<li class="nav-item active">
<router-link to="/profile" class="nav-link">My Profile</router-link>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item active">
<router-link to="/register" class="nav-link">Register</router-link>
</li>
<li class="nav-item active">
<router-link to="/auth/login" class="nav-link">Login</router-link>
</li>
</ul>
</div>
</nav>
`
});
can anyone tell me when profile route link not showing when I click it in the header
please need some help
because the values aren't changing. Even print statements in that case are ignored as nothing is printed on the console but the last line is always executed.
@charred berry you see my issue?
u havent mentioned any url linking to /profile.
{ path: "/profile", component: UserProfile }, ```
and still didn't work
@charred berry I did that and still nth
I am getting 404 not found
anyone can help?
share the exact error statement here
it's not error, it's just returning ```js
const NotFound = {
name: 'NotFound',
template: <div> <h1>404 - Not Found</h1> </div> ,
data() {
return {}
}
};
@charred berry look at the code above
I want it to show UserProfile component
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
look at full code @charred berry - https://paste.pythondiscord.com/erilupabiy.csharp
I want UserProfile component to show when I go to the router-link /profile
hope you see what I am saying
yeah i know what you want but i havent implemented it this way so i really dont know what to lokk for
sigh
hey guys, can somone help me with google maps api, i want to place a google maps window on my react page, currently the page is empty but i was wondering if somone could help me setup google maps api onto my react page
Hi guys, tell me how to transfer an image from Flask server via socket io to react. I have been struggling with the problem for a very long time, but the event is not sent from the server, and the client does not react in any way. It is possible that the server sends a picture, but react only catches promise pending...
okay, nevermind guys, have a good day 🙂
Encode image to base64, send, decode ;b
Or just share in flask static and give url
hey guys, anyone good at react?
<div class = "card-body">
<div class = "car-title">
<h3 id="title1">Car Title</h3>
<span id="price1" class="price-tag"> $356335 </span>
</div>
<p class="car-text">Huracan</p>
<button type="button">View More Details</button>
</div>
anyone css to get id=title1
and price1 next to each other?
can you elaborate, didn't understand u
I want Car title and $356335 to be in the same line
but they are below each other
@fading cargo
display flex and justify content
for the parent div
you see the div element with the class ="car-title"
add this to it:
display: flex; justify-content: space-between;
update me if it worked or not
okay
wait, instead of space-between put center, otherwise they'll be throwed to the edges of the parent div xD
it worked, thanks. Is there a way to control the space
yes
you can simply google justify-content values css
here u go:
The justify-content property is a sub-property of the Flexible Box Layout module. It defines the alignment along the main axis. It helps distribute extra
I used space between because center moved the title away from the margin
wanna share screen ?
<div>
<label for="toggle" class="hamburgerboi">☰</label>
<input type="checkbox" id="toggle" class="check_box_class">
</div>
#toggle:checked{
background: red;
}
Why doesn't this work?
Thank you @fading cargo for the great assistance, means a lot
is it better to do the authentication process with django or react
bcs i used to work with a project with a couple of friends and we were using django and react but they decided to do the authentication with react and i don't know react so i was considering learning it
you are welcome friend
if you have good understanding of ES6 you are set to learn react
for authentication with react, you can do it through firebase (it's free till u reach a certain level) or you can do it by using local storage, so for example you get the logged in user object and keep it in the local storage and keep the token in the cookies
i prefer django bcs i don't know react but my question is is the authentication usually done using django or react
anyone good at react? I have a startup project to discuss about..If you are good at react dm me
bro you have to understand that authentication differentiate from an app to another, the advantage of using react in ur case is to relief stress from ur server, cause the server will be handling the view rendering each time the user goes to new URI
using fire base for authentication will relief stress from the server since it's gonna happen through another API, but eventually if you have a new user signed in, you would want to keep a copy of his infos on ur database for sure
so even when your business grow you can use that data base for email marketing and so
Ok thank you
authentication can be done from both, whether from react to fire base, or react to django, react is only your frontend framework, but there will be some security stuff like handling users tokens in order to guaranty the authenticity of that logged in user
it's a minimalist framework for web dev, not hard to learn
I see thank you
So react boosts performance?
i know flask i want to ask
If i spent my time learning flask would i still need to learn js?
@fading cargo
how i can to bring out user email in a page
it reliefs some stress from ur server, and it will mimic the user experience of a desktop application coz there will be no loading time
so yes, ur app becomes better overall
Thanks
flask is a backend framework, you can use it to create mvc applications, if u ever needed to create something in terms of frontend u'll have to touch some vanilla javascript
long story short, flask is a framework, js is a language, 2 different things
So i dont need to get into backend js right?
in terms of backend yes, flask can do the job and u wont need to do the backend in js
im using flask to process data that react frontend gathers such as registration and stuff
good, are you protecting your APIs endpoints using jwt ?
don't forget to do that, otherwise if i my self knew your API end point, i can see http requests using postman alone xD
i wont do that but i'm warning u on what people with bad intentions can do
im still learning how to make the whole thing, im still a newbie to react, also i need to learn how to use sqlalchemy
that's a cool ORM
you are on the right path
i'm here to help, if anything just tag me
are you good at js? cos i have a issue
im trying to use this mapbox module to get a mapview onto my browser and this is the error code
what kind of prob
Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `MapDisplayNoExtras`.
this is my code
/* eslint-disable no-unused-vars */
/* eslint-disable max-len */
/* eslint-disable linebreak-style */
/* eslint-disable require-jsdoc */
/* eslint-disable react/no-unescaped-entities */
import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
import ReactMapboxGl from 'react-mapbox-gl';
var Layer = ReactMapboxGl.Layer;
var Feature = ReactMapboxGl.Feature;
require('mapbox-gl/dist/mapbox-gl.css');
const Map = ReactMapboxGl(
{
accessToken: "pk.eyJ1IjoiMXJvaGFhbiIsImEiOiJja253eGlpNXcwdnNpMnVwajZsdzRlYXI5In0.vAECi86C5Szo-3R6SiQ0iw" }
);
// eslint-disable-next-line require-jsdoc
export class MapDisplayNoExtras extends React.Component {
// eslint-disable-next-line require-jsdoc
render() {
return (
<div className="App">
<header className="App-header">
<Map
style="mapbox://styles/mapbox/streets-v9"
containerStyle={{
height: '100vh',
width: '100vw'
}}
>
<Layer type="symbol" id="marker" layout={{ 'icon-image': 'marker-15' }}>
<Feature coordinates={[-0.481747846041145, 51.3233379650232]} />
</Layer>
</Map>;
</header>
</div>
);
}
}
export default MapDisplayNoExtras;
idk why its telling me its not exported cos its clearly exported twice
because it successful for 1 second and then it throws the error
friend, why you exporting it twice ?
to try to fix the export issue
you never export a class twice
i always do my classes as arrow functions, this class declaring is old meta
can u replace export class by "function"
nah i dont want to use hooks
ok just remove the export before the word class
and put require('mapbox-gl/dist/mapbox-gl.css'); before your variables declaration
and
const Map = ReactMapboxGl(
{
accessToken: "pk.eyJ1IjoiMXJvaGFhbiIsImEiOiJja253eGlpNXcwdnNpMnVwajZsdzRlYXI5In0.vAECi86C5Szo-3R6SiQ0iw" }
);
put it inside of your class
do so and update me plz
i'm sleeping in 5 minutes
@swift wren
dude its fine im moving on from this, thanks for the advice tho
why move on when u can fix it in 30 seconds, put all ur variables inside of the class, make the access token a variable in the .env file, and just remove the export word before the class
Hello,
I'm Will and i'm making a custom keyboard and PC company and i need a person to help me design the website, all the HTML is complete and i just need you to design it for me.
DM ASAP
i fixed it. but thank you broski
is it as i said ?
no i had to refactor the whole thing
can you share the newer version
i'm curious, i didn't use classes in react for long time, wanna make sure if i'm right or mistaken, so i can help others
/* eslint-disable no-unused-vars */
/* eslint-disable max-len */
/* eslint-disable linebreak-style */
/* eslint-disable require-jsdoc */
/* eslint-disable react/no-unescaped-entities */
import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css';
import ReactDOM from 'react-dom';
import mapboxgl from 'mapbox-gl/dist/mapbox-gl-csp';
// eslint-disable-next-line import/no-webpack-loader-syntax
import MapboxWorker from 'worker-loader!mapbox-gl/dist/mapbox-gl-csp-worker';
mapboxgl.workerClass = MapboxWorker;
mapboxgl.accessToken = "pk.eyJ1IjoiMXJvaGFhbiIsImEiOiJja253ejN0NHgwZjV6MnZuNHVuanJqa2xnIn0.Ls1HOpDT6fwneXOxetJYBw";
// eslint-disable-next-line require-jsdoc
class Map extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
lng: -70.9,
lat: 42.35,
zoom: 9
};
this.mapContainer = React.createRef();
}
componentDidMount() {
const { lng, lat, zoom } = this.state;
const map = new mapboxgl.Map({
container: this.mapContainer.current,
style: 'mapbox://styles/mapbox/streets-v11',
center: [lng, lat],
zoom: zoom
});
map.on('move', () => {
this.setState({
lng: map.getCenter().lng.toFixed(4),
lat: map.getCenter().lat.toFixed(4),
zoom: map.getZoom().toFixed(2)
});
});
}
render() {
const { lng, lat, zoom } = this.state;
return (
<div>
<div className="sidebar">
Longitude: {lng} | Latitude: {lat} | Zoom: {zoom}
</div>
<div ref={this.mapContainer} className="map-container" />
</div>
);
}
}
export default Map;
why i cant see border line with this ```css
table {
width:100%;
font-size: 20px;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
}
try adding this:
z-index: 1;
in the second class
and update if it worked or not
Has anyone used put requests with django rest?
is it for updating purposes ?
Try increasing border thickness or change the value from 1px to something big
seems like you are right, just looked again and i can barely notice that 1px thickness haha
Yes
I am having a pr9blem where it says method not allowed when I send a put requesy
updates are done through post request, you learn put in school but you don't use it in actual programming
Why not?
who told you that?
And if so how can I update through a post request?
if you want to update existing data, use a PUT request. For your DRF view, did you set the allowed methods in the @api_view decorator?
No
I dont have such decorator
class OptionViewSet(viewsets.ModelViewSet):
queryset = Option.objects.all()
serializer_class = OptionSerializer
filter_backends = [DjangoFilterBackend]
filterset_fields = ['question', 'correct']
authentication_classes = [TokenAuthentication] # Autentifikācija ar token
permission_classes = [IsAuthenticatedOrReadOnly] # Iespējams GET bes auth, bet POST nepieciešams auth
def update(self, request, pk=None):
pass
def update(self, instance, validated_data):
options_data = validated_data.pop('options')
options = (instance.options).all()
options = list(options)
instance.q = validated_data.get('q', instance.q)
instance.xtraInfo = validated_data.get('xtraInfo', instance.xtraInfo)
instance.image = validated_data.get('image', instance.image)
instance.save()
for option_data in options_data:
option = options.pop(0)
option.choice_text = option_data.get('choice_text', option.choice_text)
option.correct = option_data.get('correct', option.correct)
option.save()
return instance
To send an email to a mailing list do I use threading to send each person with TO instead of BCC?
The update is in the serializer class not viewset the second ine@opaque rivet
Since it’s IO bound?
I don't really use class-based components, but you do have the put method in your class based view?
I dont have a seperate view except the viewset itself
So what you see there is all put if I call the update put instead nothing changes@opaque rivet
Lol thickness of 1 px
It is literally so small
maybe this will help
authentication has its role in both the backend and the frontend, but the rule of thumb is to keep all of the business logic on the backend, so that's where the authentication will be done - and your frontend just stores your user token.
<div class="Hamburger">
<input type="checkbox" class="check_box_class" id="hamburger_label">
<label class="hamburgerboi" for="hamburger_label">☰</label>
</div>
#hamburger_label:checked + li{
color: green;
}```
Why won't this work?
@opaque rivet will take a look a bit later, thanks, is it ok if I ping you then if I jave any questions?
can u describe what you want to happen and when ?
you are selecting element by class, but you have no element with a css class named: hamburger_label, please check again what u want and get back to me
sure, 🙂 not too familiar with class components, I might have to switch
they are selecting by ID
@fading cargo ok well I am trying to make something show up when I click on a button
bsaically when I click on the button I want the color of the <li> to change to green
:checked is only for radio / checkbox inputs or <select>
which you have
so what should I do?
<input type="checkbox" class="check_box_class" id="hamburger_label"> Thats the important line
input:checked + label {
color: green
}
This should select all labels directly after checked inputs
what class? and, which <li> elements? You showed none in the code.
<input type="checkbox" class="check_box_class" id="hamburger_label">
<label class="hamburgerboi" for="hamburger_label">☰</label>
</div>
<li>hi</li>```
if you go back to css selector basics, in your code you are selecting <li> element that is placed exactly the element that has ID hamburger_label when it's checked
here to select the li element you should go by div+li
in the css?
yes, but u want it to change color only when the checkbox is ticked, i'm thinking of it, wait
ok
input:checked ~ li{
color: green;
}
So you want it just to change the color of the li?
for now
You can use this, it selects any li after your selected inputs, the + selector won't work in your original code because the + selector only selects elements which are placed directly below the input.
also your IDs are confusing. Don't give your input the id hamber_label when it's clearly not a label.
This doesn't work for some reason
and yes I know what you mean
I have weird names for classes xd
because your inputs are within their own div, the elements have to be in the same scope for that selector to work.
So my app workings fine locally. however when deploying to Heroku and trying to login, I have a couple of issues.
Sometimes it gives me "invalid csrf token" even though its valid
sometimes it will login me in, send me to the dashboard, and return a 302 and send me back to the login page. I believe this is something to do with the login decorators? But it works fine locally.
Does anyone know why Heroku is giving me these issues?
bc of your question i assume u r using django and once deployed debug is off. So I would locally turn off the debug and check if its still working and if not django can send you a detailed explaination of the error if you specify an admin in the settings.py like so
ADMINS = [("Username of the Admin","Email of the Admin")]
and make sure you got the email backend configured as well
Who can help me with flask?
hi, i really need help with building a chat app in django. i built already the site now i need to make the chat with socket or django channels. can some one help me with it?
im very new to django so it is very difficult for me to do this app
(i tried lots of tutorials but its hard for me to understand when i cant ask questions)
I fix the issue. It was because I was using urandom to generate my secret key. I fixed it my manually setting the key
great for you
what is command to start virtual env in django
workon
could anyone help me with this thing in heroku
I am trying to install their cli, but it keeps saying that it is getting blocked by the administrator
how can I fix this>
huh
it is not django tied command
python -m venv venv
python3 -m venv venv
(depended on which is your OS)
requires installed python3-venv
it is from standard python package I guess
if it is not there, it is installed with pip
source venv/bin/activate
to activate your virtual env after you create it
hello
so i tried creating this in django
def detail(request,question_id):
try:
question = Question.objects.get(pk=question_id)
except Question.DoesNotExist:
raise Http404("Question does not exist")
return render(request, 'polls/detail.html', {'question': question})```
this is the detail view in my code but it doesnt output the error on the screen
can someone explain what im doing wrong here?
Can anyone help me use this module https://pypi.org/project/flask-simple-captcha/
I am currently confused on how to add an app config
try python manage.py startproject hello