#web-development
2 messages · Page 222 of 1
in html
and get the info from the form in the python end
this isnt really related to python stuff but GODDD this infuriates me to the core
that little move of the images pisses me off so much 😭 idk what to do about it
thanks
Hey guys, one question.
How do I make a link such as discord.mydomain.com
And that would redirect to a discord server invite.
Bump
hello
Hey I am learning Django currently and wanted to turn the background color for my homepage blue and also render an image but am unable to do so. Any help would be appreciated.
have you put in settings correct static_dir?
Yup
r u using chrome?
Yup
Press Ctrl+F5 (If that doesn’t work, try Shift+F5 or Ctrl+Shift+R).
Okay let me try
btw look in dev tools, are static files are collecting successfully?
This worked
What was I doing wrong?
nothing, you have to refresh cache
Hi
I am also a web dev...
(Just started building some websites and hosted it on gitlab)
nice
Which is better Framework and will be more popular in next 5 years Django or FastAPI
FastAPI is growing in popularity fast but Django is likely going to be here forever


both are strong
Long shot - anyone here use JS & PYTHON to script/automate in Microsoft Excel?
i need to index all files in this url like search engines but how possible it is?
if i try bruteforce, there is need to try 37^29 possibilty
could some one help in #help-donut for an issue regarding to django would be greatly appreciated
yes
you can use almost ANY (from any language) backend framework with almost ANY frontend framework
as a rule they all follow generic www compatibility
I mean... almost any backend framework can be turned into REST API at least
Which will make it already compatible with frontend frameworks
Flask can do it in wheel reinventing way, or in Flask-restful library way
anything
I would recommend using React or Vue.js in general
at they are the most stable and library rich ones
I would recommend reading the book Head First Javascript
without basic of understanding of JS, it would be a bit not cool to go further
because in the end it is just Vanilla JS that does all of it
React/Vue.js are just wrappers to simplify the same process
Usually people use Axios library to make requests to backend
Up to you. Up to you. The book I recommended is definitely best grade material. You will have hard time to find equally good video materials
if there are two post requests going to the same route in flask, is there a way to differentiate between the two?
sure.
you are meeting them in backend, where you have full programming language python access
you can differentiate them based on ANY criteria you make
Hi, in Django when i give a field a class name i cant access it in CSS to style it why is that?
create_page_title = forms.CharField(label="", widget=forms.TextInput(
attrs={
'placeholder': 'Enter the title of the entry here...',
'class': 'title-create'
}
))
how can I make an app that open websites in it such as gmail, google,..
!docs webbrowser
Source code: Lib/webbrowser.py
The webbrowser module provides a high-level interface to allow displaying web-based documents to users. Under most circumstances, simply calling the open() function from this module will do the right thing.
Under Unix, graphical browsers are preferred under X11, but text-mode browsers will be used if graphical browsers are not available or an X11 display isn’t available. If text-mode browsers are used, the calling process will block until the user exits the browser.
ah thanks!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style2.css">
<script src="style.js"></script>
<script src="https://kit.fontawesome.com/19340be48e.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="wrapper">
<!--Top menu -->
<div class="sidebar">
<!--profile image & text-->
<div class="profile">
<img src="logo2.png" alt="profile_picture">
<h3>User Guide </h3>
<p>Business Owner</p>
</div>
<!--menu item-->
<ul>
<li>
<a href="#" >
<span class="icon"><i class="fa-solid fa-house"></i></span>
<span class="item">Home</span>
</a>
</li>
<li>
<a href="#">
<span class="icon"><i class="fa-solid fa-download"></i></i></span>
<span class="item"> Application programs</span>
</a>
</li>
<li>
<a href="#">
<span class="icon"><i class="fa-solid fa-network-wired"></i></span>
<span class="item">Computers and Networks</span>
</a>
</li>
<li>
<a href="#">
<span class="icon"><i class="fa-solid fa-print"></i></span>
<span class="item">Devices and Network</span>
</a>
</li>
<li>
<a href="#">
<span class="icon"><i class="fas fa-database"></i></span>
<span class="item">Data Traffic</span>
</a>
</li>
<li>
<a href="#">
<span class="icon"><i class="fa-solid fa-globe"></i></span>
<span class="item">The Suitabe Network</span>
</a>
</li>
<li>
<a href="#">
<span class="icon"><i class="fa-brands fa-windows"></i></span>
<span class="item">The Suitable Computer System </span>
</a>
</li>
<li>
<a href="#">
<span class="icon"><i class="fa-solid fa-address-book"></i></span>
<span class="item">Contact us </span>
</a>
</li>
</ul>
<div class="section">
<div class="top_navbar">
<div class="hamburger">
<a href="#">
<i class="fas fa-bars"></i>
</a>
</div>
</div>
</div>
</body>
</html>
How to create a default disabled option in django dropdown list?
I have done this
category = forms.CharField(label="", widget=forms.Select(choices=categories))
I'm trying to deploy a small Flask REST-API on a Digital Ocean cloud. To make it simple I've dumbed it down to this, but I can't access this either. When I access the server_ip_address:8081/hello/ I just get network timeout. I have open the port on the ubuntu firewall. Any hint what I might be doing wrong?
from flask import Flask, request
from flask_restful import Resource, Api, reqparse
api_config = {
"host": "server_ip_address",
"port": 8081,
"debug": True}
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def get(self):
return "success", 200
if __name__ == '__main__':
api.add_resource(HelloWorld, '/hello/')
app.run(**api_config)
try localhost, port 8080
I can't because there are other things running on the server and so 8080 is already in use.
go port 8000
also, I have never seem Flask with classes. is this some sort of like MVC-like method?
(i know its not exactly MVC but it reminds me of it)
Idk. what MVC means
This is from flask-restful which is a library for REST APIs.
I found it really helpful.
yeah I know flask_restful. i have used it before
you ever just try and make something with javascript and it just doesnt work but if you did it in python it would
I tried. Also allowed the port in ufw but still time out.
also, MVC (model view controller) is a design pattern for making APIs
his port 8080 is occupied :p
ohh
all my other ports i can think of are occupied
of just random css tests because i never turn off live servers
it might be the host. I'm not sure if "server_ip_address" is a host. I have never seen it before, correct me if it is
also flask_graphql when
ive just been using 0.0.0.0 wiht no problems whilst using flask
oh ok\
Ohh sorry I should have said. I've written the actual IP of the server there.
I've just always used localhost, so I'm kinda oblivious to other hosts
just use 0.0.0.0, easier to share code, aswell as you dont leak ur ip! : )
and easier to manage
I think he is deploying
ohhhh
yeah then dont do htat
unless u want to debug
I want start do my own website:
Is there a equivalent to a IDE for web design where I can directly see what my website looks like with this html file I have right now?
Well.. for real-time view u can use LIVESERVER extension present I VSC
Like... it reloads the page automatically everytime when u make any sorta change in the html file
Im till not sure if you're looking for this.. but give it a shot
what would be the opposite to real-time in this regard?
💀
Delayed or postponed ig
I googled this lmfao
i mean more like in the sense of why would i want it not real-time? avantage-wise?
Django question in #help-croissant
I think I've fallen in love with vue's <script setup> sfc tag.
🗿
#help-corn someone help
Hi! I've setup a Flask server following the tutorial on the docs. I have a problem when running the server with flask run during development. It takes about 2 mins for the first request to get through to the server being logged, the browser I'm using is the latest chrome version. It's only the first request, the following requests aren't having this problem. Has anyone else experienced this issue aswell? Running everything on a Macbook pro M1 PRO Max.
How could i make a custom ratelimiting system for flask where i can make api keys that get limited instead of the ip that gets limited
can someone help? After I follow this documentation https://edx.readthedocs.io/projects/open-edx-devstack/en/latest/pycharm_integration.html#setup-a-remote-interpreter I'm having this error
yea the composition api and script setup is aweeesome
Hello, can anyone tell me why my templates render differ from browser to browser (police color for example)!
What templating engine do you use?
Also, when it comes to css, some browsers render things differently from others
And some browsers need a different css code for the same function
In a HTML file I want to divide the page into a grid, and each grid thing changes colour every second. Each grid being a different colour
Have someone seen this error before? I have django-stubs but doesn't work 😦
Sorry my discord crashed and was unable to find your message again 😅
To me this looks like it's just type hints of your editor that cause an issue here. If you execute your code it should work without a problem. Is that the case?
So the Django static urlpatterns seem to be using the type hint
typing.List[URLPattern]
To avoid the issue, you could do the same by annotating your list:
from typing import List
...
urlpatterns: List[URLPattern] = [
...
]
Discord glitch OP
My goal is to make a photo gallery (for offline personal use currently) where I can sort the pictures by tags I assign to them. How would I get started making such a website? (And I am trying to avoid using services like SquareSpace etc.)
is django rest framework part of django or is it third party ?
@native tide DRF is done by Encode OSS Ltd, Django is done by Django Software Foundation
not sure whether they overlap
question: are rabbitmq, redis, celery, kafka interchangeable? do they serve the same purpose?
I try to register 2 filters in the same file
but it only registers the first one
anybody knows why?
nvm i found out why
you load the file name not the function
i have started web dev
and i have just learned html and css
what to do now
i mean
i will start learning js as well
but how do i use python in building web apps
any idea?
It’s mainly used on the backend
Flask and Django can serve static files though
And you can use frontend JS framework with them
Does anyone know where I can get a free .com domain.
Other than freenom?
don’t know what that is
i got a free domain with an ssl
.com no.
thats basically impossible
@native tide I've heard that after you give heroku your card data, they give you some benefits regarding customizing your domain, not sure if they do offer what you want tho
nah they don’t
Gay
You still have to buy Dynos to get the custom domain and such
I see, thanks
could you share some details?
What card data
replit has free hosting (for websites it isnt even bad) and cloudflare for the replit given cname and the nameservers you get from the provider
and cloudflare u can have it online 24/7 with its rules
moai said they don't give the benefits you are asking for, so nevermind (I meant verifying your payment card)
thanks
hello
i try to use by window command with "python manage.py runserver" and error is "unreoconized command" Can someone help?
if linux then you might have to write "python3" instead of "python"
ahh ok 😄
no problem, good luck
i try to add code to urls python.pyc to add new page in ly web site but now nothing work anymore
in pycache
i don t know why
Does anyone know how I can remove these messages from my sign up form in Django?
I only use UserCreationForm() for the userform
Hey any one can suggest a simple web project using django
whats the docs for flask? and is their a tutorial i can follow on it maybe Corey Schafer has one not sure.
yo
In a vue setup sfc, is it possible to get $router or $el?
I am trying to grab a users cookie 'id' so I can manipulate it from a separate page. Looking for how to grab their session ID
After googling, $el is replaced by named ref()s. $router and $route can be accessed with useRoute() and useRouter()
What do you mean connect? Is it living on a web server, or a file?
I wanna merge python with HTML
Thank you mate, it is still not working I am going to rebuild de venv and reinstall pkgs to see what happens
You want to use python to write html?
or you want to use python in a html <script lang="python"> tag?
No , I have written html code , and now i wanna use if statments in HTML using Python
like if... <p>lorem...</p>
or if password == repassword
write logged in successfully on the screen using html
Hello is there a down side to using Profile._meta.get_fields()
I'm building my own serializer since the one in django is pretty much slow
Something like JSX but for Python?
Jinja is a templating engine where you can embed Python in the HTML
It is used by Django and Flask iirc
!pip jinja2
You'll probably want to look into flask and jinja like moai said. This way, you are not dealing with passwords on the HTML form, but it is securely send to the flask backend and processed there, then you can pass variables into the html template and much more stephenson
though jinja doesn't make your page dynamic if that's what you're after. To change the page, you need to run it again.
And there is no such thing as pyx (jsx)
yeah
that would be cool
Maybe I should make pyx👀
is Jinja a web framework like django and flask or what
Templating engine
can u explain more
<html>
<body>
{% if name %}
<p>Hello, {{ name }}!</p>
{% else %}
<p>Please provide a name.</p>
{% endif %}
</body>
</html>
Jinja is a fast, expressive, extensible templating engine. Special placeholders in the template allow writing code similar to Python syntax. Then the template is passed data to render the final document.
It takes the string and renders it acoording to the content in {% %} and {{ }}
Is this jinja
{% %} is control flow
{{ }} is print
Yes.
note that you can't import things. You have access to whatever context you gave the template engine.
is it able to use jinja only , like without a library like flask
Yes, but you would need to configure it. You can't just run it from the command line
^
okay thanks for helping
hii, how do I add word-wrap property to
<p class="card-text" style="width:400px; word-wrap: break-word;">{{ dd.headers}}</p>
this is not working..
isn't word-wrap the default?
not working by default
maybe. Try div
still not working
¯_(ツ)_/¯
for js
if i have a number in seconds
how would i calculate the days, hours, minutes, seconds since that number
Hi everyone. Does anyone know how this sight is accessing the match data that fills there website? They are not officially apart of pokemon unite and I can't find a public API being offered by the game so I am curious how they are doing it.
Anyone here running dev projects on Apple m1?
Is it a date object?
no
Well that would probably be a good first step
Im trying to store input signup data so they can log back in... Where do i store it?
And how
Database
TypeError at /
'bool' object is not callable
Request Method:GETRequest URL:http://127.0.0.1:8000/Django Version:3.0.3Exception Type:TypeErrorException Value:
'bool' object is not callable
Exception Location:/Users/incognito/Documents/incog/incpay/incpay/views.py in get, line 15Python Executable:/opt/miniconda3/envs/myEnv/bin/python3Python Version:3.8.5Python Path:
['/Users/incognito/Documents/incog/incpay',
'/opt/miniconda3/envs/myEnv/lib/python38.zip',
'/opt/miniconda3/envs/myEnv/lib/python3.8',
'/opt/miniconda3/envs/myEnv/lib/python3.8/lib-dynload',
'/opt/miniconda3/envs/myEnv/lib/python3.8/site-packages']```
someone said the solution to this would be to ``Try to reload your server through comment on the get method.
`` but i don't understand
Hey I am using django and having some issues with web deployment. I am using heroku to deploy my website and it works fine, but when I change the domain name, I am getting some errors
These are the errors I am getting on the new domain
I'm unable to build my pelican blog because of this issue, which i imagine affects a lot of Flask projects as well. https://github.com/holoviz/panel/issues/3257
Does anyone have an idea what a temporary work around might be until they fix it? It basically just needs to have an import line changed in the pelican package but... that doesnt help me until they add it.
one guy said this "Same error on an internal project : current workaround was to explicitely pin the Jinja2 requirements"
what does he mean by that. jinja2 is in my requirements.txt file.
i figured it out.. explicitly revert back to 3.0.x is what he meant
is anyone here who has worked with django 4 ?
needed some help
I have set up Digital Ocean Spaces using a FileUpload field.
How do you upload other files outside of using the upload field like creating a PDF in a Post_Save Signal and uploading that to Digital Ocean?
This is using Django 4
what's the problem ? , I tried twice but nothing have changed
I created a "HTML" template, and I rendered it using flask but they tell me templateNotFound , I go back to ensure if there is something wrong on my code , but the entire code is correct
I have not even made a mistake on the path of the template
how can i host a django app without downtime for free?????
hello everyone, im a beginner programmer. i want to ask something about django. why request.POST.get always return None?
do u have any forms on the page?
if yes, do they get submitted?
yes, and yes. i submited string in the form
this is my views.py file
and this is my html file
bruh
whats better (Pagination & Requests):
1-Pagination on backend. Frontend requests everytime the page changes.
2-Pagination on frontend. Backend sends all data when requested then frontend handles the paginiation and caching etc...
I would say it really depends on the amount of data, and if users are likely to look at all the pages
oh it solved. so in my form, i send POST request to index page. but, instead getting post request value inside views.index func, i get the value of post request inside of views.addtask func. lol
lets say 10,000+ objects vs 100- objects?
for 10k I would definitely do pagination on the backend, users most likely wont look at all those objects, for 100 you should be fine just sending all the data
okay. Thanks!
for django, instead of the following
>>> # This will run on the 'default' database.
>>> Author.objects.all()
>>> # So will this.
>>> Author.objects.using('default').all()
>>> # This will run on the 'other' database.
>>> Author.objects.using('other').all()
could i specify in the Author model that i always want to use a specific database like 'other' for that model? or do i always need to call .using for selecting the non-default database?
hi i am writing a website but i got stuck in this fucking traceback
solved by my hero on stackoverflow https://stackoverflow.com/questions/3519143/django-how-to-specify-a-database-for-a-model
like adding via django admin panel?
Can anyone help? Want to change a persons session from another page
I have an opencv file i want the data that im getting from that file in my django project which will be saved in my database
The open cv file basically detects faces and appends the name in a list i want that name in my django project
u can add the file in the static folder, and then in ur views.py u can import it via the path
Anyone done any FileUploads with Digital Ocean Spaces?
ok ill try this
if u get stuck anywhere, feel free to ask me
ok sure thanks a lot
Can you pass a file to a filefield without it saving locally?
How are you getting the original file (file upload, creating through code, some other app) ?
Using WeasyPrint im creating a PDF in the post_save signal
then trying to pass it to a document model
OK so you're creating it and you don't want to save it locally first just to send it over to Digital Ocean spaces.
which then uploads to Digital Ocean Spaces
I have an application where I am downloading videos using yt-dlp and I can't escape creating the file (or I haven't looked hard enough). I'm storing it in a TemporaryDirectory but you can use TemporaryFile. Before you go that route, have you looked at django-storages?
im using storages yes with S3Boto
So far i only know if i use a FileField it uploads to DO, but not sure how to do it in code
html_template = get_template('claim_form.html').render(context)
pdf_file = HTML(string=html_template).write_pdf('test.pdf', stylesheets=[CSS(settings.STATICFILES_DIRS[0] + "/forms/style.css")]) #
document = Document.objects.create(claim = sub_claim, document=pdf_file)
OK so check this
import os
from django.core.files.storage import default_storage
def save_to_s3(file_input, directory_name):
with open(file_input, 'rb') as f:
file_output =
os.path.join(f'audio/{directory_name}', file_entry)
file_output_actual =
default_storage.save(file_output, content=f)
Now this is me hacking up my existing code to break out the gist of it.
Yeh you ur using with open to read the file
So if you are able to save the file local using TemporaryFile, then read that in and write to the default_storage.save, you should be home free.
what is TemporyFile a library?
at the top, tempfile.TemporaryFile. On my system it saves it as /tmp/tmpxxxwhatever I think
so regardless it has to exist in the working dir before being shifted to S3
Now if you can get the PDF file as a byte array, you should be able to skip that step.
for my use case, yes. But as long as you can get the file content in that f var using another mechanism, you should be good.
I'm not familiar with your PDF library.
Can always clear out the tmp file once the process is done
I have a document model that has a filefield, ideally i could create that document and pass the pdf to the filefield and that would be it
I developer
I can make my Web brauser
Its Python server
I love Python
Kto ne verit tomy v glaz
Ok
We only allow English in this server.
(( sorry
@native tide @native tide please review our #rules so that we don't have to take further actions.
!ot
Off-topic channel: #ot2-the-original-pubsta
Please read our off-topic etiquette before participating in conversations.
I got distracted. Let me know if you need anything else.
can someone help me refactor those 2 functions?
Both of them have 4 similar lines of code
so I want to use the 2nd function in the first function bcuz DRY
but I don't know how to deal with the return statements of the second function
any help would be appreciated
@pallid tulip whats wrong with the return of the second function?
see, 2nd function returns either the icon (an emoji)
or the full tree name
in the 1st function (where I want to replace the try/except part with the 2nd function):
i'm either getting the icon, or the first function will be returning the full tree name
lines 69 and 70 are the ones causing me the problem
let's say input of the first function has a tree.fruit_name that isn't in TREE_NAME_ICONS dictionary
how am I going to make the 2nd function deal with the return clause
(please mention me if you have an answer)
Hello
I have an app with jwt access how to give a temporary access to a a temporary user with email for only one route (read only access)
Hi there 👋
I'm trying to use Google OAuth with my back-end (Django and DRF) so users can signup/login using google, first I read the official docs for it
https://developers.google.com/identity/protocols/oauth2
and tried to use google-api-python-client
https://github.com/googleapis/google-api-python-client/blob/main/docs/oauth.md
but I can't understand the docs Although it's the official 3rd party that google provides with Python, I did not find any tutorial about how can I use it with the rest API in Django.
I checked out django-allauth but it's not for rest API, so what should I do in this case? if there are good tutorial guides me on how to accomplish this task, please let me know!
I’m going to make a e-commerce website for a small business and was wondering how much should I charge them for it and or if I should do a revenue share instead ?
There is no one fits all. It completely depends on the requirements of the project and what experience or skills you bring to the table.
Also add some buffer on top to your estimate to cover any issues that could arise.
!e py my_list = [1, 2, 3, 4, 5, 6] print(my_list[:5])
@ivory kiln :white_check_mark: Your eval job has completed with return code 0.
[1, 2, 3, 4, 5]
I think this should work for JS too. Tried it yet?
ah cheers
yeah i tried it
it worked when i did hourData.length - 1
Ah, I'm wrong. The -1 doesn't work in JS, my bad!
np :)
er
i have a list like
[1, 2, 3, 4, 5]
but its in a string
string.replace("[", "").replace("]", "").split(',').map(Number); is there an easier way to do this
Is this reasonable to set up for mid size flask apps? https://www.digitalocean.com/community/tutorials/how-to-structure-large-flask-applications
Seems a little bit overboard, so much so it's hard to even understand where stuff goes.. Anyone have any sources on how to structure mid size flask apps?
what does Cannot read properties of undefined (reading 'pingDifference') mean?
const pingDifference = Math.round((ping / Number(hourData[hourData.length - 2].split(" | ")[0]) * 100)) / 100; ignore the shambolic code
im passing this into a dict into a rendered ejs file
means that the value is undefined
either you're asking to use it somewhere before it's ready, or it's not computing correctly.
If you log it, does it show the value eventually?
er turns out i may have accidentally used the wrong dict path
Hello, I have multiple questions about RDS AWS Database (Free Tier):
1-What is the data limit
2-Is there a visual interface that allows me to see its data
3-If the data limit is exceeded/full does it change the plan automatically?
i am only 14 but i love 
Does anyone know of an easy way to add search to a flask-wtform selectfield?
How can I debug where and why I got this 405 in my endpoint?
It is inconsistent sometimes it will 405 sometimes it will not
And the built in debugger isn’t giving me any useful errors
hey i need help with flask and stuff
i want to make a folder called Website into a package but its not working, yes i have a __int__.py in there but its still not working, can someone help me plz? and plz ping me when you answer
sorry but its only a typo in here
ok
it is init in my file i just missed the i in my text here
what file are you importing and where are you importing from? Can i see your file structure
okok
@unique shore the main.py is outside of the Website folder btw
there is nothing in the statics folder either
not sure if templates is supposed to have Python files
That’s where your html files go
well thats what the tutorial said
Send the tutorial I wanna see it
are links even allowed here?
In this video, I'm going to be showing you how to make a website with Python, covering Flask, authentication, databases, and more. The goal of this video is to give you what you need to make a finished product that you can tweak, and turn into anything you like. We're going to also go over how you create a new user's account, how you store those...
this is the one im watching
@unique shore also moai do i need HTML if im using flask even?
cuz i thought its all in python
A webpage’s structure is made in HTML not Python
ik but im saying do i need HTML skills too?
You can use a Templating engine to extend HTML with some Python syntax
yes
if you are doing web development, specifically frontend, you need HTML, css and JS skills
then...what is flask for?
server side development
backend
But it can serve static files
@unique shoreare you familiar with flask?
templates dir is supposed to house the html static files
i think i have officially lost all my braincells at this point
if you have the time, check this video some time - it can help put everything in context https://youtu.be/EqzUcMzfV1w
This is my annual guide to take you from start to finish when it comes to the web development technologies that are available for frontend, backend, and full-stack developers.
👇 Content Guide:
https://traversymedia.com/guide
👇 Website & Courses:
https://traversymedia.com
💖 Show Support
Patreon: https://www.patreon.com/traversymedia
PayPa...
i know it helped me
when i first started trying to comprehend web dev
okok thanks needed it
yeah he walks through okay what is frontend vs. backend vs. fullstack
big thanks to you two
what technology is what
ik those
yeah but he just helps you understand and categorize all the buzzwords/tech stack you might come across

noted
helped me also

Anyone here in a javascript or totally web development dedicated server
any trick to edit HTML files with live preview in Brave?
I need help, this is a issue with Digital Ocean when trying to deploy my app. How do I get ssh access to the web server, instead of using it through the console?
Following their docs is a great start.
From google: https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/
I figured it out, but thank you so much for the initiative to guide me 💀💞
np
I can buy you nitro classic if you like, since you decided to help me out 🙏😁
lol no that's fine.
I don't do it for the gains.
Thanks though
Alright thanks again 🙏😁💞
Hi all, I'm just looking at a website I made last year. I have five links in my navbar. Four of them hide the link so that the text is white, whereas the 'bcTech' link underlines and goes purple. Any idea how to turn this off?
Nevermind, got it 🙂
.logo a{
text-decoration: none;
color: white;
}
is it worth learning django or flask if I am not going to use js?
at some point u need to use js in ur web dev journey
Good companies use flask / django / FastAPI only as REST APIs, no JS, just json data
knowing JS for backend person is nice to have at least as basics, but not really obligatory
one book like head first Javascript should be basically already enough for the backend guy to fill the JS quota up to Middle rank
im solo
My company use Python and Django only for make backend services. The consumers of that API's are JS programs
(frontends)
Good day everyone, I'm new to django and would really appreciate if I could find like a practice mentor or something
hello anyone can give me some idea? I am writting Jquery in flask. Trying to store it as external JS scripts. But it seems when I have <script type="text/javascript" src="{{url_for('static',filename='outcontrol.js')}}"></script> code in HTML (a render template page). It treat outcontrol as a static file, and it won't able to execute $("#b01").click(function() { htmlobj = $.ajax({ url: "{{url_for('out')}}", type: "GET", the url part. But if I put it as a script in HTML template directly it works fine. Does this mean flask does not support Jquery written in a seperate file?
Hi! I'm trying to build a Twitter Scrapper, but I can't manage to do it
my knowledge on python is 4/10, and I've tried tutorials
but I get errors like this
Can somebody help me, please? Or send me a good tutorial or course
This is my code:
Hey @native tide!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Can someone recommend an django tutorial? Everything i can find (text / video) are outdated or behind a paywall... 🤔
does anyone have any experiences with anvil? would love to hear experiences with it?
Hello. This is probably a FAQ but I can't seem to find the answer anywhere so please do help.
What i'm trying to do is when the "Add" button is called, i want to query the database and change the value of the "Stock" field. How will i go about doing this without having to reload the page?
can i turn a flask with html web app into a desktop app?
When I first setup my website I registered on some sites like google console and all to get better listing now am setting up another site anyone knows where all I need to register to get good listing...?
I'm currently checking out 'techwithtim' so you could try it out
Also I need a practice buddy if you're interested
You need to use javascript. You could use javascript to send a request to a flask/django page that will query or update the DB then return the new stock value, and when it is returned the javascript updates it
you can use this
https://pywebview.flowrl.com/
not sure ok,.. like.. i've used it a lil bit.. but not with flask.., so try it out & see if it works for u :)
Build GUI for your Python program with JavaScript, HTML, and CSS
you can check out this if you want https://youtu.be/jBzwzrDvZ18?t=13108 like it's beginner friendly (imo) ||for the first 3 hour & 30 minutes they're just teaching 'basic' stuffs so you can skip the basic stuff if u want||
This video is a full backend web development course with python. In the course, you will learn everything you need to know to start your web development journey with Python and Django.
✏️ Course developed by CodeWithTomi. Check out his channel: https://www.youtube.com/c/CodeWithTomi
🔗 Join CodeWithTomi's Discord Server: https://discord.gg/cjqNB...
Got it! I was trying to figure out a way to not use js but i guess it is the only way. Thank you for the help!
thankss
:>
DW is this why backend pays more than frontend 
has anyone of you lately tried deploying Django on Heroku? It's throwing me a "Django heroku push gives could not build wheels for backports.zoneinfo error". I searched on the Internet but didn't find any answers.
What is the best programming language for web dev/web hacking ?
Do you want to do frontend or backend dev?
Frontend dev essentially requires JavaScript
What's the difference ?
Frontend has to do with the UI and how the site looks
Backend is the logic behind it and how it works
frontend then
Learn JavaScript
Ok super thanks !!!
But languages that can compile to webassembly like rust can also do frontend
I would recommend switching to typescript after becoming proficient in JS
Typescript is JavaScript with a type system
So all valid JavaScript is valid typescript
Typescript makes more correct code and is type safe
Can anyone explain to me, in simpler terms, what an AbortController is and how to use it?
Can someone recommend a good flask open source project that I can learn from? (GitHub)
uhh if I want to have something like an admin panel for fastapi model how would I do that?
I want something like django panel
I google the keyword and find Piccolo Admin, maybe it could help?
How do I get global ports into a python socket? To be able to connect from another computer
javascript
Could you elaborate just a bit more? Does this mean i'll have to query the database through javascript rather than via django itself?
How to add data to ManyToMany Field in Django using a .csv file?
the csv column has values separated by commas
hey, so if i have a wall of text on html in a tag, and i want to make it so that if i hover over a certain word in the wall of text, it should change color, but not the whole text... how do i do that?
u could try to add that certain add inside another tag, and can add the css to it
no like
i have
<h4> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </h4>
If i were to hover over, say lorem, i want only lorem to change color, not the whole text
<h4 style="display:inline"> <span id="hover">Lorem <span> ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </h4>
add css to the span tag with id='hover'
and if i wanted that to be done for every word? i'd have to use a new tag for each word?
there's no single attribute i could use?
I mean that's enough to know only basics. Deep understanding of the language requires entirely different effort. and code quality technics take the 90% of the effort
since backend person already usually knows code quality technics of the other language
learning just JS syntax is usually enough to handle most of his tasks, or at least having understanding in what he wishes to achieve, even if he does not use JS / and its client side browser interaction
what you want to learn
And btw, 50% of backend is made in Javascript ;b
it can be as backend language choice as well as any other one
quite a lof of backend positions in js. Just for the amount of job positions... quite tempting to choose learning js
node.js and others right?
i mean you dont have to convince me. im already learning js for frontend 
but career-wise, i probably will either go DS or backend route
Hi everyone! Let me just say that Python for me is a very awesome programming language to do web development.
Yeah, node.js which runs stuff like express
Hello everyone
Does anybody can use selenium to login to google mail
Google mail detect my selenium and ban it for sign in 😿 , i have search in stackoverflow/github but it no use
Does anyone have any idea
Hi everybody, I'm not used to implement Flask application
But I have a goal for a customer, he has a web server on DigitalOcean configured with ServerPilot, with some web PHP classic apps
No he has a Flask project, and he wants it on the same server, what the best way to do that please ? I'm very blocked, and I don't understand all step I do sometimes...
I tried to search on Google, but nothing with ServerPilot + Flask, and the separated documentation is not easy to implement.
If someone already did something similar, or exactly similar, or just a big knowledge and can help to achieve this.
I use Gunicorn to bind the app on the 5000 port, and try to listen to it with a .htaccess:
https://serverpilot.io/docs/how-to-run-apps-in-any-language/ (modifié)
Same like u add data on CSV by importing CSV adding it (like u do in py same) ,just pass the into a dict while rendering return value
Django Question, Can i use redirect(request,'other-view') inside APIView?
You can run both servers behind revese proxy (like nginx) that would determine which app send request to based on various factors
Such as request host, for example domain.com or another-domain.com
I'm not sure if you can run gunicorn behind something like apache 🤔
But you probably can
I saw some documentation on flask and other website to run flask app on apache but I think it's with WSGI or something like that, but I'm not sysadmin and I'm not very confortable with this stack (flask, etc...) So I don't understand everything ahah.
What did you say make sens, I will try to work with that during the weekend, I hope to find a solution. If anyone has skills on it, and want make a call to help me, it's appreciate ahah.
hi, anyone know how it would be possible to make a page that sends push notifications to specific users, and they don't need to be on the website to receive it?
So on what kind of platform(s)/channel(s) are they receiving the notifications on?
sorry for the late reply, on a webserver on Flask
I meant how are the users going to be notified if they aren't on the site? Like by email, text?
more like you know how when you need to allow a site to notify to redirect you to the actual site? and then you suddenly have notifications even when you're not on their site lmao?, well like that, but with a better intention
Please someone answer
I don't get why discord does POST/channels/{channnel_id}/messages instead of just sending a websocket event back
can anyone think of any reasons they might do this?
does it like save bandwidth or smth
Can anyone tell me if there's an easy way (using flask) to automatically scale text font to fit within a parent element (like a div)? The text is variable length and I need it to fit within a fixed area on the screen without cutting off. I see some javascript libraries that do similar things
Rethink your choices.
Try to use direct POP3, IMAP email protocols for connection.
And if u wish working without limits, get yourself stuff like Sendgrid
Hey all,
wondering if yous might be able to help me.
Got a simple aspnet core app that works fine on my local windows environment, cant get it to work properly on a linux server.
It's a matchmaking http thingy for Among Us. Very simple stuff (I'm not a web developer, help!)
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:56630",
"sslPort": 44385
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"AmongUsMatchmaker": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": false,
"applicationUrl": "https://localhost:443;http://localhost:442",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
This is my launch settings.json file
GNU nano 4.8 /etc/nginx/sites-available/default server {
listen 80;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
This is my nginx config on the linux server.
What am I doing wrong?**
Anyone done much with the tempfile module? I can't seem to get it to work... I get a module 'tempfile' has no attribute 'TemporaryDirectory'
ERRORS:
?: (djstripe.E002) DJSTRIPE_FOREIGN_KEY_TO_FIELD is not set.
HINT: Set DJSTRIPE_FOREIGN_KEY_TO_FIELD to "id" if this is a new installation, otherwise set it to "djstripe_id".
n when i remove null n blank field from stripe_subscription column it shows
ERRORS:
?: (djstripe.E002) DJSTRIPE_FOREIGN_KEY_TO_FIELD is not set.
HINT: Set DJSTRIPE_FOREIGN_KEY_TO_FIELD to "id" if this is a new installation, otherwise set it to "djstripe_id".
index.MyStripeModel.stripe_subscription: (fields.E320) Field specifies on_delete=SET_NULL, but cannot be null.
HINT: Set null=True argument on the field, or change the on_delete rule.
Hi guys
new to web dev
I just have a quick question
I just installed LAMP stack in my ubuntu OS VM
I used php to write the whole back end
However, is it possible to write my request script in a separate file ?
I used a python script to retrueeve the apache default page
and used a socket to sent and http request as well as an ssl but iim not sure how to conmnect them to my main PHP script
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("vulnerable", 80))
s.send("GET / HTTP/1.0\r\n\r\n")
while True:
response = s.recv(1024)
if response == "":
break
print response
s.close()
So im using Digital Ocean Spaces, when I upload a document it created the entire path of files instead of just the file inside 1 folder, if that makes sense.
Anyone know how to move H1 to middle of page?
use flexbox
Hello gentlemen! I'm lookig for full stack dev who could explain how to make API for python program. I couldn't find a good example and the concept is unclear. Thank you in advance!
im trying to make a migration remove the occupiers field of my clique model but when i try to migrate i keep getting ValueError: Field 'occupiers' expected a number but got ''.
#A clique can have many users.
#A clique can have many posts.
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=1)
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 ````
Idk much but if u asking about
html then its <center>
i guess sorry if im wrong just started learning html but couldn't resist helping
Hello
How can I implement real-time voice call app with django framework without WebRTC and P2P(stream data must pass through the server)? (I've seen django channels but it supports UDP protocol in version 1.0 and I use version 3)
There are no shortage of tutorials all over the web, here's an example: https://www.educative.io/blog/python-fastapi-tutorial
Those I watched before(I watched and read a lot) did not give me a clear answer of how exactly it works)
@inland oak Hey any idea how I might have applied set_password to all the user accounts in my database? I was creating a custom password reset flow and I realized somehow during the process it changed the password of every user in the database. Without some kind of for loop, any idea how that might have happened?
- Typical situation to write unit test to check/verify your domain logic
- during database migrations, default same value can be applied to every user possessing new field
(Same happens if u use some randomizer in field default. Migrations are recorded for static values)
I realized that it's a problem with JWT. I'll explain later. 🤦♂️
Well. Unit tests are made for this
https://youtu.be/qeMFqkcPYcg
Eurythmics - Sweet Dreams (Are Made Of This) (Official Video)
Stream Eurythmics here: https://eurythmics.lnk.to/Playlists
Subscribe to Eurythmics' YouTube Channel: https://eurythmics.lnk.to/YouTube
Follow Eurythmics:
Official website - https://www.eurythmics.com/
Facebook - https://www.facebook.com/eurythmics/
Twitter - https://twitter.com/eur...
I'm a beginner to webdev and I'm learning it for a project. Im thinking of using django because Ive worked with it before. I know there are two approaches to doing this:
- Using templates to render
- Using a js based frontend and REST api
Which of the following would you recommend. Ive already worked a little with the first one so Id like to hear more about the 2nd. Will there be any difficulties if Im hosting because I need 2 ports. Noticeable performance issues with cheaper servers, etc. And also which one is more commonplace in medium sized projects.
just use the text align option. Define the <h1> and under it, keep text align as center
I want to start web so suggest me to how to start plzz
Learn html?
Hmm can you explain more in dm? I'm new at html
any good free hosts for FastAPI webservers?
I'd suggest taking some free online course of html. There are plenty on the internet.
I am using Django and I was wondering what the best way is to remove the username field from everywhere and replace it with an email, and add a full name and a phone number field as well
currently watching this video https://www.youtube.com/watch?v=SbU2wdPIcaY
In this video, I'm gonna be talking about making a custom user model in Django. We will show you email authentication as well as phone authentication in Django. We will first make a custom user model that inherits from abstract user (or abstractbaseuser) and add a new email field which is unique (or phone number field which is also unique). We w...
but it's about 2 years old
anyone know anything about phishing?
Dm me
i am trying to upload a file to an wordpress API and it works when i do it from reading an image file on my pc but fails when i try to get the image from another url
[03/Apr/2022 10:11:37] "GET /static/images/grid.png HTTP/1.1" 404 1804
[03/Apr/2022 10:11:52,685] - Broken pipe from ('127.0.0.1', 57003)
can someone help me?
Can someone explain how to use templates and models in Django? And why do i need them? Thank you in advance
I could use some help in trying to get a dictionary read by my template file in #help-chocolate
im having an problem with positioning div
~~<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="login.css">
<link rel="icon" type="image/x-icon" href="static/logo.png">
<title>Document</title>
</head>
<body>
<div id="parent">
<div id="alignment" >
<img src="static/instagram2.png" alt="">
<img src="static/instagram1.png" id="overlay" alt="">
</div>
<div id="login">
<h1>Instagram</h1>
</div>
</div>
</body>
</html>``
and this is css
~~body{
text-align: center;
}
#parent{
margin-top:32px;
}
#alignment{
display: inline-block;
}
#overlay{
position:relative;
right:175px;
top:25px;
}
#login{
height: 538.84px;
width:350px;
border:0.5px solid rgb(211, 211, 211);
display: inline-block;
}~~
why i cant place div with id login horizontally along with div with id alignment
How can I make the python server auto-restart?
what framework are you using for the server?
flask
you want it to auto restart when you make code changes during development?
no
i have an api hosted with that
so data comes from json
the data in json keeps updated. or somehow i do that.
so the data in api also needs to be updated right?
you want the server to restart when it receives a request?
no, i just want it keep restart. to update the data.
thats what i have understood
and if i do it mannually, it works too
i dont know if it can be done another way.
but if server restarts, it works. thats why i was asking how to do that. 😄
you probably have code that only runs at startup, and you want it to run on a regular interval, or when something happens
inside of flask you have have a couple ways to do this.
Set up an endpoint or function that runs the "update" code,
and then use an external service to hit that endpoint when you need to ( cron job, airflow, etc), or tie that function to one of your existing endpoints so they run in sync
Looking at your code, you don't need to do that though, what you want to do is wrap your file reading into a function
def read_nepse_data():
with open.....
return nepse
nepse = read_nepse_data()
and then inside your route functions, add a call,
nepse = read_nepse_data()
before your return calls
then you will read the latest version of that file each time before returning any data
you want to make nepse a local variable for each endpoint, you can then delete the global one
if you paste the actual code snippet here, I can show you exactly what I mean
I'm running into this weird problem with Django sessions and JWT. If I login to the admin panel, the auth is performed via session middleware. Unless I log out of the admin panel and clear my JWT cookies, I remain logged in as the user session and am treated that way vs the new token. Is there a way to prevent that?
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'graphql_jwt.backends.JSONWebTokenBackend',
)
Swapping them around doesn't seem to do anything. If I login to the site under a different non-admin username, my session takes precedence and I'm still the admin user on the site.
hello, how does one validate user inputs in django + store them in a db or something? I don't seem to find anything
lmao
Either through javascript or using forms.py to validate.
Django uses an ORM to store and modify data in the DB.
"If I login to the site under a different non-admin username, my session takes precedence" - have you considered adding a flush() to your login calls? That way your old session data would be removed on login https://stackoverflow.com/questions/16039399/how-to-clear-all-session-variables-without-getting-logged-out
I never even considered it. Are there any side effects vs. just clearing the sessionid since I don't use sessions anywhere else but the admin panel?
"Are there any side effects vs. just clearing the sessionid" - Maybe? Would be worth experimenting with. If clearing your sessionid on login works for you, maybe that is enough. If not, then you need to clear more
Hi guys, who work with emailhunter in django? please help me
I am trying to use tailwindcss with my Django project, but the CSS effects don't work. I have done everything correctly according the official documentation
You almost certainly have not done everything correctly if it is not working for you.
more specific details other than "it isn't working" would be helpful.
cheers mate
it doesn't work?
show code
With django, are you supposed to repeat column definitions in your custom register form like they are in your custom user model?
because that seems kind of weird
How should I import my utils package in the settings.py script? If I do import utils and run it from the IDE it works fine, but if I cd into web in console and do python manage.py runserver I'm getting ModuleNotFoundError
im trying to remove a field of my models and when i try to migrate the change i keep getting this error => ValueError: Field 'occupiers' expected a number but got ''.
#A clique can have many users.
#A clique can have many posts.
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.ManyToManyField(Occupier)
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 ````
Help would be greatly appreciated
if the utils folder has to be outside your project for some reason, then I would append that path to your python path
It's inside the project but outside of the web (django) part of the project because it has stuff that multiple parts of the project uses
Can you show an example?
something like
https://stackoverflow.com/a/28712742/4340591
Worked like a charm, thanks!
hello what is the best payment service for django?
Question should be which fits the best for what you need. Django is agnostic in regards to which system you use.
I often use Stripe if that's any help.
is there any bootstrap dev here?
hello guys ..
m not able to create superuser .. getting some Fatal error .. please help
I am trying to use tailwindcss with Django but it's not working.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Hello</title>
{% load static %}
<link href="{% static 'css/index.css' %}" rel="stylesheet" />
</head>
<body>
<h1 class="text-center">HI</h1>
</body>
</html>
tailwind config js
module.exports = {
content: ["templates/*.html"],
theme: {
extend: {},
},
plugins: [],
}
package.json
{
"dependencies": {
"autoprefixer": "^10.4.4",
"postcss-cli": "^9.1.0",
"tailwindcss": "^3.0.23"
},
"scripts": {
"build": "postcss css/tailwind.css -o ./static/css/index.css"
}
}
and I am getting "GET /static/css/index.css HTTP/1.1" 404 1798 on loading the page
how do I fix this?
I assume you've ran npm run build ?
yes
is index.css being generated correctly?
yes
what does your browser console log when you try load the page
(to be specific open the network tab in the dev tools)
I get this error
what is the url it's trying to fetch?
you mean this http://127.0.0.1:8000/welcome/?
I mean the url it's trying to request to get the css
and I assume if you go to that url directly it returns a 404
are you serving any othe static content from the static route?
yes
hi everyone!
i am building a website that makes it possible to download videos, but i have one problem.... i have to pass my HTML form value to my Python file.
I don't really know how to to that and i would appreciate it if someone could help.
Thanks a lot!
I have created html form with text box and button
enter ur search keyword
My requirement is to pass the text box value in to my test.py code, is there any way to do it.
Please suggest me how do it.
if that helps
i tried this one but i think i am just missing one important step or so
oh
my migrations wont apply because of this error => ValueError: Field 'occupiers' expected a number but got ''.
#A clique can have many users.
#A clique can have many posts.
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='')
created_at = models.DateTimeField(auto_now_add=True)
occupiers = models.IntegerField(default=2)
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 ````
this is what i get maybe you know how to fix it
Hello! Can i get some help with Flask method routings?
sure
The button i want to perform a function:
<div>
<input type="submit" value="Interpret Actions" name="interpretActionsBtn" class="btn btn-outline-primary" id="interpretActionsBtn">
</div>
my app.py is working and the page appears fine with all the css
how do i make this button do something?
i want it to run a script i wrote earlier
onclick I believe
you might have to write some JavaScript, but you should be able to do it in Python
you just call the function with the onclick button attribute
onclick=func() in the html
the method is in a different file
if i import it and call it will it work?
onclick="script.method()"
?
^ that too
<input type="submit" value="Go to my link location"
onclick="window.location='/my/link/location';" />
If you dont want javascript
well onclick should work. You might have to use JavaScript to create some middleman between the html and your Python though
If you want something triggered on your backend, then having a form is a good way to do it
it should call a script i already wrote in python, the page will stay the same
hmm
so i just put the button in an empty form and add the action?
The form is not empty, it has the button
<div>
<form action="interpretActions" method="get">
<input type="submit" value="Interpret Actions" name="interpretActionsBtn" class="btn btn-outline-primary" id="interpretActionsBtn">
</form>
</div>
now what do i do
do i make a route for it in app.py?
it worked lads
thx
hello everyone 🙂 noob here,
started learning javascript, and i have come across this feature you are able to define anonymous functions as a value to a key in a dictionary which was really exotic to me. is there a similar feature in python?
const jsDict = {
return_something: function(something) {
return something
},
fruit: "banana"
};
console.log(jsDict.return_something("hello"))
JavaScript is weird as fuck but you can
!e
def foo():
pass
d = {"func": foo}
print(d["func"])
@unique shore :white_check_mark: Your eval job has completed with return code 0.
<function foo at 0x7f7c82b3bd90>
!e
d = {"func": lambda x: x + x}
print(d["func"])
@unique shore :white_check_mark: Your eval job has completed with return code 0.
<function <lambda> at 0x7fa568833d90>
@ruby sorrel there is a lambda example which is pythons anonymous function
yes i have recently learned about lambda but i havent used it on my own yet but yeah that sounds right
ty
I have a row iterator ( <google.cloud.bigquery.table.RowIterator object>
Is it possible to show it in Flask ( django html ), every row as numbered?
- row0
- row1
- row2
Done 🙂
I needed to return the row iterator variable 🙂
Hi everyone can someone please tell me what i am doing wrong? I want to pass my HTML FORM value to my download.py.
I woul dappreciate it if someone could help!
This is not how it works
unless u use Brython 🤔
you can't execute python code in web form (only HTML basic things/actions and Javascript code can be executed there)
could someone help me in #help-burrito
u need to point to URL endpoint that contains python code
usually it can be done in a minimalistic way with web forms because
in GET method the page is rendered
and POST method web form invokes same page where it is
to call same URL but with values to put in
can i contact u in private? i would appreciate it
nah. I usually don't do DMs. It takes tooooo long.
alright can you like point out the things i have to change cuz i am new to the coding-space and i really need some explanation about what i am doing wrong
expose some backend endpoint with Flask / Django / FastAPI
at the address like / or /blabla
in your web form input this address <form action="/blabla"
press button in web form
accept request in backend / check it is POST type
do your thing, render answer in return
optionally render your web form from same url (/blabla) just from the GET type / if-flow check
thanks! i'll see what i can do 😎
Hi, I'm a beginner in backend development. I posted a problem on stackoverflow. Any help would be appreciated.
https://stackoverflow.com/questions/71741481/cannot-assign-str-must-be-a-user-instance
i'm using django rest framework btw. thank you 😁
it looks like you're trying to authenticate with a token. Do you have TokenAuthentication set?
Django, API, REST, Authentication
from django.contrib import admin
from django.urls import path, re_path
from core import views
urlpatterns = [
path('admin/', admin.site.urls),
re_path(r'^$',views.home,name='home'),
]```
is there something I can use here instead of re_path?
Yes, sir. I do have it in my settings.py
a question about HTML and how Xpaths work:
i have this relative-xpath: "//article//p" that returns all the text in the page, but includes one element wich is when the article was created,.
now i notice that the element (and only that) is located under the 'header' tag,
is there a way to exclude the 'header' tag from the Xpath ?
How do i save the jinja variables in python variables after form submit?
I think you can just do path('', views.home)
The token should be set with header Authorization: Token <token> not bearer
Django, API, REST, Authentication
The note states that you can change the keyword to something else, like bearer if you want. But you have to subclass the authorization class and set the keyword class variable
anyone know why my javascript wont link to my flask app?
<script src="app.js"></script>
<script src="jquery.js"></script>
@me if you answering i dont have notis on
This is how it works for me
<script src="{{ url_for('static', filename='js/select2.min.js') }}"></script>
i have the javascript in static/js
For Flask you must have a specific folder structure.
ye i did all that
i got it to work
but not that way
and i had to embed the css in the index.html for it to render that
inefficient but works for now ig
This is for my css
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/select2.min.css') }}" />```
app.py
templates/index.html
static/js/select2.min.js
static/css/select2.min.css
my folder structure
You are not allowed to use that command here. Please use the #bot-commands channel instead.
I need to find out some terms or vocab for what I am looking for:
A way to make sure images, when they fail to load, are properly replaced with something so they don't break the HTML
Like a placeholder, but not for lazy loaded images; for images that simply cannot load because the resource's URL changed.
But I can't find any information on this topic.
maybe "alt" text ?
yes use the alt attribute
That would still break the HTML because the element would resize.
I think I've found one part of the equation though: onerror attribute.
Either could be a URL or a function.
yeah that cloud also work. it also depends on how you build the HTML. for example if by default you display an loading image, and you change it when the actual image is available or something like that
I'm trying to keep my HTML & CSS as low complexity as possible, so if I can use built-in functionality, that's what I'm counting on.
Static site served by Jekyll on GitHub pages, you know
oh okay
Normally yeah, I'd go Vue and some lazy loading image extension with functions for automatic replacement with a suitably sizing placeholder image or some ballsy thing
then go for onerror
Hello guys, i'm new to web development, i just want to know how HTML & CSS Templates are sold in freelancing, as when i turn a Figma to HTML do i sell it as source code or in another way?
@wicked tide just in case you can write like this:
<!DOCTYPE html>
<html>
<body>
<img src="image.gif" id="_img" onerror="myFunction()">
<p>A function is triggered if an error occurs when loading the image. The function shows an alert box with a text.
In this example we refer to an image that does not exist, therefore the onerror event occurs.</p>
<script>
function myFunction() {
//replace the original image if it's not possible to load it
var d = document.getElementById('_img');
d.src = "https://images.takeshape.io/4d46e476-8704-42c4-8d0d-06ebdd0e3c93/dev/3a75df3f-7ad3-46c6-b792-1825239fbd44/nuxtjs-logo.svg"
}
</script>
</body>
</html>
it'a sold as Source Code, check site like https://themeforest.net/category/site-templates
Is it not possible to refer to the element as like this or something
I'm not a big JS writer so function environments and contexts are not something I am familiar with
I know they are weird.
Would be better to at least pass the ID in the function call, encapsulate it
Definitely !! it will be more concise
@obtuse mantle only bubble developer i know has a wand a bottle soap.
no really I think it is the type of developer
@obtuse mantle it was a dumb joke. I don't know anything about developing code
It could be possible that you don't know it but it's exist
yep. and WOOSH right over.... Crickets chirp (nobody laughed) that's usually the response i get when i make a joke.
It looks like CMS WordPress like developer
https://bubble.io/
Yet another no code solution
oohh that it is
Bubble is a no-code development platform, I used it a bit.
Hello
is there a way to make it so that when a user reloads a endpoint it returns a new random image
i'm using FastAPI
i'm trying to learn how APIs work and trying to make a basic random image API
currently stuck on how to make it random on each reload of the user
nevermind
@true warren
that should be pretty simple
you will first need to get the image
either from url or disk your choice
so if you have a url you do something like this
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
app = FastAPI()
templates = Jinja2Templates(directory="templates")
@app.get("/", response_class=HTMLResponse)
async def read_item():
# get random image either from an api or whatever
# then passing the img url to the template
return templates.TemplateResponse("index.html", {
"img_url": "https://upload.wikimedia.org/wikipedia/commons/c/c3/Python logo-notext.svg",
})
and then in the template
<img src="{{ img_url }}">
That would update every time i refresh the website?
I already found a way to do it i don't really know if it's a good way
Kinda feels hacky
when i try this i get an error
in TemplateResponse
raise ValueError('context must include a "request" key')
ValueError: context must include a "request" key
@delicate ore
i don't know what to do
Never mind i'm a idiot
Works but my images won't show
hi is there someone that knows how to work with Flask? I have some questions about it.
yes
Can you tell me what i amn doing wrong here. I have to read my form data and make it a usable value.
thanks bud!
what's going wrong, what do you get as the output vs what do you expect as the output?
i just want to make the URL that u pasted a value that i can read in my python file
yeah gonna create it in this first and then create it outside afterwards
since no time till deadline

