#web-development
2 messages · Page 158 of 1
the issue i'm actually having is that redirects in flask just send me to localhost
it's done this on every flask install i've done
no clue why
is this during production?
i.e. if the url u are visiting is myapp.com, it redirects you to localhost?
yes
pretty wild IMO
i thought it was something regarding server env var config or smth
but it's not, ostensibly
Please can you tell me, well also I'm using Jinja, exactly I'm making a discord bot dashboard and i wanted to display all the list of commands, and when i hover over the command it will display it's description, usage, etc
For that I'm using quartz, jinja, d.py
i'm not that familiar with quarts. in Jinja you can iterate over a python list as html like this:
you will need some sort of web framework/server in order to deploy your site as well if you want to use server side rendering such as jinja
Are you using blueprints by any chance?
https://stackoverflow.com/questions/65951531/flask-redirect-method-redirecting-to-localhost
I am indeed not.
I literally just booted up Codespaces and did pip install flask followed by flask run
there's an issue with tailwindcss classes being found in pycharm, has anyone had a similar issue?
You neee to install the linter f9r it
yeah I did (the plugin), but it's still not working so I think something might be up with my tailwind.config.js
Are you purging the right directories and extensions?
And using craco for your scripts (if you're using React)?
^ not sure what this means
You use React, right?
React doesn't support PostCSS Compat 8 yet, so you need to use 7, and for that, you need to use craco for your start and build scripts
This guide explains it: https://tailwindcss.com/docs/guides/create-react-app
i'm using next.js so I followed their guide on setup, I'll retry and if it doesn't work I'll try that. The tailwind.css file doesn't actually include any css just @tailwindcss components (for example - not sure on what that's called) so it's not picked up by intellisense, but all the strange test .css files from tailwind are. anyways, I'll restart my project
Oh, next? My bad
I think you need more than just @tailwind components;
Pretty sure you need
@tailwind base;
@tailwind components;
@tailwind utilities;
yeah I've got that, it's just that whatever @tailwind does it's not being picked up by intellisense
or something like that
I don't think PyCharm is officially supported by Tailwind, so it might just be that the autocomplete is wrong
they have a plugin for it
Oh, I didn't know that
it's not working for me though :(, this is gonna be a thinker
holy crap, I literally got it to work and I have 0 idea why
that's good enough for me, hurrah 🥳 🥳
Until it doesn't work again 👀
yeah, hopefully not 😭 . I literally have no clue how I got it to work, it just happened
Sometimes PyCharm is just slow to index files tbh. Sometimes it also doesn't index properly
You working with React?
How I can shoot a web page for a few seconds (or make a gif) with selenium?
anyone here familar with chart.js
How to append to a list in Jinja, without calling it?
{% set grouped_products = [] %} ##### List is created
{% for product in products %}
{% for product_category in product.category %}
{% if product_category.category_id == category.id %}
{% if (product.product_group) %}
{% if product.product_group.group.group_name not in grouped_products %}
{{ grouped_products.append(product.product_group.group.group_name) }} ## Item added to list
It appends it to the list, but it also calls the list because I'm using {{ }} - I just want to append the item to the list
nvm sorted it. Always the way after I make a post 😄
someone tried using Flask for server sent events? it seems my threads will not close properly and flask eventually crashes
i'm using this code https://maxhalford.github.io/blog/flask-sse-no-deps/
i guess because the message queue is blocking, it won't close the threads until a new message is sent if the client is already disconnected?
Can someone help me in help-bread. I have been waiting 30 min. Maybe that is typical wait time. I can't get flask run to work. I tried the obvious. More detail in the help channel
okay I made a new help channel in carrot
Mind sharing your setup that's running the Flask app - e.g. Nginx and uWSGI? The redirection to localhost could occur if say a reverse proxy is not set up quite right.
yep, working with React (next.js)
i don't know about you but it takes me so long to create components
i'm always debating about the design and then it'll take even more time re-creating the component...
It's using the default web server as I am just trying to get the application built
I am not a fan of spending my time managing convoluted tools
presumably the company that acquires me should specialize in such matters :P
do you do wireframes in some sort of design tool?
no, that's probably where the issue lies, but I think even if I used Figma or whatever I would still bash my head against the wall on what the best design is
it helps IMO
iterating in a design tol
is generally faster than doing so in code
uh
okay honestly?
I do drawings
like physical ones
LOL
use whatever works for you
😂 I didn't expect that ngl
like really simple ones
Hello, I'm not sure if this is the right spot for this, but I'm attempting to host a web-app online, and am using a MySQL database that's done through Google Cloud Platform's SQL. I have connected to it via Flask-SQLAlchemy, but I am having trouble actually creating the tables. I also posted this in #databases, but I think this might be a better spot. For some more general information, the application itself is built on Flask_RESTful
When running locally, I can just do as follows, but with my understanding, this code is not run when being deployed through Google App Engine.
if __name__ == "__main__":
db.create_all()
app.run(host='127.0.0.1', port=5000, debug=True)
The error that I'm getting through GCP is ProgrammingError: (1146, "Table 'file_info.file_indices' doesn't exist") so I'm assuming that the db.create_all() code hasn't run. The issue is, I'm not quite sure how I can run it, as it appears that I only need this to be run once in the Flask app.
Here is the database model:
class FileIndices(db.Model):
_id = db.Column(db.Integer, primary_key=True)
user = db.Column('user', db.String(80), unique=False, nullable=False)
filename = db.Column('filename', db.String(200), unique=False, nullable=False)
file_info = db.Column('file_info', db.String(500), unique=False, nullable=True)
file_type = db.Column('file_type', db.String(20), unique=False, nullable=False)
summary_generated = db.Column('summary_generated', db.Boolean, unique=False, nullable=False)
transcript_generated = db.Column('transcript_generated', db.Boolean, unique=False, nullable=True)
def __init__(self, user, filename, file_info, file_type, summary_generated, transcript_generated):
self.user = user
self.filename = filename
self.file_info = file_info
self.file_type = file_type
self.summary_generated = summary_generated
self.transcript_generated = transcript_generated
run once meaning run once ever, right?
don't put it in your server's entry point
that's run once every startup
and if you wanna horizontally scale in the future...
put it in a separate script
and run that.
at the moment, it's not running at all
once, manually
so i'm not quite sure how to run it manually since it's on google app engine
if it was a vm it probably would've been easy, but google app engine is a bit odd
I'm sure GAE gives you some mechanism to access a shell on the instance your code is on
okay so the issue here is
there's no automated migration management
on Django there is so all of this is taken care of for you
you could add additional logic
that basically amounts to
"if database not created then do it"
yeah i saw something like that, but i'm not quite sure where to put it and where it wil run
i could try putting it in the script itself
It gets better with time. I work with it daily for my work (next.js as well) I highly recommend taking a look at styled-components when using React especially if you're trying to dynamically update styling or classes on an element.
We are thrilled to announce the launch of Imagine.ai - a platform where you can generate production-ready Django code in seconds.
Just set up your project preferences and define your data models in our UI, and we generate a code base (including working REST / GrahphQL APIs), that is fully tested, dockerized, linted and more - instantly. Our goal is to generate clean, well-written Django starter code that works out-of-the-box, so you can save time and focus on writing custom business logic.
We’re still at an early stage and we're working hard to build a platform that’s useful & interesting for developers - so we’d appreciate all the feedback you can give us! Please reach out to us through our Discord or Slack with any questions, suggestions or even just learning more about the platform.
Also, learn more about our competition where you can win a cash prize by building a Django project using Imagine.
Win a cash prize by submitting a Django or Node project built using Imagine!
I saw that in the Blitz.js server (or was it Next.js), seems really interesting.
Thanks! Did you have any thoughts about the tool? Any features you'd like to see added?
I haven't taken too close of a look at it yet, but I'll do so when I have some time.
this is p cool
did you check with mods whether it's considered advertising though?
Oh it's a free tool. Sorry I can check
I am returning a valid HTML string that I'm rendering in a template, but specific {% ....%} are redendering as a literal, even after applying safe filter.
return "<button type='submit' class='button value='Save'>Save<svg class='icon'>{% load static %}<use xlink:href='{% static 'svg/icons.svg' %}#save'></use></svg></button>"
I am redering like this {{ html_string|safe }}
{% load static %} and {% static 'svg/icons.svg' %} are rendering as literal strings, not processed by django template engine
hey there, so i've been having a couple issues with a button not appearing when i render a template with quart. anyone know why? it's kinda just like a blank rectangle
the button in question is in this file:
https://github.com/MrKomodoDragon/paste-site/blob/new-stuff/templates/view.html#L12-#L22
templates/view.html line 12
{% block new %}```
Thanks i need that only, can you tell me more about it
I'm using one!
Hi, someone uses django ?
my favorite all-around framework
I lost a job because i dont know the framework. sad
Now im learning
I actually started to learn in advance it, because I saw all Python job position requiring Django%
I forced my company to choose as main framework Django instead of Flask)
As one of reasons, to get practice for myself. As another reason... job is done 10 times faster with Django. And 2 times better quality
There are some other competitive frameworks though
I hear and read a lot of good about Fast API, wishing to try it as next framework to play with
I have a doubt related to Django can someone please help me
Hey @native tide!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
@native tide show code
error or problem
doubt is having a wrong meaning for your phrase.
I heard its common mistake for some language native speakers, not remembering which one
that won't work
not sure if all() is necessary though
the error will still be raised
its not
thanks
Ohh...then can u help
I'll send my project...please check it if possible...please
no need. the problem is pretty simple. What exactly are you trying to do?
Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free.
There's this error when u run it...
This is the file
ik what the error is.
I want you to explain what you are trying to do
well i shuld tell you what you are doing wrong
when you do MyModel.objects.get(some_field=some_val) then it is mandatory that only one object is returned. You are however filtering on the basis of date. Two or more books can have the same date and so more than one object (2 in this case) are returned.
To fix this, you will have to use a more unique field for the filter. Try doing it via the id field.
There is also the MyModel.objects.filter() which will return zero or more objects. Maybe that is what you need. I can't really tell.
#help-bread please i just need a little bit of guidance
!close
But when I use filter it keeps asking to select another date repeatedly
show the code where you are doing the filter
book=Book_ground.objects.filter(date=date)
Though the page is shown
The error is very obvious. Look into the python docs about how to format dates
Hi
Side project in progress !
I think i will go with FastAPI + VueJS for it. Anyone mind sharing some advices, warnings, experiences... before i go 🙂 ?
Hey I checked I couldn't find it...can u pls help
What did you try to check?
I can't change it...I tried date input formats
I have absolutely no clue what you are trying to do
Can you paste some of the relevant code here?
!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.
I just want to get rid of the error...
well for me to help you, youll have to show me some code so that i can uderstand where the error is
I'll send the project is that fine?
do you have a github link?
No...can I send a zip file
Hey @native tide!
It looks like you tried to attach file type(s) that we do not allow (.rar). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
Dun
AzePUG Blog Site
hey guyz, you can check our blog about FastAPI
from official Azerbaijan Python Users Group
any django developers here ?
No need to ask, what's your question?
i am making a query from models.py and it shows that obect is not iterable
object*
class Testdetails(models.Model):
testid = models.ForeignKey(Testscores, on_delete=models.CASCADE)
subid = models.ForeignKey(Subject, on_delete=models.CASCADE)
percent = models.CharField(max_length=100)
userid = models.ForeignKey(Users, on_delete=models.CASCADE)
def __str__(self):
return str(self.testid)
this is the model
tdetails = Testdetails.objects.filter(userid=1).order_by('-testid')[0]
and this the query i am trying
I want to access subid after this query
any solutions ? pls help!
I recently just got a website designed for me on Figma. I want to export it to upload it to my shopify store but the designer said you must do some conversion. Bit confused, any ideas?
Figma won't be able to directly translate to exactly what you want. You'll need to mess around with it a little to fix or change some things so that it can integrate with Shopify.
so i would need to get in touch with a front end dev to do this for me?
If you know some html/css, then it shouldn't be too hard. If you don't know it, and don't want to learn, then yeah, probably.
I am having an error called no such table called products_product after running the server. I am using django. Actually I reset my laptop and every python setup was gone. I installed python latest version. Previously it had python 3.6 . The project was running perfectly but after resetting my laptop every model object I retrieve or create It says no such table exist
The error doesn't occur when i create a new project. It is just happening to the current project i am working
have you tried running migrations
open command prompt in the current project directory
then do python manage.py makemigrations
and then python manage.py migrate
it should work now
Can some one explain me what query string is and why every url has ? In it
Like this
Does anybody has a good Discord channel for anything JS frontend related? Speaking as a React beginner because I'm lost with the hooks
I Did it but didn't work
Thanks mate
How can I download castro on raspberry ?
because
from castro import Castro
File "/home/pi/.local/lib/python3.7/site-packages/castro/__init__.py", line 10, in <module>
import lib.messageboard as mb
ModuleNotFoundError: No module named 'lib.messageboard'```
Reactiflux discord
thank you!
I really like that here some people who are experts and know this wont explain but when they need help they want others to explain
You can think of the query string as a dictionary, with key-value pairs. This is how it looks like:
https://url.com/?key_1=value_1&key_2=value_2&key_3=value_3
the start of the query string starts with ?, each key/value pair is seperated by a &. This is what helps you extract information from the URI
Thx so much <3
hey how can i do that if anyone donates in my site , so it show it in my other (donaters.html) , ik that fetch function but patreon is not my site (lol) so how will i know who donated ;-;
and how can i make sign up page backend ;-; , which stores user idp and data + with there username
is learning learning python from w3schools enough to get started with django?
Please don't learn Python from w3schools. w3schools is a reference, not a place to learn.
Below, a lot of really good places to learn are linked
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
ay thanks
is anyone knows what is wrong with my setup? There is no error but the app doesn't run
do you know a tool like selenium that supports apython video recording?
Hi
Hello
I'm using django and have email based login methods
Do I use the default user model or create my own ?
I'd like to have a level of roles for each user
Use custom user model
Line #11-12 should not be inside function. Indent it left
Alright I don't want to see the users in here
currently userlooks like thsi
It will go away when you set custom user model in settings.py
Okay thanks!
in app.run put debug=True
try
Instead, you're better off extending the user model instead of creating your own. It will save you a lot of headache and allow you to keep the same methods as the default User model.
What to study in Python to get hired for a junior position here in web-dev?
there is a famous question "what all happens when you type google.com in browser". There's a git repo to answer that question. Choose the depth that you can quickly comprehend and study each component in that answer. For example, what web browsers do, what is domain, what is dns, what is http, what is http request, what is http server, what is application, what is rendering template, what is html, css, js, what is http response. First couple of iterations on this path should be more than sufficient. Choose a simple Python framework like flask for reference and easily do each step. Done! you are a full stack junior web developer
when you study each of those components in depth, slowly you will turn into a senior web developer
thanks I figured out
Did my method worked?
ec2 is not connecting via ssh after setting up apache2 server on it somebody help
hello there, can i find here in Django dev that is quite familiar with Django library's ?
u can
Did you close the ssh ports ?
No I didn't
Ssh inbound is open everywhere and outbound is all traffic allowed
Did that the users thing from top went away
But the staff status and stuff is still there
#bot-commands
Do you know of any software (like selenium) that can simulate a browser, functional on vps that can take video (or screen very quickly) and simulate keys
or do you know an alternative to castro? https://pypi.org/project/castro/ to register a site ?
am trying to automate the purchase of shares on the website Predictit. My code is currently finding optimal markets to invest in but I'm struggling to automate the purchase of shares because the URL is different every time. The website doesn't have an API so is there any way to automate or scrape the website.
here is a link to the website: https://www.predictit.org/markets
I see tons of performance comparisons between web frameworks, but none regarding websockets, anyone got some?
Litterally doesn't matter about any of it. In production they're all really the same sort of speed. I wouldnt worry about any sort of performance issue really. The slowest thing is gonna be your IO not your framework
Mhmm
so can ANY kind of data be used with websockets? and JSON is just the most commonly used? like can you use XML over websockets or just plaintext? or does websockets need to be JSON?
no
you can send whatever you want
strings or binary data are both fine
I am learning Django using the ebook "beginning django: web application development and deployment with python"
Anyone else followed this path?
i am building a simple weather app that shows only temp for current and hourly wise using flask as a backend
This is how i show the data from API to the frontend in this way how can i show the dt field from API response which is in Unix time into 12hr format
guys how do i store this img , i got this from the frontend data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA54A…kBE8AAACSEjwBAABIKIT/BxTJ43TF9pn+AAAAAElFTkSuQmCC
guys do companies need to pay money when they message you to verify your phone number
like say when you sign up to instagram, they verify your phone number by sending you an sms
so does this cost money
its base64
so i should decode it ?
yes
Hey Guys!!! I am just trying web development in Python using flask. I just created everything, but when I try to register and login it says "CSRF tokens are missing". What should I do here?
use {% csrf_token %}
Thank you!!
np
Hey guys, I have honed my python skills and now want to learn Flask, however I do not have the energy to sit through a teacher/lectures teaching it. Any recommendations where Flask can be learnt through reading/blogs/more reading based approach?
Here you go
Research on browsers compatibility.
Thanks for your response @sturdy marten . Have you read this manual? Do you recommend it?
I got the recommendation from someone. I've gone through it, it's a good starting point. But I'm learning with django not flask
I am a complete beginner to all of this. Is Django better than flask?
Ohh I meant to say, you need to make research on which one is best compatible with browsers these days. Amongst other requirements
I can't say, but I just chose django. It's about the developer not the technology
Although am sure seasoned programmers would give you specific differences between them.
yes django for sure is better but it does spoon feeding and do things automatic but user should know whats happening in bg like db and connecting things in flask we have to do it ourself so our db part and things get good and u will never face issues while doing django , i strongly recommend flask first
@fickle reef
Hmmm
good luck , u will face issues while connecting and making db that topic but dont give up for sure u will get it , if u dont get try again again and again but dont gove up
hey bro hi!
Hi
so i have been learning flask from months
and now i wanted to switch to django
but i have some questions
What resources do you use, I don't mind trying it too
my flask is clear leaving a few things
docs + yt + dc friends+ 3 projects
I'll try. I'm just two months into django, theoretically understanding what's happening behind the scenes than practical for now.
for flask
Ohh noted
The pdf am using for django is quite explanatory
That's why I got comfortable learning it
how can we make a sign up backend . 2nd how can we ask user for notification as some sites do by flask
rather that it ik jinja templating . inheritance , db's , connecting db making db , making a login page , fetching data from db , message flashing , make rest api
connecting with mail
and all the things
just have 2 questions
..
For django you mean?
this is stopping me to give myserf 101% on django , so i came back at flask to learn
nope in flask
ok tell me django , cez i want to be good at django too
After that, I'm trying fastApi.
Basically I'm into django for web development.
But then again want to use another technology to handle api development
hm simple use jsonify
I'll try. But I have to say, I'm not that far yet.
I'm taking at a pace so I don't learn half-assed
Yeah. Knowledge sharing
We'll certainly keep up. Am tryna be active in a community
ok lemme open my django file and, lesgoo!!
yes added u friend
u from? @sturdy marten
Nigeria.
oh im from India and im 15
Hello
Is there any way in django to use a view inside another view?
For example let's say i have a HomeView and a PostListView
PostListView gets all the posts from the database and renders them in some way
i want to add that post list inside HomeView to avoid creating a context variable with the items in each view i render the list
is it possible?
or is there another approach?
either way you have to abstract the common code. if you are using function based views then define a function that takes care of common functionality and call it from both views. if you are using class based views then define a base view and inherit other 2 view classes from the same
it also depends on how often you expect code change in this area of your codebase. if it's like write once and forget then code duplication is okay. In certain cases following the rule of 3 (don't abstract unless you are using the same functionality in more than 3places) is actually very beneficial
alright thanks
im used to the concept of component in javascript frameworks and this is a bit weird
another one.. just to confirm
in order to change the context variables in class based i need to override get_context_data right?
yes
thanks!
@arctic temple you can have the view as an API, and make a request (a side effect) to return data from that secondary view.
Anyone know of a flask powerpoint to jpg converter?
Let's say you had ASGI django with no middleware. How would this compare with the speeds of FastAPI?
what up
Anybody used GeoDjango?
https://slambook-py.herokuapp.com/nuc2vir
django app
its a type of a game
you can create a set of 10 questions and then share a unique link to your friends to answer them | and you can view those answer!!!
Thanks👀
I want suggestions for this to imporove ! NOt a advertisement
You can just ask your question, we will help if we can.
Hey, Does anyone know how to show an image in the background of a div by selecting it from input file tag?
using Javascript
What's the difference between HyperlinkedModelSerializer and ModelSerializer in django rest framework?
I tried it in this way but didn't worked.
Anyone knows how to do it?
guys i tried to make the navbar to be fixed but how do i make that first card to show fully , if i change the navbar to static its showing the first card fully
nvm that was a stupid question
Hi so I want to add users to a group but I can't save the users because I get this error
'FIELD ID EXPECTED A NUMBER BUT GOT A ()'
I'm uding django
Using
Is Gunicorn + Gevent (monkeypatch.all) still relevant? Or is there something better out there. I'm trying to scale up my flask backend to support a high number of RPS but having some troubles benchmarking and finding the bottlenecks.
Generally, your IO will still be the slowest thing followed by the data transactions. In terms of relevent yes gevent is still relevant and alot of companies use flask and that setup because it makes flask very performant in real world situations. In terms of new kid on the block, ASGI systems / asyncio in Python is alot more popular now days because its explicit and directly integrated in python which makes life easier for developers (it's also a bit more efficient) but it does generally require re-writing your entire backend from the ground up to make it worth using
Gevent will likely give you plenty of extra wiggle room and it's still what most flask apis will use today e.g. discord
could you please define "high number" ? 10k? 100k? 1mn? 10mn? 100mn?
how to insert image in django html
image is in http://127.0.0.1:8000/media/wishrecoder1.PNG
location and i want some other method to include image in html so that if i change port or ip i dont have to come to html and change the src
<img src="http://127.0.0.1:8000/media/wishrecoder1.PNG" class="carousel-image" alt="page1">
Ok thanks for this I feel comfortable moving forward
use static template tag with static and media directives configured in settings as explained here - https://docs.djangoproject.com/en/3.2/howto/static-files/
I think even 10K is high
10k requests per second is a metric fuck ton
frontend is going to make about 100> per user
thanks
in production 10k rps is top 5% website level of big
i was doing server side
this could be your bottleneck more than server. If it's browser then note that browser limit max number of concurrent requests per server
Wikipedia gets less requests per second than 10k 
it seems that way
Browsers limit the number of HTTP connections with the same domain name. This restriction is defined in the HTTP specification (RFC2616). Most modern browsers allow six connections per domain. Most older browsers allow only two connections per domain.
because if I just do async resquests.posts I get my singel response back in about 10-20s
bearing in mine 10krps is 300 BILLION requests a year
but the browser is taking 50s
you should look at a persistent websocket opened. that way you get much better transport option
what are you doing on each of these requests?
generally i avoid websockets at all costs
because they scale awfully
the web app is a blockchain wallet tracker
yeah, what's your use case like? dynamic apps with that sort of velocity would definitely justify something like react/angular with websocket/webtransport
so I'm making a bunch of calls to the blockchain network and then erturning the response.
would like to know why. (not that I'd disagree, more like I'm curious)
i meant to quote you on your websocket doesn't scale remark*
generally, I think sending the calls to the blockchain network is gonna be your bottlekneck
Pretty standard:
- Once a connection is made it cant be re-shuffled without reconnecting
- Each connection holds that port up all the time even when its not doing anything.
- Websocket connections generally are also very hard to cache on the proxy side and proxy caching is your best friend at scale
yes and there isnt any async library developed for this
would encorping a redis queue in the mix just cause more headaches or actually be benificial
well i wouldnt necessarily say a redis queue because stuff is still gonna take about the same time, but are you able to cache the responses for a given amount of time?
what do you mean by that?
So if you send a request to the blockchain network
are you able to save its response for a bit, and then future requests use that data for a little bit before re-fetching
the Time to live can be very small
but it means that under much higher load you send less requests to the network and instead hit the cache which will likely be quicker
I guess in theory yes but pricing data is important in this realm
Anybody in Web geographical apps? Because I was wondering if leaflet + GeoDjango would be a good combo
@woeful vapor what is your request flow like? 100req from client to your server which propagate to blockchain networks?
I mean if its something like 100ms time to live would that be to long in terms of the data becoming invalid?
for the caching? Thats not too long at all
Imo i would make it cache the response for as long as you can without making the data invalid
so that under high load
most of the requests will hit the cache rather than sending another request and waiting for non-local IO
because a locally hosted redis/keydb instance will a couple ms at most (generally less than 1 ms)
hey need a small help ,i already 1 login panel how can i create 1 more login page
by flask
I think this a good place to look into and also optimizing my backend to respond faster
whats the standard size limit for a file (png jpg) for users to upload on a webapp?
ok, why do i need a hosting service for flask?
whenever i use this html file it gives -302 error idk why
Hey @dusk portal!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
@nimble dawn About your question in #career-advice, just know that you should never use document.write()
console.log() is the correct way to print.
@app.route("/login",methods=["GET","POST"])
def login():
if 'uname' in session and session ['uname'] ==params['admin-user']:
return render_template("admin.html",params=params)
if request.method == "POST":
username=request.form.get('username')
password=request.form.get('password')
session['uname']=username
if username==params['admin-user'] and password==params['admin-pass']:
return redirect("/admin",params=params)
else:
return redirect("/login")
return render_template('login.html',params=params)
@app.route("/admin")
def admin():
if 'uname' in session and session ['uname'] ==params['admin-user']:
report=Contacts.query.all()
return render_template('admin.html',params=params,report=report)
else:
return redirect("/login")```
login.html is contains a login form and admin.html contains page which logged in user can see so
127.0.0.1 - - [21/May/2021 21:23:20] "GET /login HTTP/1.1" 302 -
why i always face this issues
and when im opening login.html not in my flask app(server) its opening
;-;
@dusk portal sup
i can't sorry just text
ignore the html only. focus on the flask server
does any page load
like when do you get the 302
after you login?
or when you load the page
/login?
This page isn’t working127.0.0.1 redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
yes
i see why
oh tell plz
one minute
@dusk portal
oh done? @solemn glacier
@app.route("/login",methods=["GET","POST"])
def login():
if 'uname' in session and session ['uname'] ==params['admin-user']:
return render_template("admin.html",params=params) # you may want to redirect instead of render
if request.method == "POST":
username=request.form.get('username')
password=request.form.get('password')
session['uname']=username
if username==params['admin-user'] and password==params['admin-pass']:
return redirect("/admin",params=params)
else:
return redirect("/login")
return render_template('login.html',params=params)
@app.route("/admin")
def admin():
if 'uname' in session and session ['uname'] ==params['admin-user']:
report=Contacts.query.all()
return render_template('admin.html',params=params,report=report)
else:
return redirect("/login")
wheres the problem
se the comment too
else on line 11
should have been indented
try it
if it doesn't work let me know
lemme try
you had a redirect loop
you were redirecting to /login on a get request to /login
worked?
oh damn
def login():
if 'uname' in session and session ['uname'] ==params['admin-user']:
return render_template("admin.html",params=params) # <-- you may want to redirect instead of render [READ ME]
if request.method == "POST":
username=request.form.get('username')
password=request.form.get('password')
session['uname']=username
if username==params['admin-user'] and password==params['admin-pass']:
return redirect("/admin",params=params)
else: # < -- this wasn't indented it was it was an else for the "if request.method == "POST":" so when you made a GET it just loops the redirect over again
return redirect("/login") # and this^
return render_template('login.html',params=params)
see comments
Hi
oh lol i saw
the problem was
i putted 1st if then indent then 2nd and 3rd in indent but 4th on 1st indent place
lol
Hi, im using python flask as my backend.
im returning a value in python then displaying it on my html page.
How would i use the python return inside a js tojson?
{{all_test_data|tojson|safe}};
var test = {{all_!python_return!_data|tojson|safe}};
what does test look like doing that?
its all good got it to work was a silly error on my end
Hi so im adding users to my website through the admin panel and i have custom fields and all but each time i add a user in my group i get this error:
Field 'id' expected a number but got ()
Need a bit more context here. Are you using WTForms? What does it look like? What does the template for this section look like?
ill show
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
class registerForm(UserCreationForm):
first_name = forms.CharField(max_length=30, required=False)
last_name = forms.CharField(max_length=30, required=False)
omang_id = forms.CharField(max_length=30, required=False)
email = forms.EmailField(max_length=254)
phonenumber = forms.CharField(max_length=30, required=False)
city = forms.CharField(max_length=30, required=False)
date_of_birth = forms.CharField(max_length=30, required=False)
address = forms.CharField(max_length=30, required=False)
class Meta:
model = User
fields = (
'username', 'first_name', 'last_name', 'email', 'omang_id', 'city', 'date_of_birth', 'address',
'phonenumber',
'password1', 'password2',)
Can you share the full traceback of that error?
Nvm getting the same thing again.
The returned value of test looks like:
[{"time": 1620949623, "open": 19, "high": 19, "low": 19, "close": 19},{"time": 1620949623, "open": 19, "high": 19, "low": 19, "close": 19}]
{{all_test_data|tojson|safe}} works fine i just need to replace the "test" with another value from a for loop
Sorry, don't quite understand. You're trying to replace something in test with some value from a for loop where?
var bot_name_list = ["test2", "test3", "test3"];
bot_name_list.forEach(function(bot_name) {
this[bot_name+"_change"] = function(){
var all_chart_data = {{all_!!bot_name!!_data|tojson|safe}};
candleSeries.setData(all_chart_data);
}
});
each "all_test1_data", "all_test2_data" and so on has a different set of dictionaries set to them
!warn @woven terrace I just told you that we don't allow offers of paid work. If you continue, you'll be removed.
:incoming_envelope: :ok_hand: applied warning to @woven terrace.
Sir I forgot I advertised there
I deleted my messages @manic frost
heres the trace back
Hey @mellow kettle!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/W/student/add/
Django Version: 3.2
Python Version: 3.8.5
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'W',
'crispy_forms']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Hi i I will scrap data over a link but this link is not a static link. The link is varies according to the dates. for example: http://www.sgk.gov.tr/wps/portal/sgk/tr/kurumsal/merkez-teskilati/ana_hizmet_birimleri/gss_genel_mudurlugu/anasayfa_duyurular/duyuru_20210512
http://www.sgk.gov.tr/wps/portal/sgk/tr/kurumsal/merkez-teskilati/ana_hizmet_birimleri/gss_genel_mudurlugu/anasayfa_duyurular/duyuru_20210505
This link is only posted every Wednesday and only the last part (date part) of the link changes. How can I access only this link that changes the end each time? And how can I save the excel file in the link and view the data in the form of a table? How should the process steps be ? thanks in advance for the help
Traceback (most recent call last):
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\fields_init_.py", line 1823, in get_prep_value
return int(value)
The above exception (int() argument must be a string, a bytes-like object or a number, not 'tuple') was the direct cause of the following exception:
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\contrib\admin\options.py", line 616, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\contrib\admin\sites.py", line 232, in inner
return view(request, *args, **kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\contrib\admin\options.py", line 1655, in add_view
return self.changeform_view(request, None, form_url, extra_context)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\utils\decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\utils\decorators.py", line 130, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\contrib\admin\options.py", line 1538, in changeform_view
return self._changeform_view(request, object_id, form_url, extra_context)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\contrib\admin\options.py", line 1584, in _changeform_view
self.save_model(request, new_object, form, not add)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\contrib\admin\options.py", line 1097, in save_model
obj.save()
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\base.py", line 726, in save
self.save_base(using=using, force_insert=force_insert,
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\base.py", line 763, in save_base
updated = self._save_table(
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\base.py", line 845, in _save_table
updated = self._do_update(base_qs, using, pk_val, values, update_fields,
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\base.py", line 879, in _do_update
filtered = base_qs.filter(pk=pk_val)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\query.py", line 941, in filter
return self._filter_or_exclude(False, args, kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\query.py", line 961, in _filter_or_exclude
clone._filter_or_exclude_inplace(negate, args, kwargs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\query.py", line 968, in _filter_or_exclude_inplace
self._query.add_q(Q(*args, **kwargs))
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\sql\query.py", line 1396, in add_q
clause, _ = self._add_q(q_object, self.used_aliases)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\sql\query.py", line 1415, in _add_q
child_clause, needed_inner = self.build_filter(
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\sql\query.py", line 1350, in build_filter
condition = self.build_lookup(lookups, col, value)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\sql\query.py", line 1196, in build_lookup
lookup = lookup_class(lhs, rhs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\lookups.py", line 25, in init
self.rhs = self.get_prep_lookup()
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\lookups.py", line 77, in get_prep_lookup
return self.lhs.output_field.get_prep_value(self.rhs)
File "C:\Users\BIDA19-040\PycharmProjects\drivingTP\lib\site-packages\django\db\models\fields_init_.py", line 1825, in get_prep_value
raise e.class(
Exception Type: TypeError at /admin/W/student/add/
Exception Value: Field 'id' expected a number but got ().
So, basically you just need to get the last wednesday and change the last part of the url wich is the date 20210505 is 05/05/2021
Then you make a request to the url
Scrap the data you want
To work around with excel take a look at pandas
You can print a table with pandas
And you only need the link to the excel file to access the data
besides fiverr, where can i find people to make a website for me, are their any discords or anything?
you are looking for hiring services. https://upwork.com and e.t.c.
thanks
hello
i was creating an app to download video from https://mover.uz but I got stuck that my soup can not find "video" tag even it excist
from bs4 import BeautifulSoup as bs
import os
import io
from base_func import *
# from kivy.app import App
# from kivy.uix.video import
a = load_url_string("https://mover.uz", "GET")
a = a.find_all("section", class_="index-featured")
a = bs(str(a), "html5lib")
c = list(a.div.contents)
type(c[1])
type(c)
c[1].div.a.img["data-live-preview-src"] # video preview video link
c[1].div.a["href"] # video link
c[1].div.a.img["src"] # video picture link
# len(a.div.contents)
# for i in c:
# print(i.div.a.img["data-live-preview-src"])
# /html/body/div[1]/main/div[1]/div[1]/div[1]/div/div/pjsdiv/pjsdiv[1]/video
v = load_url_string(c[1].div.a["href"], "GET")
# v.find_all("iframe", class_="video")
# print(v.find(string = c[1].div.a["href"]))
"""here I could not find vide tag"""
g = v.find("video")
Mover.uz - Видео онлайн. Юмор, приколы, клипы, интересные моменты и многое другое.
this is my bas_func:
import urllib3
from bs4 import BeautifulSoup
import io
import os
def load_url_string(url1: str = "url should be a string", method: str = "GET") -> None:
http = urllib3.PoolManager()
r = http.request("GET", url1)
s = r.data.decode("utf-8")
return BeautifulSoup(s, "html5lib")
this is a part of html that i can not find
<video style="position: static; top: 0px; left: 0px; width: 100%; height: 100%; object-fit: contain; transition: filter 0.2s linear 0s; min-height: auto; max-height: none; min-width: auto; max-width: none;" src="https://v.mover.uz/KEVHlF8g_h.mp4" x-webkit-airplay="allow" pip="false" preload="none" autoplay="0"></video>
@mellow kettle did you read what the error told you?
How do I change the last part of the link so that you can access the excels of both the last Wednesday and the previous Wednesdays?
does some one know how to dou delete request
def do_ge(self):
def do_POST(self):
does do_delete exist
yes i did but i dont understand what it wants me to do
return int(value)
The above exception (int() argument must be a string, a bytes-like object or a number, not 'tuple') was the direct cause of the following exception:```
I have got same error to this. however, the solutions on it are not working for me. https://stackoverflow.com/questions/63783517/django-heroku-raise-valueerrormissing-staticfiles-manifest-entry-for-s-c
settings.py
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'components/media')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'components/static'),
]
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
urls.py
if settings.DEBUG:
urlpatterns += (
static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) +
static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
)
What are the differences between ModelSerializer and HyperlinkedModelSerializer in django reast
did you use command python manage.py collectstatic ?
it's called the parallax effect
Hi, I need one help. I have to upload more than one image for a product, number of images is not fixed. How can I write a model for it.
class Product(models.Model):
name = models.CharField(max_length=100)
product_image = models.ImageField(upload_to='product_image/', null=True, blank=True)
price = models.PositiveIntegerField()
description = models.TextField()
def __str__(self):
return self.name
This is for one image per product , but I need multiple images for one product.
oh thanks 😄
When I try to use vuejs for frontend and django for backend
While using axis in vie to get images from the django server no picture shows up why?
Does every product have the same number of images
Then create a that number of imagefields
I am using django to build an simple app. By default time zone was UTC I changed it to Europe/Istanbul.
If I deployed that app on like Heroku. Will it changes date format ?
Yeah ig
ig?
I guess
😅 I didn't knew that shortcut. Thanks anyway
Also make sure to use datetime.datetime.utcnow()
Lol
What it will do?
Of you use that it won't give you errors when deploying in heroku
I'm creating a scheduling app with Django. As per most recommendations on the topic, the appointments (in my Appointments model) are stored in UTC timezone format. So my settings.py are set to TIME...
Follow the answers here
how do i make this into a page that works for all codes
@app.errorhandler(404)
def errorpage(e):
return render_template('error.html', error=404)```
flask
any django resource recommendation for beginner ?
pls help
i want help in mobile app development, can i get guidance? please ping me
Can I learn vue directly without learning bootstrap?
from my understanding python isnt best for mobile app devpmt
ok

yes - what's up?
yes. Vue is a frontend framework and bootstrap just provides premade css objects.
Because the initial state is username and password is "", the initial if statement is always false.
How can you check that the state equals a value (e.g. "username") without ever setting the state beforehand?
It's a catch 22
AS i told you, use datetime to get the last wednessday then just use something like f'http://exampe.com/dumsdad_{daytimeformatted}'
it does change in my code i have input fields which set the values
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
the code works
well, at least the state part of it
so the text in the input field does change for you?
you need to be more specific about this
ahh nvm fixed it
so what "didn't work"?
so basically the value of the input fields was not updating as i never set the value of input fields in the first place
right this makes no sense
Yes. You don't even need to learn bootstrap, it's just a separate css component kit
just know that if you're printing your state, state gets updated async.
so even if you "think" your state isn't updated because you console.log'd somewhere in an effect and it's a stale value, it just means that the state gets updated at the end of the event loop
but your code works
how do i open my flask project to LAN
i googled it but none of them worked ( i am using port 5000)
I wanna use a machine learning model in my android application
Technically speaking , I wanna develop an android app using AI software , and I guess python would do the AI part .....but I need guidance on how to merge Java and python to make the final product
Or if I'm wrong somewhere, please correct me 🙏
make your mobile application and interface with your ML model as an API
fixed thanks
okay thanks
Hopefully someone here has an idea. (Not related to just Python). I have a SaaS that is getting a wave of signups with disposable emails. Does anyone have any suggestions on how to put a stop to it?
I already have a few ideas. But, I wanted to see if there was something out there I wasn't aware of.
@app.route("/taskcreator",methods=["GET","POST"])
def taskcreator():
if 'uname' in session and session['uname'] == params['admin-user1']:
if (request.method=="POST"):
title=request.form.get('title')
content=request.form.get('content')
phone=request.form.get('phone')
img_file=request.form.get('img_file')
entry=Posts(title=title,content=content,phone=phone,img_file=img_file)
db.session.add(entry)
db.session.commit()
return render_template('taskcreator.html')```
it reloads taskcreator.html again when i submit form
surely problem is in last return statement
how do i add a .ico file as favicon on flask
any1 plz help
Check this out. You'll want JS to prevent the event handler: https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
Add an ID to the form and then add a submit event handler. Then prevent default on the submit event.
ok
Like any other html file.
it's doing it because you are not telling it to redirect to another place if the form submission is done
i did that but it didnt work
ok its reloading the same page
;-;
yes, because you are not redirecting it elsewhere
how do you add images via css ( i am using flask)
No... No it is not lol
thx it works now
you have it rendering the form again after submit.
this is my css
.u-section-1 {
background-image: linear-gradient(0deg, rgba(0,0,0,0.4), rgba(0,0,0,0.4)),
url("{{ url_for('static', filename='images/2236553_medium2000.jpg ')}}");
background-position: 50% 50%;
}
but it gives this error ```
GET /static/styles/images/2236553_medium2000.jpg HTTP/1.1" 404 -
and the file exits btw
No, the number is not fixed and it is upto user
What did you want your form to do after submit? Add an element? Redirect? Show a flash/notification?
can i see how your static folder is setup? if you don't mind
cool. here it's complaining about this? /static/styles/images
that doesnt seem to exist
so i guess the question would be why is there a get request to that location?
i mean i have put it wrong but i am not sure of the correct order
i tried many things but its not working
i'm confused?
the url for is wrong
{{ url_for('static', filename='images/2236553_medium2000.jpg ')}} this one
are you putting that in a css file?
yes
doesnt jinja2 work for html files?
did you try hardcoding the url instead of using url for?
man, i mean hard coding the url like /static/images/image-name
then idk, maybe use the style attribute for the element in your html
https://stackoverflow.com/questions/39579666/how-to-set-background-image-on-flask-templates/39579810
@jolly star maybe one of these can help you
i just checked the css file via dev tools
./images/2236553_medium2000.jpg this is the url in it
and its supposed to be ../images/2236553_medium2000.jpg
this is what i have in the file /static/images/2236553_medium2000.jpg
i am so confused rn
I'm accessing the current Wednesday, but also what do I have to do to access the links from previous Wednesdays? I mean, how do I set this up in a function?
@worn mural you think did I explain exactly? by the way, the example does not appear in the link you provided
Has anyone had experience using residential proxys with selenium? If you have how have you run them and where did you buy them from
Where should I go after "Wedge of Django"?
question, if anyone has experience with creating website, what is the typical cost for someone to create a website with subscription payments and referral systems?
Just want to get a general idea before i agree to pay someone a months income or something
It’s very hard to estimate a cost based just on that info.
If it was me I would scope out the details exactly what’s required, and then see how many hours you would think it would take. Add a buffer on top, and give your estimate.
Whatever they think the required hours are 3X it
Ahah yeah, thats the fun part of estimating
Hey, if anyone has the time to look my question in mango. I would appreciate it. I know you guys are busy so if you can't I understand. ❤️
oauthlib.oauth2.rfc6749.errors.MismatchingStateError: (mismatching_state) CSRF Warning! State not equal in request and response.
``` Umm What is this error? I am so confused.
ok it was browser issues i cleared cache and it worked
does anyone here know to deploy quart app on windows server? need help with this
@app.route("/taskcreator",methods=["GET","POST"])
def taskcreator():
if 'uname' in session and session['uname'] == params['admin-user1']:
if (request.method=="POST"):
title=request.form.get('title')
content=request.form.get('content')
phone=request.form.get('phone')
img_file=request.form.get('img_file')
entry=Posts(title=title,content=content,phone=phone,img_file=img_file)
db.session.add(entry)
db.session.commit()
return render_template('taskcreator.html')```
when im hitting submit button on form it reloads taskcreator.html instead of sending post req
sad life
im 101% problem is in last return statement
<html>
<body>
<h2>Add a Task</h2>
<form action="/taskcreator" method="POST">
<label for="title">Title</label><br>
<input type="text" id="title" name="title" ><br>
<label for="content">Content</label><br>
<input type="text" id="content" name="content"><br><br>
<label for="phone">Phone</label><br>
<input type="text" id="phone" name="phone" ><br><br>
<label for="img_file">Image</label><br>
<input type="text" id="img_file" name="img_file"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
this is html file ping me plz when u solve or u wana try to help
Is it getting to the db.session stuff?
what u mean sir?
its not sending req to db
its just simple reloading
but you're trying to submit a POST request no?
Hey guys, what's the best practice for uploading images along with other form data? Should i upload right away after user select the image or after submitting the whole form?
so you want the stuff inside of if request.method == 'POST' to execute correct?
yes
@outer apex
sorry for late replies
so, right now, when you submit the form, it's not reaching the stuff inside if request.method == 'POST'?
have you double checked if all your conditions are met?
yes
so what should i do
and i have made this like 10 times so im sure
i am not wrong in syntax
but this time if working with 2 if in post req 1st time
if 'uname' in session and session['uname'] == params['admin-user1']:
if (request.method=="POST"):
these 2 instead of 1
so im damn sure
problem is in return statement indent
or 1 more return needed
but i have tried and cant fig, out
so all the stuff inside of that request method thing is running?
is correct but not running cez of last return problem and when i changed last return to xyz.html
it showed xyz.html not found
shows prblm is in the last statement for sure
So do you want to redirect to another page or render a different template, if the method is POST?
if u dont mind
can i share screen
@native tide You can put office address or the contact us below. Better than side by side
At the point of when user clicks submit you send the data to your backend. And after validating you can upload it to your storage.
i have a gridview it has some rows when i update the row it updated succfully i need to change the background color of update row
oh It looked much better. thanks
@peak lava You can use <script> tags
i did but it wont work for some reason
Can you share the code?
me?
Yes
well its reallyyy long yk
Just the one tag
the script one
<script src="main.js"></script>
And what's not working?
its as if ive never included it
wait
Not Found: /home/main.js
[23/May/2021 15:14:39] "GET /home/main.js HTTP/1.1" 404 2481
elementary question, getting this error:
The current path, notify/1/vote/, didn’t match any of these.
return HttpResponse("You're voting on question {}.".format(question_id))```
urls.py
```path('<int:question_id/vote/', views.vote, name='vote'),``` #urlpatter
@fallen kindle try path('notify/<int:question_id>/vote/', views.vote, name='vote')
causing the same error
NB: http://127.0.0.1:8000/notify/1/ returns a page
The fucking problem was with the me forgetting '>' in '<int:question_id>', FUCKK
What http status code should I raise, when my API is dependent on external api and external api does not answer?
500
this is how i run my website:
app.run(host='192.168.2.188', port=5000)
```because it's like this, subdomains do not work
how do i fix this?
What kinda website do you need? I'm a freelance web developer.
Yes there are many servers
Btw in this server these things are not allowed u can dm
No self promotion allowed sorry
Refer to Django's docs on how to manage static files.
https://docs.djangoproject.com/en/3.2/howto/static-files/
Mind if i ask is it better to use Lets encrypt or use ssl provided by web hosts , I host my website on pythonanywhere and it has free SSL or I should encrypt it by lets encrypt
If they take care of all of that, then it should be just as good as lets-encrypt. Just verify by trying to connect to your website at port 80.
how to do that
http://mywebsite.com -- the whole idea is to force this over to https so that uses are not accidently sending stuff in the clear.
Create a website with Ownwebsite today. 200+ beautiful templates to create anything with the easy website builder. No coding required. Web Hosting included.
so it would be website.com:80 but that shouldnt be necessary. just do http:// and test that you cant load this without it switching to https.
If it does that, then it works
Either way
oh it did switch to https
if the say they provide SSL, they most likely do.
yes they provide a free one
so let's encrypt is useless if my website works fine with SSL of the web host
right.
cool thanks
guys i need help with foreignkeys in django
so i want to send a foreignkey in a form
<form>
<!--Form stuff-->
<button type='submit'>Submit</button>
</form>
but i want to add a foreignkey
in the form stuff area
so how would i do that
can someone help with django?
this is my LoginView, but despite of that I m getting redirected to http://127.0.0.1:8000/accounts/profile/
Hello everyone,
There I present a simple Python based framework for creating lightweight websites. The creation of the website is easily done using Markdown. I hope it will be useful for you. 👨💻
Link: https://github.com/dennishnf/framework-light-website
Would love some help in #help-lollipop regarding some auth issue sending me an anonymous user back utilizing JWT!
Am I right in thinking that Flask session data can not be viewed, unless the malicious user know the app secret key?
are you saying you want to expose a foreignkey for a database table in a form?
hi I asked a question yesterday in the help channel and didn't get any help. Can someone help?
My file tree looks like this
https://imgur.com/a/DB02hHb
init.py
init.py from the flaskapp folder
https://paste.pythondiscord.com/ezikihoyig.pyfrom
These 2 lines are not working from the above file and I don't know why
flask_sqlalchemy import SQLAlchemy
from flaskapp.users import users
config.py
https://paste.pythondiscord.com/zugemorazi.properties
init.py
init.py in the users folder
https://paste.pythondiscord.com/icopohadum.kotlin
forms.py
https://paste.pythondiscord.com/lurozitine.py
routes.y
https://paste.pythondiscord.com/tisagafaju.rb
models.py
https://paste.pythondiscord.com/utusinuder.py
The error here is
from flaskblog.users import db
If you don't want to go through all the files just look at the errors
The question involves flask
Can I order VPS from one provider, and DNS + certificates from another one?
there should not be anything against it?
oh nvm, I can
just checked to be sure
Can anyone advice good resource to read about DNS?
I need to fill this blank in my knowledge (or lack of it)
oh yes, there are books for that from O'Reilly. I wonder if there is something a little bit shorter to read though
preferably interactive
what is HTTP code that y'all use in login to check if email doesn't exist?
200 with exists - true/false in response
401?
404?
500?
400 sounds pretty good
401: unatherized. if im right
404: page not found,
500: server error.
200 should only be for good requests, and 500 should only be if the server screws something up more or less
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes: HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes: Informational responses (100–199)Successful responses (200–299)Redi...
yes so telling the frontend email doesn't exist after processing it is a good request?
if it's for login then my interpretation is that the request is bad since the server got bad information
It's like a 404: the search query was correct and the request is well formed, but nothing could be found, so an error occurred
Hello
This happends everytime I enter a new div or item into my container
I'm using grid.
my code
<!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>Website</title>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Josefin+Sans:ital@1&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="container">
<div class="name">
<a href="#">Logo</a>
</div>
<div class="box one active">
<a href="#">Home</a>
</div>
<div class="box two">
<a href="#">About</a>
</div>
<div class="box three">
<a href="#">Shop</a>
</div>
<div class="box four">
<a href="#">Info</a>
</div>
<div class="logos">
<i class="fa fa-twitter"></i>
</div>
</div>
</body>
</html>
Everything moves upwards when I add a new div.
Not just a div. If I add any new icons or text.
why does this happen?
You can use 422 for failed validation
how can i add sign up page in my flask app
ik to make login panel and other stuffs by flask
!rule 1
1. Follow the Python Discord Code of Conduct.
a form. i want to make a system where if someone makes a post on my website, it has a foreignkey to the user
hey could anyone help me with making an event listener that updates a buttons position upon scrolling?
That’s not the best way to do it then. The data through the form can be edited by user potentially allowing a user to make a post impersonating someone else.
You should get the currently logged in user through your server side code.
how would i do that?
and how would i attach that to the form data
and save it
heh
i've messed up my database for django
You don’t submit it with the form data. You get the value from your auth system and insert into the db or wherever you store.
seekaona
wow, i didn't know about this. ill try and look around for some videos or something
just make a route that takes a user's details and adds them to a database or whatever you are storing user details in
@thorn igloo oh
But how
Till now have made a class for them
@thorn igloo i want ur 5-10 mins when u free ping me will ask all questions of that and u can guide me within that time
Out of home rn
Will brb soon
i'm free, lets talk
Sure but I'm out rn
Out of home lol not on pc
Buying some groceries
@thorn igloo add me as friend bruh
done
oh
@thorn igloo I'm back
Hi, How can I develop a graphql api with django and neo4j?
Can someone recommend Domain provider?
I've used Namecheap before, they're good
someone please help me fix my db in django
its so messed up and i dont want to restart my project
Highly recommend Namecheap
What's the problem? Migrations?
i created a custom user model mid way through the project
big mistake
i deleted the db and all migrations cause i thought that would just reset everything and would function normally afterwards
Nice, thanks.
I was feeling like my local domain provider was reaping me off
plus he had broken web interface anyway
If you deleted the DB then you're already starting with a clean slate. Unless I am not understanding something?
well it just doesnt work
i run migrate but it doesnt pick up any models or anything
Wow.
namecheap has SSL certificates ten times cheaper than my local provider
I was definitely reaped off
Uhh. Through hosting maybe. Don't go with their hosting though, please
Make sure you deleted all migrations folders inside all apps for your project.
Also side note, SSL certificates are free to get
nah, I go with german servers https://www.hetzner.com/
As a leading webhosting provider and experienced datacenter operator in Germany, Hetzner Online offers professional hosting solutions for a fair price.
they look nice for testing period
Yeah I like Hetzner they are really cheap and consistent. Only downside is that the german feds require you to bulletproof your server or they will take it down.
If you're running ubuntu for a server you can get a cert for free by following this guide. It also has auto-renewal: https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx
do you mean self signed cert, or really real certificate?
It's a real certificate.
wow
I use it for all my websites and clients.
that's nice
what are the rules to choose domain names in certbot?
some limitations?
shrugs I thought to setup with Nginx anyway
I thought to make redirect with Nginx tomorrow)
what protects me from other people taking my domain name for themselves?
Uhh, you own it?
Think of it like renting it. Once you rent it for however long nobody else can rent it for that time
I'll get domain name from namecheap then
and will try to get certs from cert bot, or perhaps from namecheap too
it also has openwithGuard
why is it requiring often cron renewal?
are they really fast expiring?
what server are u trying to host on
german Ubuntu 20.04 VPS
They always expire after a few months. A certificate needs to be renewed. Thankfully, certbot will autorenew the cert for you
oh no , dont know in linux
but i have a video that might help made by corey he's so good
nice
and he also he bought a domain from namecheap
so give it a watch so u can understand everything
let me paste the link
In this Python Django Tutorial, we will be learning how to deploy our application to a Linux Server from scratch using Linode.
If you would like $20 of free credit towards a Linode account, then you can use my link here to sign up:
https://linode.com/coreyschafer
We will be covering the entire deployment of a Django application. This includes...
In this Python Django Tutorial, we will be learning how to set up a custom domain name for our application. We will use NameCheap as our domain registrar and Linode to host our server. Let's get started...
If you would like $20 of free credit towards a Linode account, then you can use my link here to sign up:
https://linode.com/coreyschafer
B...
he bought name cheap and added it in this video
I hate videos
99% of water for 1% percent of useful information
without ability to skip water
I am a guy of text (+ pictures) tutorials and books
thanks anyway.
ive deleted all migrations and it still broky
Corey Schafer is one of the best
If you really prefer articles here: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-20-04
I don't know if they include certbot for that though
Corey Schafer added a video for certbot and lets encrypt
I already have Django with postgres and Gunicorn, packed into docker
I already even used Nginx, but I am going to make it into docker-compose for happiness
DId you specify the custom user model in the settings file? If you did... Try running python manage.py makemigrations APP_NAME for all applications. Enter it one by one
if that doesn't work then did you use abstractuserbase or what class did you inherit from for the custom user model?
mind if u tell more about nginx like is it like pythonanywhere or heroku cause i dont know it very well
i inherited from abstractuser
OOooOo. If you're using docker I am not going to be helpful
@modest scaffold try to clean ur migrations files Dont delete the inital file and try to migrate again
it is Linux apt-get application, serving as web-server, can be used as redirect server for just ssl certificates
i deleted my intial file im assumign thats bad
oh im windows no need haha
No it's not
Not if you created a custom user model halfway through 🤦♂️
i deleted all of em
Do what I said Amaz
k
Then after run the migrate command
those free certificates were really useful)
and namecheap helped a lot
every bit helps)
oh i think its working
ok now do i run migrate
Yes
hope it works
i think its working now
awesome
thanks you so much magic
oh btw mind if i ask what's the importance of gunicorn
👍
No worries dude happy to help.
I just read an article that it says to use gunicorn to improve ur website performance
i think gunicorn puts your project on an actual server
and is serving ur static files on AWS3 also helps ?
It's extremely important when deploying a server as it creates workers/threads for your server.
rather than the test server
oh even for deployment ?
i have done this but its a bit of a pain to setup
It can, yes. There is a lot of debates on that but using a dedicated service is helpful.
mind if i ask how to use gunicorn , i installed it now what
Especially for deployment. If you meant development, then no.
yea im talking about deployment
i think generally serving static files from a dedicated server is better
Errr, depends on the service. If you have multiple servers then it won't work anymore
what's the most recommend web host , i find pythonanywhere some features are still not occured like 1i8n
is digital ocean good ?
didnt use it before
DigitalOcean, AWS, Linode, Vultr are all pretty good.
Heroku and PythonAnywhere are PaaS
but pricing is bad in heroku
25$ per month
Because it's a PaaS meaning you don't have to worry about devops
so digital ocean is better than pythonanywhere and heroku ?
It depends.
on what?
What you value, the project requirements, and probably your funds
I need something better security , rapide performance and less price cause its an eCommerce website
and ofc easily to handle
Did you code the eCommerce site? And assuming it's a Python backend?
Will it actually be used by other people
ofc just building a website for a non profit organization that later a team will control it