ah sorry
this is actually low code stuff since you can modify the code

When i run this i get an 404 not found error when trying to show one of the images
import uvicorn
import random
from typing import List
#from fastapi.responses import FileResponse
from models import User, Gender, Role
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
#from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
edgar_imgs = ["Edgar/edgar.jpg", "Edgar/Edgar2.png", "Edgar/edgar3.jpg", "Edgar/edgar4.jpg", "Edgar/edgar5.jpg", "Edgar/edgar6.png", "Edgar/edgar7.png"]
app = FastAPI()
templates = Jinja2Templates(directory="templates")
db: List[User] = [
User(first_name="iamSkev", gender = Gender.male, roles = [Role.student])
]
@app.get("/", response_class=HTMLResponse)
async def root(request: Request):
random_edgar = random.choice(edgar_imgs)
return templates.TemplateResponse("index.html", {"request": request, "img_url": random_edgar})
'''
@app.get("/api/v1/users")
async def fetch_users():
return db
'''
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000)
As i thought index.html couldn't access the folder where the images are in
I moved the folder inside templates
Still it throws a 404 not found error
Still can't find it
Hello everyone
I am trying to make a page hit counter into my blog, Idon't want to use google analytics because it's a community blog and I want the authors see their post views.
I can do the normal post analytics but how do i know if a user is a unique / new visitor... I don't want to 2 views for 1 person that refreshes the page
Any idea on how to achieve this??
Feels a bit kiddy tbh we made actually a no code drag n drop flowchart arduino C code gen in one startup ...it was for kids..
if i knew web dev, i wouldnt be in this situation 
my background is in DS
but nobody else in the group is doing jack
so here we are

Imma drinking coffee at 11 pm breaking taboo too lmao
bruh i have cold brew and breakfast tacos rn 
Hi, I have a question, I working on a project with my friend. I want to create an API but there is no localhost connection, so the question is how my friend can use the API? Should I upload it to the server or what is the solution in this case?
He would need to connect to the address of the API
so you can host it virutally somewhere and work on it together or have him connect to your computer
@late trail
You can host virtually pretty cheap for a basic server to dev on
Hi sir. I tried to do your suggestion but it still gives me an 401 error. 😅
which host do you recommend?
Digital Ocean is great
can I share it for free? @dense slate
@late trail , there are some options here - https://free-for.dev
Do you recommend it? I mean did you use that?
Thanks
DigitalOcean is not listed there though 🤔 And they have up to 3 static sites for free
depends, on your budget. I had used it and ended up moving out to kubernetes managed by AWS or DigitalOcean
maybe I will try the pythonanywhere.
I want to give it a try to cloudflare workers
I tried vercel but pricing is a bit confusing for me
@late trail r u a girl 😄
If you have some spare money i'd use a vps provider, you'd also gain some experience with deploying your applications
ok so I have my flask app dishing out html pages on the test server and I'm pretty happy with it. It's a pretty rudimentary flask app I'm sure. what's the next step? How do I go from flask app on local macj=hine to networked flask app?
Deploy it somewhere, get a vps or use free python hosting 🤔
Thanks
why? 😄
Something like 5 eur/mo would be more than enough btw
Ohh, I'm a boy btw. I didn't know that. 😬
haha 😄
For Django I18N do you need two different translations in your locale folder? If you want your website to be available in english and dutch, and you have created an english translation file from dutch, how do I use the default (dutch) translations then
@native tide are you familiar with internationalization in django ?
There will be a button on the web page.
When the user clicks this button, a new tab will be opened, the specified email and password will be sent to Netflix's login page and login will be made.
Its purpose is for the user to be able to log into Netflix without accessing their login information.
How can I do that?
whats the purpose of that 😄
I am making a shared netflix account sales site.
not sure if u can do it just by going on the netflix page
since the password cant be hashed in any way
What does what I want to do have to do with password hashing?
Because what you are trying to do is not possible. "Its purpose is for the user to be able to log into Netflix without accessing their login information." - if you open a window and put creds in, it would be trivial to have those creds read out in the context of the session. So everyone's password WOULD be being leaked
Netflix login forms are plaintext, NOT hashed or protected client side.
exactly 😄
i think his idea is to have something like a subscription based website
u pay lets say 5$ compared to the 12 euros on netflix
and he will provide an account that has premium unlocked
yes I am making such a website but not for myself
so 4 ppl can use 1 acc and he will be getting 20$ for 12 euro 😄
but seems impossible 😄
to code that
It could in theory work, assuming the forms WERE protected/hashed client side so the data could be dumped safely (but they aren't and that is by design lol)
You would also have to deal with people selling their account creds and then changing their creds the next day, etc
Hey , I'm looking to deploy a django app using docker , should I go for gunicorn or uwsgi as my webserver ?
gunicorn
why ?
dont ask why
google gunicorn advantages
and ull know why 😄
i always do that
when i ask for help in some forums
lots of reasons ^ , better support, used in WAY more production settings
Thanks
also licensing @plucky wadi - uwsgi is gpl, which I wasn't even aware of til just now https://www.reddit.com/r/django/comments/or7yvi/is_it_better_to_use_gunicorn_or_uwsgi/
gunicorn it is
I want to update the timeofattendance field everytime i make some change,for ex here every time I increment the value of attendance i want the timeofattendance field to be updated how to go about it
what?
Does anyone know how to add apache full?
Using auto_now should do what you're saying
ok
thanks it worked
you should note that calling .save on a Student will always update that timeofattendance field, even if nothing changed.
Django question. I've been building a web application and the DB has been growing. However, I just went to add a new column to the model by adding the following:
twilio_massaging_service_id = models.CharField(
null=True,
blank=True,
max_length=20,
help_text='''Enter the Twilio Messaging ID'''
)
I've made no reference to this field elsewhere in forms or views. This is the first time I'm referencing the column. And, it obviously does not exist. However, when I run makemigrations I get the following error: django.db.utils.OperationalError: no such column: events_eventsetting.twilio_massaging_service_id
I am confused. Help?
Hey @ionic raft!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
Here is the full traceback: https://paste.pythondiscord.com/eyanujajof
This seems like a very strange error. I am adding a column to the model and I have no idea why it would tell me there is no such column on makemigrations.
I get exactly the same error
It appears to not be letting me add any columns to models now. And I'm utterly stumped as to why
check your last migrations file
is that error when you makemigrations or migrate?
what's the last migrations file look like
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('events', '0161_event_event_payment_gateway_event_stripe_product_id'),
]
operations = [
migrations.AlterField(
model_name='eventsetting',
name='twilio_account_id',
field=models.CharField(blank=True, help_text='Enter the Twilio Account ID.', max_length=80, null=True),
),
migrations.AlterField(
model_name='eventsetting',
name='twilio_phone',
field=models.CharField(blank=True, help_text='Enter the Twilio Auth Token', max_length=20, null=True),
),
]```
ok so you're trying to alter a column that doesn't exist yet
Which I've literally done 100s of times. Now all of sudden...it's not letting me add any columns
Oh actually no those are different fields.
Exactly
Im trying to add a new column. I add the text > run makemigrations > get that error.
And I'm stumped
Here's the net-new text in the EventSettings model: twilio_massaging_service_id = models.CharField( null=True, blank=True, max_length=20, help_text='''Enter the Twilio messaging ID''' )
Read your mind...I'm adding the text above to the EventSettings class in models.py
This really has me puzzled. I've run hundreds of migrations and added plenty of columns.
It tells me no changes detected
ok so you already added the column, or your DB thinks you did
did you add it and now are trying to alter it?
No. I didn't already add the column. I added the column to models.py, ran makemigrations and got that error
No. That happened immediately on trying to add
ok but you said without the text it says nothing detected. are you talking about the help text or the whole field?
The whole field.
so "added text" you mean you added a new field to the model?
Yes.
As per the pasted text
I am now trying a completely different field to test test_field = models.CharField( null=True, blank=True, max_length=10, )
like in admin or something
I get ``` return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such column: events_eventsetting.test_field
So basically, I appear to be unable to add a column to the DB anymore
I can alter fields...but not add
This is actually a problem. I either have to fix this DB or completely rebuild
If I make an edit to an existing field all is well
run manage.py dbshell
and then .schema events_eventsetting
See if something is there you don't expect
`CommandError: You appear not to have the 'sqlite3' program installed or on your path.'
ok so are you connected properly to the DB?
This is unknown territory...
in settings.py?
I start up the app and it calls from the DB
I'm inside the console in PyCharm
Yes. I can change fields but not add. I've made no changes to settings.py
You using sqlite?
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}```
And you didn't recently upgrade Django?
