#web-development
2 messages ยท Page 185 of 1
Guys, I got a problem with flask. Could you help me If I sent the Code and error here?
I just reset the password for lanesflow user. Copy/pasted password....same error.
Going to try and add a new superuser.
https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e
Please?
I want to be just coding too, or being just devops
but in reality I fulfill backend/devops roles, not the mentioning architect and security in addition now
a bit too much for one person, I want to fulfill just one role, not everything
๐ฑ
I just created a new superuser...I get the same error....there is a problem with authentication
Something doesnt make sense...I create a new user...validate superuser...and get:
FATAL: password authentication failed for user "lanesflow"
So, let me get this straight...no superuser in this DB can sign in to the front-end????
How is that even remotely making sense?
u know, for time while u develop, it would be just easier to have temporal postgresql raised at you every application start
with auto user creation
That won't work. There are parts of the application that would fail
Is this an issue with authentication with the database, or authenticating as a Django user?
put initial data into yml and load from it.
configs should be configs
not the data in database outside of your code revisioning
I am going to sign up through the front end, give superuser rights onto the back end, and try that way
Because this...what is happening...is making NO sense
At all
So can your app connect to the db or not?
checking with console client would be a solution
Well I am unclear if the auth error is connecting to the db, or if they have a login system and just cannot login (e.g. to admin app)
or if firewall got enabled by accident or something
better start with pinging by telnet ipaddress port
Oh wait...it's the DB account password that is failing!
I removed quotes...I will try with double quotes
No...it's the single quotes that I didn't remove from around the password
Apparently I can't log in. 500 Server Error has gone. But no account can login. That is progress
When I am creating users to enter the front-end, do I need to create users in a different table?
super admin or regular ones for frontend access?
Front end access.
That's the bit I need to fix. the front end superuser account is the one who's pss I need to change
I've been changing super admins
This has been the central problem. All of the sudden, the application superuser password started not working. I suspected this was the issue. However, I just created a user on the front end that doesn't show under /du. Which shows me there is a user table...and it's THOSE users I need to change. Ordinarily, I'd go in through /admin. But, I don't have a front end superuser to access /admin. Catch 22
That's the confusing part. I create an account TestAccount on the front end....but that does NOT show in /du. Even though i can log in AS that account.
I am reading the documentation and whatever this is about is NOT clear...at all
If I create a user on the front-end, (TestAccount) where does that user display? It's not showing under /du
front end created user go to the table Users within your LanesFlow database. They are purely data-record in table
/du shows users of the database to make connection to database
those are two separated entities
Ahhh...OK. I'll look up how to access user table.
And how to change password for users on that table
the best way to access it python manage.py shell then it goes for few more commands..
or using your django admin interface
Because THAT is what I need to get done
But I can't get into admin. My superuser is locked out
python manage.py shell works without superuser
Even though I have a password manager, apparently, the password stopped being accepted yesterday
And where exactly do I run python manage.py shell?
in container with _web
Your database table might have been wiped
this all comes back to....that user's password suddenly not being accepted.
And that REALLY concerns me.
And to run that command you can use docker exec to launch a shell in the running container
a) either you tinkered with it b) someone accessed the root user perhaps
next time better changing default postgresql password to something complicated or making better setting for allowing who can connnect at the postgres config ๐ค
and better disabling ssh access with password, id_rsa is more than enough
Yeah part of this process will be setting up the volume properly and also setting up an automated backup solution
And how do I find the container? I am in the directory where the container was launched
docker ps
docker exec -it container_id /bin/bash
And you can get the ID from docker ps
IIRC it's the very first value in the table of the command's output
Ahj ha!
I finally have the python console inside the container!
OK. Thanks guys!
SO now....I get to change the password for the superuser....
๐
I apologize for being so dense...your collective patience....is appreciated
if u think we were any different when starting, you will be wrong ;b
OK. So, now I can run python manage.py createsuperuser <name> and should get a prompted for a password?
Nope...that's not right
I am taking EXTENSIVE NOTES.
Oh it just occurred to me there's probably a shortcut to get into the shell with docker compose and sure enough there is docker-compose exec service_name /bin/bash
service name is easy to remember so no need to look up IDs
Nice.
So, it turns out, I'm in the console >>> But I'm not using the right command.
I think it should be possible with docker-compose run, but did not try it yet
docker-compose exec looks cool too
Yeah that's true if you don't have a running container yet; you can override the entrypoint and start one
I don't think that the console is where I can create a superuser
Sorry, I've only messed with user stuff in the shell a couple of times and it's not something I remember well
disable python
OK. I just need to get the superuser syntax right now...
FINALLY!!!! ๐
I'm finally able to login as a Superuser...
OK...now to turn debug=True off! LMAO
And check this...NOW...profile pictures work!!!
YES! Finally...all core functionality..>TEST SUCCESSFUL....
I can only assume that there was something in those single quotes that was getting in the way.
And you sir...thank YOU! That find on single quotes...outstanding!
This has fixed another issue with profile pics and article images in /media that could not display. I am VERY grateful for your help, sir!
You're welcome
While I was debugging I took the liberty of cleaning up your Dockerfile, if you're interested
Sure. Let's have a look ๐
I need to push a new change up to turn debug off anyway ๐
You know...this Discord...without it...there would be no lanesflow
Improved layer caching and removed installation of unnecessary packages https://paste.pythondiscord.com/lojazajoqa.http
Since you said you're taking notes, I find that apt-get snippet handy
I will take it for a spin right now ๐
An overkill solution would be to create a separate build stage for psycopg2 that dumps out a wheel. That way none of those build deps are in the final image anyway. But the size difference is trivial I bet so meh
Frickin LOVE Docker for what it is. Just had to bang my head against a wall for a couple of days to get here...
The web app...on the front end...is fast...so not concerned right now.
But I do plan on taking a CI/CD course...and building out a proper pipeline
As someone who has built word press sites in the past...shifting to Django....holy crap...FASTER!
I have somewhere docker-compose for wordpress
my eye did not notice the speed difference
I think it could be seen only with performance testing
I'm talking about the overhead that comes with WordPress core and using plug ins. I didn't do WP dev...just pieced together sites.
Your revised dockerfile runs like a charm! TYVM
oh my goodness....SUCH relief. Very grateful!
Ok. Now...off to learn about CI/CD, pipeline, testing, staging...so much to learn!
then load balancing, security, hammering microservices...
yeah, my learning queue is a long one too
it would be great to have 48 hours per day ;b
It's not so much about speed as it is about reducing the size of the image. It's not something to be concerned about in most cases though.
I also noticed 15 steps instead of 20 on the container build. So your clean up made a difference directly
Oh yeah that last comment was just about the overkill build stage thing I mentioned
I'm going to be curious about building an automated CI/CD pipeline incorporating docker container.
You know...where it's built in the dev VM, staging VM, tested, approved, deployed
I already have dev work to do for v0.2
They key to writing a good Docker image is to understand how layering and caching works. If you're not mindful of that you can end up with slow builds and/or bloated image sizes
Do you recommend any courses online for Docker? I'd pay for a good course
I learned by doing and by being around smart people, not from any course. So I have nothing to recommend besides practice.
That isn't to say that courses aren't valuable... it's just not the route I took
I admire that learning style. ๐
It's not my strength. I find I learn by being shown the initial stages, and then extending out
That said, this Discord community is filled with smart people!
this.
after many months of usage I think to read a book though just in case to check what I miss
Well, as a solitary developer, I'm not currently around smart people...or any people when I work ๐
So, this Discord will have to do.
guess where I learned
my micro company is having me as a single dev
So guess what...that superuser...500 Server Error again...password apparently doesn't work again!
I'm going to do a reset behind the scenes...
But I'm puzzled...Even more so because when I change the password in /admin....and then try and log in, I get a 500 SE again.
How can that be happening?
Whoa....When I change use the resetpassword link in /admin I now get a 500 SE. Any ideas anyone?
The other Superuser account I created is fine
I can user /admin reset password for another account. But THAT superuser...trying to change in /admin...500 SE. What on earth...!!!
OK. I get 500 Server Error when trying to do ANYTHING with that user account.
I think i'm going to simply delete this User...there's clearly something wrong with it
And now profile pictures and article images stopped working.
OK...this can't be right...how can changing a superuser's password (or making a change to anything related to that user) in /admin throw a 500 Server Error? I'm finding nothing online about this that directly relates
What is as mystifying...media images were showing. Now they don't...
Which is a revert to what was happening 2 days ago.
Huh....SO....[Errno 2] No such file or directory: '/app/web/media/profile_pics/LanesFlow_twitter.jpg'
Media files not showing ARE the core problem...
How do ensure media files work in Docker? They're not showing up and their absence is making it impossible to update users
I would just do unit test
it is possible to write unit test that checks media file existence
Hmmm....Well, I did manage a fix. I submitted a new profile pic for that user. It saved. And then was able to reset the password. So that's progress
in your case, you would be better checking against already deployed server I guess
if you would work in linux, it would be much easier, since it woudl catch problems like that even in local development without docker
That will take some learning on my part.
Well, I put a workaround together
I'm going to build a CI/CD pipeline all in VM Linux
anyway, u solved the intial docker deploying problem, I'll be not needed tomorrow then
the problem is not solved. I got rid of the 500 Server Error. But pictures do not show at all.
Either profile pictures or article images. They were...a while back. But no longer show
Ok...the problem keeps coming back...there's something not right with media...
Yes...docker deploy solved. Much gratitude.
Just need to work out why media is such a problem
At this rate, I'm just going to remove profile pictures...this is a nightmare
That said...I may have found what this is about...
Django documentation has MEDIA_ROOT for upload. So...
image = models.ImageField(upload_to='profile_pics', default='profile_pics/default.jpg')
Should go to media/profile_pics/ correct?
How do I check that?
What I SHOULD have had was MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
What I had...
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')```
A missing slash...omg
That happens a lot trust me
I have literally just spent the past 2 days dealing with 500 Server Errors because of that slash ๐
It was a nasty one
that's what distinguish a true programmer from other people.
LOLOLOLOLOLOLOL
we insert incorrect password until the pc agrees
OMG...I laughed out loud at that
2 days ...on a frickin SLASH! LOL
I can laugh now...but bruh...
And it was causing the 500 Server Errors too. Because of a signal...causing the profile to save...but when the profile pic wasn't uploaded correctly....hosed. And it only happened when the picture was changed.
Which apparently I did.
Nasty little bug! ๐
Although...interesting...I just turned debug off...and profile pics don't show again...
So...need to dig deeper
Is this correct? STATIC_ROOT = "build/static"
eh, it should be
technically you could shorten to one folder name
it will make build folder creation as not needed ;b
i ilked that approach though
build is build, can't be mistaken for anything
So better to have STATIC_ROOT = "static/"?
The end needs a slash?
The missing slash at the end would explain it not working in Prod
I'll try STATIC_ROOT = "build/static/"
So if that fixes this..
The missing slash at the end...makes me think this is the causew
Expanding this...
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATIC_ROOT = "build/static"```
Documentation is suggesting...
STATICFILES_DIRS = [
os.path.join(BASE_DIR, '../frontend/build/static')
]```
u already have static folder busy with something
ah yes
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
you should remove this one then
otherwise it will loop itself to death
trying to take from static and to build into static
wait a second
u can't remove it ๐
nothing will be collected then
So...replace
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATIC_ROOT = "build/static"```
with ```
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATIC_ROOT = "build/static"```
emm, is it still working now?
be sure you saved everything
before experimenting ๐
No. When I turned debug off...it broke again
it's working in debug...trying to work out why it won't work when debug is off
that's what VCS is for ๐
quick catching on ๐
my previous colleage did not commit for weeks
even during heavy refactorizations
thankfully we fired him
git and testing is not needing for frontend, it is not like backend
his famous words
Documentation says...
@ionic raft STATICFILES_DIRS should point to the directories which have your staticfiles. STATIC_ROOT cannot be in STATICFILES_DIRS.
STATIC_ROOT is the dir where your staticfiles are collected when you run manage.py collectstatic
Yes. I get that.
By the way in production you need a proper server to serve your staticfiles
Using Nginx for that
Ok nice.
The problem appears to be the uploaded files...profile pics...article images...
It collects just fine...1490 static files.
I currently have STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) STATIC_ROOT = "build/static"
But uploaded images do not display with that setup in production. Work in debug
Unfortunately, it is a slow learning process. When you get errors, start with the last one, copy/paste into browser...and start researching what it is about.
The worst bugs are when you don't get an error...but it doesn't work. Just like I'm having now
nxinx conf doesn't have location for media....
are u sure?
location /static/ {
alias /app/web/build/static/;
That is there. but there is no location for media
I don't know how u store media
This has a suggestion...
there is a media directory in the root
how is it called exactly?
I see
But this makes sense...now I just need to get it working...
I tried
root /app/web/build/media/;
}```
settings.pyMEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
u need to modify docker-compose in order to work for that
Ahhhh TYVM!
build: ./nginx
volumes:
- static_volume:/app/web/build/static
- media_volume:/app/web/build/media
- ./ssl:/app/web/ssl
ports:
- 443:4000
- 80:3999
depends_on:
- web```?
version: '3.3'
services:
web:
build:
context: .
dockerfile: dockerfile
volumes:
- static_volume:/app/web/build/static
- ./media:/app/web/media
- ./temp:/app/web/data
expose:
- 8000
env_file:
- ./.env.prod
# - ./.env.${mode}
nginx:
build: ./nginx
volumes:
- static_volume:/app/web/build/static
- ./media:/app/web/media
- ./ssl:/app/web/ssl
ports:
- 443:4000
- 80:3999
depends_on:
- web
volumes:
static_volume:
try something like this
u need added to nginx and web
Right...was just realizing thattoo
tbh it is really bad
Ok...that makes sense
Well, the profile pics are resized to no more than 250px. Article images are for writers only
no load balancing is possible any longer
I did wonder about storing images off to another server.
u will go only with buying more powerful servers then
That's important. to consider.
I could remove profile pictures...
And use image storage server for article images
there is a service which generates them automatically
based on any input from database
Yes...gravatar
Currently, profile pic in profile model.py is image = models.ImageField(upload_to='profile_pics', default='profile_pics/default.jpg')
i am sure it should be possible to store in db
may be even in built thing exists for that
you know, now that I think about this...I'm inclined to remove profile pictures for now...and have this built in when I can hire a developer who knows what they're doing ๐
I'll see what I can find w some research ๐
type="submit"
Not action attribute...type
Initial research is showing the approach I've taken. Use of media...
if you will store media in db, u will have another round of problems with XSS attacks though, although if you would keep them out of db, it will be still a problem too
you know, you are making a convincing case to simply remove profile pics!
I think I'm going to remove for now. I'll store article images on another service and link to them. And I'll simply remove profile pics
This is not a big feature...and it's more trouble than it's worth to be honest
EDIT button is in loop , i want store the value of every domain and retrieve in the function of view.py button in HTML ----- .<td> <button type='submit' class="crud" name="id" value={{ e.domain }}>
<a a href="/eminfo/show/"><strong>EDIT</strong></a> ------ and ---- view.py def getemployee(request):
e=Employee.objects.get('id')
return render(request,'show.html',{'val':e})
That's a whole different bag. You might want to break that down in a help channel. #โ๏ฝhow-to-get-help
But whatever the case, your button tag needs a type
okay thanks @ionic raft
Any python expert
I've removed profile pics. When you identified loss of load balancing....that's no good. They're not important enough for that cost. And as for inserting into DB. That's a problem for later.
plus by keeping it stateless you can allow for yourself destroying this server at any time and rebuilding from scratch)
it is quite good to have
no attachments, easier upgrades
possibility to have two versions running at the same for thorough checking before making the main one
hello, can you help me with a django problem?
just ask
I need to use can_mark_returned permission and PermissionRequiredMixin, to check if a logged in user is a librarian and allow them to access a template that displays all books that have been borrowed
I'm sold. Removed pics ๐
I'll use an external service for article images.
Hello, is there anyone can assist me with setting django source website form github. i am stuck at:
4. Add export DJANGOPROJECT_DATA_DIR=~/.djangoproject (without the backticks) to your ~/.bashrc (or ~/.zshrc if you're using zsh, ~/.bash_profile if you're on macOS and using bash) file and then run source ~/.bashrc (or source ~/.zshrc, or source ~/.bash_profile) to load the changes.
I added the line: export DJANGOPROJECT_DATA_DIR=~/Desktop/website/site-main
(this is my website folder path) at the end of the .bashrc file.
But I get nothing beside: 'source' is not recognized as an internal or external command, operable program or batch file.
I changed the command to set for windows but nothing happen.
Source code to djangoproject.com. Contribute to django/djangoproject.com development by creating an account on GitHub.
guys u know there is in css :before and transition,
does anyone know how to make the after I hover the mouse still be there that transition
error ?
urlpatterns=[
url('employee/',views.employee,name='employee'),
url('page/',views.retrivedata,name='retrive_data'),
url('page/',views.count_data,name='count_data'),
url('show/int:id/',views.show,name='show'),
]
does /show/3/ not work?
Hi! do you think it's hard to show an interactive tree (like jstree) in django?
Hey guys, im trying to build a simple python requests bot (real simple, no threading...) for logging in into a site. I'm unable to make my post request work, if someone could help me i would really appreciate it.
Hey @rigid anvil!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey, does anyone know a smart way of sending data to a django channel (websocket consumer) via DRF?
you can send a message into the channel layer (im a bit rusty with it)
Hmm I have to DateFields in django and one of them is returned as string and the other one as a datetime object,
any idea what it could be?
Hey @opaque rivet now I'm getting this error:
GET https://bucket.s3.amazonaws.com/static/main/base.css net::ERR_ABORTED 403 (Forbidden)
Looks like an ACL problem
weasyprint.HTML(string=html).write_pdf(
response,
stylesheets=[weasyprint.CSS(settings.STATIC_ROOT / 'mystatic/css/invoice.css')]
)```
i have my static files in static folder so i should do BASE_DIR / 'static/mystatic/... but in production collectstatic will use STATIC_ROOT so i will need STATIC_ROOT / 'mystatic/... what should i do?
Hello , i have a site where i display webscraped data that i gathered from a python script. Is the web scraping process then also considered a part of the backend?
if it happens on the remote, it's the backend.
What do you mean by remote?
on the server
But there's no rule that says your backend can't be a frontend for another service.
Atm i gather the data into huge csv files and then upload them manually to the database
Oh its only backend if its an automatic process?
I believe so.
heyo homies!!! I've a quick question...
in node js you can render a static file like this exemple:
app.use(express.static('public'))
how to do it in flask???
that's not rendering
that's just a static file HTTP server
this is your answer
https://stackoverflow.com/questions/20646822/how-to-serve-static-files-in-flask
as a side tip: using Nginx as a server for static files is more responsive
generally speaking
I'm coming from building full-stack apps with Node/React (REST API with Node, Client app with React, JWT for auth) and I'm wondering if I can get some input from the python community.
-
The only 2 frameworks that anyone talks about are Django and Flask, are they the only ones worth using or are there others that would do great?
-
Anyone have any recommendations for me to get up to speed and productive quickly with a python backend? I saw the Django REST Framework which looks promising but I'm not sure.
guys can u suggest some flask projects :3
I don't know flask (we are supposed to be making a group project using python) but we are supposed to use flask which hasn't been taught to us

Also if anyone has used this https://www.django-rest-framework.org/tutorial/quickstart/ I'd love to hear feedback and criticisms of it.
Django, API, REST, Quickstart
this is good thing to use
if you are making rest api ;b
blazingly fast speed of development for sure
but takes a bit of initial learning curve
some people say that flask is more beginner friendly
people usually choose between django or fastapi though
Lol I actually just stumbled across fastAPI on github. This is so cool. Why haven't I heard about it before?!?
FastAPI is growing in popularity from what I've seen.
You might also want to try Starlette, on which FastAPI is based
Hmm looking at Starlette I'm not sure. I think FastAPI (from the 5 min I spent on both of their documentation pages lol) provides just enough abstraction to be easy to use but not enough to be half black-magic like Django often appears to be
im gonna do yet another clone project, this time twitch. I've picked out the stack, how does this look?
NodeJS, NextJS, Express, PostgresQL+Prisma, MaterialUI+StyledComponents, Redux, Stripe, RNative+Expo for mobile app.
also some other react based library pretty small
just picked out the tech stack so far, next i gotta do the overall architectural design
Am I missing anything crucial?
Personally not a fan of Next or Redux. With modern react you can do all the state management really without the use of any external libraries. useContext and useReducer are both great if state becomes to complex for a simple useState hook to handle (though context isn't exactly state management). Next is more of a personal quirk but I just don't find it necessary in most cases. I also dislike pre-styled components in general but that's another personal quirk. Other than that it looks good.
hmm interesting, im honestly comfortable with skipping out on next, and as for redux, it's just become second nature to use it lol..
but you are right, i can probably skip on redux too, dont think state will get much complex for this project
Lol yeah like I said some people like Next maybe you will too. I think it's especially good for SSR if you need that, that's probably the only time I personally would use it. But Redux is honestly unnecessary and can have negative impacts on performance as well
Fastapi vs flask vs django. I feel fastapi can do almost everything in lot less code!
Hi guys. Got a view function for a recipe creation form here. When something isn't valid in either the form or one of the formsets I have to render the form again including the error message. In the spirit of DRY I'm wondering if there's a way to create a helper function that I can call when I need to rerender the form using the code I have to repeat. Does anyone know how I would go about doing that?
form = RecipeForm()
iformset = IngredientFormSet()
mformset = MethodFormSet()
return render(request, 'recipes/create_recipe.html', {
'form':form,
'iformset':iformset,
'mformset':mformset,
'error_message': "Oops! A form isn't valid."})
Otherwise I have to reuse this same code in 2 places, which I've been led to believe isn't ideal ๐
any way toi fix it?
nvm i solved it
cries in happiness
kinda conflicted, should i store dark mode preference in the db or cookies/localstorage?
generally settings like that can go into db
unless its purely a static setup
because bear in mind if a user clears their session it'll remove the preference
ah true, yeah ill store it in db.
That makes complete sense. A dark mode for my web app would be a nice touch down the road
is there any html, css, js discord server??
Hey guys, how do you debug Javascript in a django project? Let's say my script isn't working and I wanna debug my JS script, how do I really do it (to see if certain variables are getting populated and all)
In the case of Next, I personally love it. The image and script optimization, filesystem routing, and an easy way to create an API are all really amazing. ISR is very very nice too. I personally see no reason not to use Next for any app that could be pretty complex. (Not trying to argue with you, just stating my opinions)
!code
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.
If you guys were to build a website that served as a news site plus a forum would you look into building the forum from scratch or some other means?
I've been digging into website making and have been looking at react plus django. A lot of what I am reading though is saying making a forum from scratch is a bad idea.
Hello there decided to upgrade my web interface from simple html and text files to a decent gui and possibly a database what would you guys day best way of doing that would be. Currently it's all on flask but not sure what it's capabilities are
Well the ui side is purely down to html and css
No backend framework is really gonna affect how it looks design wise other than render some html templates
But generally yes, flask is fine to use
just checking here before posting an issue on github, in the context of FastAPI, does anyone know if there a way to set the order of request validation for the query vs body parameters? i want this because query validation does IO but the body validation does not, so i want to avoid doing the IO if the body is not valid
reading the body in itself requires additional IO
is the IO you're doing really expensive?
no but's it's the diff between simple string validation on the body and hitting a database for the query
maybe ask in https://gitter.im/tiangolo/fastapi first
thank you
i forgot the gitter existed
fastapi has an official discord now actually, from gitter https://discord.gg/TNgAnEB6
oh right
Im new-ish to Python, not at all new to webdev. Could someone give me a quick comparison between FastAPI, Starlette, and Flask?
I can't help you with comparisons, but Flask is a nice.simple backend that let's you easily set up website routes and render HTML templates. Highly recommend for a beginner.
Not trying to render html im gonna have a react app for the frontend
Flask is like React
FastAPI is like React but better
Django is like Angular
That's the comparisons we were missing ๐
I always wondered which frontend framework is battery included like django, and which one is micro framework like flask
Perhaps you can classify Vue.js too?
you could say FastAPI is kinda like Vue maybe? but not reaaaally
why are we comparing them to frontend frameworks and not backend frameworks? ๐ค
are you saying this in terms of "batteries included"?
Lol
Lol
Hello.
window.location.replace(link); with flask is not working with FireFox. Any ideas how to fix it?
Or does JavaScript have problem with FireFox?
@native tide window doesn't have a replace attribute. Where did you find this code?
I wrote opposite lol
There
Fixed
@native tide What argument are you calling it with?
A string.
Can you show the error you're getting?
It it currently a rickroll since it was a trial.
I don't have the code rn but I will also share that once I am with my laptop but the thing it, my application is supposed to redirect users to different websites based on their IPs.
When I tried it on Chrome, it worked
When I tried it with Brave and FireFox, I was not redirected anywhere.
By the way, a second question. Is there a way to IP ban someone using flask?
Or just get their IP and like temporarily store it or something?
window.location.replace("https://www.youtube.com/watch?v=dQw4w9WgXcQ") works for me in firefox. Something else must be wrong.
@native tide The easiest way is to use fail2ban, probably. But I don't know about that much.
https://vgui.senkusorcorer.repl.co/ maybe this is still in host mode
Would you like to try?
Or privacy?
@manic frost
worked for me
oHkAy. That means my Firefox is sus ig.
Nevermind then. Maybe it is only mine cuz I have JavaScript disabled or some fancy extension on.
Thank you so much!
If you have JavaScript disabled, then yes, JavaScript won't work 
No. I don't have it disabled by default.
But maybe
Just mAyBe
Because of some extension I installed and forgot lol.
do you have anything more substantial to say?
yup
lmao
@fossil pond nice, how'd you solve it?
I basically clicked on all the folders and enabled public access.
Not only the bucket, had to make the folders public access as well
Remember when making the bucket, did you untick a setting regarding public access? Is that only for the bucket and not its contents?
Yep I did do that.
Strange.
Never used angular but people don't really love it. People love Django though
yeah, React is a lot more popular than Angular
I guess you could say the learning curve isn't as steep
Vue even more so
has someone experience with fastapi so far ? i struggle with posting a list to the api right now ^^
I'd say React is more popular than Vue
Is there any way to change flask subdomains?
(I know how to do it In development servers but I have hosted and there it's not working)
Strange indeed, maybe it's something to do with the DEFAULT_ACL setting? I had it as 'public-read' and it worked first time.
That being said, what AWS service can I use to deploy my backend? Its containerized
is there alternative to flask's secure_filename() that will only remove special symbols but not non-latin letters? E.g I want to provide user with access to original filename if its in chinese/cyrillic/whatever and only remove things that could cause security issues (database shenanigans, xss, etc).
Theoretically I could just do that with self-made regexp, but maybe some solution already exists? I mean - cloud filehosting providers provide you with original filename in their web interface, so there should be some workaround
Hi, i used flask for my project
but every time i typed the url http://127.0.0.1:5000/support i get no errors
but if i typed http://127.0.0.1:5000/support/ im getting errors
you set this path yourself inside of your code
so if you request a path that is different than the one you set inside of python code then of course errors will show up
i have 4-6s latency for django-admin change model page
evrything about sql in fine 220-290ms, all other time spent on logic calculations and rendeering
goal is to reduce page loading time
p.s. my assumptions:
- http caching with etag(but in this way code becomes hardly maintainable)
- pypy
question - can anyone help me in optimizing page loading time?
How can I show this form orderly ?? like Enter Title and then in next line Enter the content ??
@naive hawk pre-render the content?
If you know he is coming to the site, make it static, serve it with a Vary or via an edge cache
Is it an API or HTTP Response?
Cause you could send back the HTML CSS and start rendering the page, yielding a connection and then pipe the calculated parts later
who r u talking to ?? @glad pendant
That @naive hawk dude - thinking of speeding up page responses
The fastest responses are those you almost pre-load into the edge caches knowing they will be called
okayy (although don't know exactly)
Like it depends on the context, but most CMS and static pages being dynamic is a waste -they rarely change.
@glad pendant can u guild me through this one !!
I mean - you could also just use a flexbox
@glossy ore look up https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Our comprehensive guide to CSS flexbox layout. This complete guide explains everything about flexbox, focusing on all the different possible properties for the parent element (the flex container) and the child elements (the flex items). It also includes history, demos, patterns, and a browser support chart.
Thanks I'll check on that for now...
You could also be lazy and do my old horrible ways
<div>X</div><br /><br /><div>Y</div>
๐ I was thinking the same but changed my mind later ...
Flexbox is 98.29% + 1.3% = 99.59% supported
#winning
unless you live where I do where IE11 just never dies
lol I don't get a thing what ur saying (noob alert)
cf-cache-status: HIT
cf-ray: 685dba62fdfcf48a-JNB
content-disposition: inline; filename="MVI_8906_Q7GeCsY.MP4"
Content-Length: 64954784
Content-Range: bytes 0-64954783/64954784```
That is never going to work - you need to have them setup as a streaming video format
Cloudflare already has this
or you can load them in smaller snippets
64954784 = 64mb
That's nuts
It must be able to load at around 2 - 4mb
maybe reduce quality
Also Vary: Cookie is not wise cause you will have very low cache hit rates.
Use https://caniuse.com/mediasource and stream the content
when you order from an ecommerce site do they generally send you invoice on your emails?
@cerulean badge yep
and an option to download them on them from their site as well?
also can you name a few?
I've not seen that before. Usually just an email invoice.
ok
@cerulean badge Do you mean for a customer or from the admin side?
In that case it is up to you/ or the business requirements on if you want them to be able to download an invoice or not.
Yes, I would add the ability to download invoices on all ecom sites for the admin.
ok thanks
Let's resolve it gracefully.
If user visits with IE11, he just gets banner, which asks him to reconsider his life choices.
I just killed their cookies and said it was a forced upgrade security measure.
๐
No banner, waste of time - you can't save that won't save themselves.
Company name - order number
Like if you've ever ordered from a business that uses woocommerce, check their confirmation emails
We have Order Placed
Order Confirmed
Order Dispatched
but with nice meta clickbaity subjects ๐
"Order placed! Check your details", "We've managed to charge your card", "Your products are coming to you!"
Yes - also, include the JSON-LD metadata for Google
Its not that hard to come up with an email subject. Who is the application for? Who is the client?
I mean client as in who are you delivering the project to
Content for emails and stuff i would always get from the client
Then just pick whatever works for you. There is no one standard. Its like asking what colour should my website theme be.
Why did you delete all messages @cerulean badge
It does make sense, just not one somone can answer for you. And you shouldn't delete messages its rude.
has anyone used RTMP before to implement live streams?
very few resources out there on this topic
i deleted one last time dont mind
CAN ANYONE HELP ME WITH DJANGO?
guys Im building a React app
Im trying to fetch my Django backend app
using fetch()
(async () => {
const Response = await fetch('http://127.0.0.1:8000/api/auth/register/', {
method: 'POST',
// headers: {
// 'Accept': 'application/json',
// 'Content-Type': 'text/plain'
// },
body: JSON.stringify({username: document.getElementById("usname").value, password: document.getElementById("pswd").value, email: document.getElementById("email").value})
});
const content = await Response.json();
console.log(content);
return content;
})();
this is my fetch code
it says
Access to fetch at 'http://127.0.0.1:8000/api/auth/register/' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Apparently I can only use text/plain Content-Type
but when I use requests module in Python to request localhost:8000/... it works perfectly fine
anyone knows why?
@broken mulch when you're making a request from your fronted to your backend, the request has a different origin from your backend, so the browser will enforce CORS. Your backend has to provide a CORS header Access-Control-Allow-Origin which specifies origins which can make requests to the server.
When you use the requests module in the terminal, it's probably the same origin.
thanks, what should I provide in Access-Control-Allow-Origin? is there a Mozilla docs for that
Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading of resources. CORS also relies on a mechanism by which browsers make a "preflight" request to the server hosting the cross-origin resource, in ...
@broken mulch are you using django?
yes
@broken mulch there's a pluggable package for django
alr i'll check it out
Easy to setup. Just install, add to installed apps, add middleware, then list valid origins
kk
And the reason the requests are from another origin is because your server is running on port 8000 and your frontend on something else (e.g. 3000). There's docs on the spec for what constitutes a request that is not on the same origin.
yeah
can I just use * or do I need to list every single one
Yeah you can use *, but in production list them explicitly
alright
I don't think I would change my React's port
so I'll just insert localhost:3000
Sounds good. Also a note, localhost:3000 is different to 127.0.0.0.1:3000. I don't know why I'd actually like to know.
@outer arrow
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.
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mywebsite.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
``` this is my manage.py file
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
return HttpResponse("Welcome to this polling section!")
``` This is what I have in my application that I started inside of my project
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
``` This is what is inside polls/urls.py
I'm assuming you're following this tutorial https://docs.djangoproject.com/en/3.2/intro/tutorial01/
"""mywebsite URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]
That is what is in mywebsite/urls.py
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]
yes I am following that tutorial
that's what the tutorial indicates you need to have int hat file
you didn't include path('polls/', include('polls.urls')),
oh that's probably the issue
as an aside, if this is your first experience with web frameworks, you might find it a little top-heavy. Django is powerful but there's a steep curve.
You might be better off starting with Flask, which is far less complex
Django has a lot of configuration and knobs, so it can be bewildering for a first-timer
hmm yeah, I kinda wanted to learn web development and implement data scraping into it to make kinda a cool website
e.g., this is a hello world Flask app in toto
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
yeah that's alot less complex
I might look at some flask documentations, and try to figure something out on my own
much of the management and boilerplate stuff in Django is so that one can build sites with many features, but I find that it's often too much for people to take in at once if they have no experience with how web frameworks work
yeah I've never worked with web frameworks before
Yes, it might be best not to start with Django as your first outing
let me look at some flask documentation
@cerulean vapor Thank you for the help. I really appreciate it.
YW
hey everyone, i have a rather complex to understand question...
i have a flask web server running some content on replit and i have another site hosted using github pages (idt that matters) that needs to access some content on the site hosted on replit.
for simplicity's sake ill let the replit site be a.com and the gh pages site be b.com
now ive made the gh pages site logic using javascript and made a simple GET request to a.com using axios however this failed apparently becaused of a browser policy called CORS, which i just read up about and basically i need to make a.com (which was made using flask) to send a response when b.com accesses it with a header of Access-Control-Allow-Origin: https://b.com in order for the browser to let me use the resource on another origin (which is a.com).
and i have no idea how to do it. im fairly new to web development and i just learnt how to make flask web servers today so any help would be greatly appreciated!!!
guys, I'm using react frontend and I cannot access any HTTP headers. Anyone knows how I can see those headers
Question on Django and gmail in #โhelp-coffee
Hi guys๐
Does anyone know that
How to download zoom records from its site with Python?
devtools > network > request / response
hey all, I'm requesting https://api.github.com/repos/onerandomusername/modmail-addons/zipball which provides a zip file and a name, how can I get the provided file name as well as the zip contents
Guys need little help ...
I have a little problem with my current Static Files Config.
Now the problem is that React frontend Build is also considered as static files when Django serves these files. Locally it works fine after creating a build from the npm run build command manually. But when I push this in production with two separate engines One Node.js for React and the other is Python for Django app on Heroku, then Django tries to get Build files from GS_BUCKET as configured for Media files and static files. So frontend build files are not picked by Django.
So I'm trying to make two configurations. Google Cloud Storage for just media files but Static Files should work as default bypassing Google Cloud Storage.
So How to make it possible. Please suggest to me any method to make them separate. Or how to Bypass Google Cloud Storage Config for just Media Files. Thanks!
after futher exploration this is a b64 problem, ironically.
for nginx config, in /etc/nginx/sites-available/<site_here>, what is the filetype of <site_here>? Is it .conf or .txt?
no idea I have it run on my RDP
I checked and EC2 would be the one. It's also an RDP (I think?)
just briefly checked it
NameError: name 'HttpReponse' is not defined
Those Django errors really gonna destroy me
First thing...17 unapplied migrations is a lot. You might want to run migrate as the log suggests.
Second thing, we'd need to see the code. The error message alone isn't enough
I think this is not the problems, cause I make the migrations just right now
What is the code for the view?
!code
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.
It's MUCH easier to read code pasted directly in
views.py:
from django.shortcuts import render
from django.http import HttpResponse
Create your views here.
def index(response):
return HttpReponse("<h1>Hello, World !!<h1/>")
urls.py:
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index")
]
Use the backticks ๐
!code
Three of them either side.
You can edit your posts ^
put three like thispy print("Using backticks")
you can even add the letters py after the first three backticks to highlight the code
The good news, once you get used to it, you will do it without thinking ๐
Typo...
!code
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.
Look for HttpReponse
You wantpy def index(response): return HttpResponse("<h1>Hello, World !!</h1>")
You were missing S in Response
AND...
Put the backslash BEFORE h1 for the closing tag
๐
Welcome to the world of coding!
Bruh...I spent two days recently on finding an issue where I had a : instead of =
thank you xDD ^-^
Trust me....this is coding
that's happened always to me
Programming is dealing with very exacting syntax. There is no forgiveness really. ๐
Accuracy of observation
that's what I really like even though I don't adapt quickly xD
With the : vs = issue, the problem was I couldn't even see the issue. The two characters look so similar. Other more experienced programmers also missed it. Also because it was an environment file where there was a list of lines mostly with =. And two lines with :
DB_ENGINE=django.db.backends.postgresql
DB_NAME=lanesflow
DB_USER=lanesflow
DB_PORT=5432
EMAIL_USER:info@lanesflow.io```
^ that ๐
Nasty one. Anyways...good luck, bruh ๐
thank you and good luck too
Coding is fun. I started Django in Jul, 2021, and Python in April. My first project: https://lanesflow.io
that's really nice
Thanks. I've worked hard on it. I spent June learning Flask but realized I needed more because my idea is complex. Django is FAST though ๐ Really powerful framework
yeah that's the truth, django is so good
have dedicated email working in prod now. Emails come from info@lanesflow.io ๐
U a one of rare snowflakes capable to do front and back at the same time now
Now I have to code a webhook for Stripe
Thanks Bruh. Rare snowflake ๐
I think I will never go for front.
I already go for too many back directions.
Backend/devops/devsecops/architect
Just as well. Building an idea from scratch...as the sole developer...you'd best be a rare snowflake or your site will look like or work like dogshit
Reminds me...once I get this webhook built, I've some dynamic forms with htmx to build to replace Inline Formsets, and then....learning automated CI/CD
Jenkins methinks...
The easiest and laziest to learn in github/gitlab ci/cd
Yeah. I'm thinking gitlab as well.
Quite recommending gitlab, I love it
Stripe webhook in Django...anyone have experience with those?
My brain is fried today...I may put this off to tomorrow. My brain is literally hurting.
well, my head is hurting...but you know
I'm using checkout...
That is my current task
I think I need to throw a webhook function in the view
I can say that integration itself is not the hard part
Hard part is passing security audit known as PCI DSS compliance
I got the checkout working in test. All that's left is to have the webhook so that I can get notified of sub success and update the record.
However, I believe I'm missing the capture of customer_id and email after the first checkout
So I think I need a webhook to receive the customer_id and email after they subscribe...and to receive subsequent notifications about their sub
Which reminds me.,...this will warrant a new branch! ๐
Dont forget to delete them ;b
I do forget to do that, that's for sure
Hello guys, I wanted to ask does django needs any additional security checks or packages to be ready for production?
There are some settings to adjust. You want to make sure that debug is set to False.
How are you deploying?
heroku deployment, is it safe enough?
I've deployed to Heroku once with Flask. So I don't have direct exp with deploying Django in Heroku though.
At the very least ensure DEBUG is set to False.
only ?
That's the main one. How are you handling environment variables?
Also, what DB are you using?
Yes I know those setup
Postgres
That's good.
OK. Well, you've got the most obvious elements prepared.
You'll want to make sure your requirements.txt file is upto date with required dependencies obviously
Now, I'm no seasoned veteran in this though. So, might be good to see what else others have to say. I've just got the one production site so far.
Okay Thank you ! really appreaciate your help!
You're welcome. Like I said, I'm no pro. You should keep inquiring and get other opinions though.
I used Heroku with Flask to get some experience. In the end though, I needed my own URL so deployed to Linode. Using 2 servers, one for staging the other for DB
What's the best way to remember a user's login session?
@broken mulch use cookies
discord most likely using some sort of auth token
theres always security issues. Auth tokens are more secure
do some research on google
does someone know if node media server scales for live streams?
So after 2 minutes of exploring discord's localStorage and cookies I think I now how they're doing it
basically:
after I log in it will have a auth token
before page unload it'll add it to local storage
next time I go to discord, the token will be there
after page fully loaded the token will be removed from local storage
if I unload the page, it'll be added back again
that's my guess
discord is a web app, so most likely
through the desktop app:
login -> creds sent to server -> auth token generated + session cookie created -> login redirects to account if successfull
Hi
Can anyone here with intermediate skill of django apis building
I need a dev for my paid project which api have to develop in django
if anyone interested let me know
Hi, im in github and trying to add this thin line after a header
how do you add that line after "materials"
Actually the token is Account Creation Date + User ID + A Unique
Well, that was interesting...building a Stripe webhook ๐ Did it though. Bit of a journey to get there
You might want to check the rules. I seem to recall that recruitment is not allowed. I'm not saying that in official capacity, but if it does break the rules you might want to know.
Are you trying to use Markdown?
@ionic raft i believe so, unless there is a better alternative
I am not aware of an alternative. If you're building a Readme file that's what you've got to work with. I suspect markdown style may be driven by their css.
@frank grove you can use three or more asterisks, dashes or underscores
e.g.
***
---
_________________
markdown has support for html but you can take a look at the basic syntax here https://www.markdownguide.org/basic-syntax/#horizontal-rules
thank you both @thorn igloo and @opaque rivet , your site really helped me!!
@ionic raft thanks!
Guys can u tell me how to solve this #web-development message
how should i structure my dashboard flask app so i can easily update data sources?
@broken mulch a benefit of cookies is that they're sent with all HTTP requests, including, for example, images
(context django) if you are going to add a minvalue and maxvalue validator to a integer field anyway should you use IntegerField or PositiveIntegerField?
Not that I'm a pro, but the obvious consideration is how big do you need the integer to be?
From my limited CS knowledge, if there's a chance you need a huge number, then going with PositiveIntegerField just doubles your potential limit, since the negatives explicitly are not needed. But I suspect we're in the billions or trillions (advise research for limits on field types at that point). However, unless you're looking at huge numbers/big data/Science/Math heavy computations, if you're talking about mundane usage, the difference between those two data types isn't going to be meaningful.
It's all about specific context.
its a rating field and has a value from 1 to 5
class Review(model.Model):
user = model.ForeignKey(
settings.AUTH_USER_MODEL,
related_name='reviews',
on_delete=models.CASCADE
)
product = model.ForeignKey(
Product,
related_name='reviews',
on_delete=models.CASCADE
)
rating = models.PositiveIntegerField(
default=1,
validators=[MinValueValidator(1), MaxValueValidator(5)]
)
comment = models.TextField(max_length=1000)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Meta:
ordering = ('-created',)
def __str__(self):
pass
any idea what to return from __str__?
Then it really doesn't matter what data type you choose. Given that you'll never have a negative integer PositiveInteger would be fine.
__str__ is what you want the record to display as. At the very least you want...
return self.user
self.user```
You can make use of the str though when you want to make the record make more sense.
this is what someone answered me
its automatically returned based on the pk you dont need to override that method
if you dont want to override it just dont
what do you think?
That is correct. The use in using str though is that you can make adjustments to what you return as you need. I always declare it because during development I often need to show the record in different ways.
At any rate, I just wanted to share a success story. Apr 16, 2021 I started learning Python. I had an idea for a website. I chose Python. July 9 I started on Django. A few days ago I deployed v0.1.1 of https://lanesflow.io
I'm 50 years old, and have never coded before this. To any newcomer to Python, it's an amazing language.
As for LanesFlow, I've already got 32 items on my task list, and for v1.0 there'll be a Collaboration Map App to take this website to the next level! ๐
Side note - this Django Discord....HUGE part of the reason this happened!
ok thanks
great job!
that's extremely impressive
As I recall, you've been a helper along the way! Thank you
Thanks. it's v0.1.1
I've got 32 tasks on my list for v0.5.
v1.0 is going to have an innovative Collaboration Map App.
I read 2-scoops of Django. Will re-read it I'm sure.
I'm solid on front-end-app-db separation. And I spent time structuring the project before I even began ๐
do you mind sharing what you did before?
it sounds like @ least you have good planning skills
But yeah...this Discord....I don't know I would have done it without this Discord.
which is something people often fail to understand makes a big difference between "writing code" and "engineering software"
I am a business consultant. I train/mentor in process improvement (Six Sigma inspired methodology and information management). I have spent time working with a visual development stack and have implemented high-end IA systems for clients. I have been Business Analyst for 20+ years and Project Manager for many years. I've mentored BAs.
More recently, I realized I could take my 25+ years of experience in helping organizations to collaborate more effectively and the idea for LanesFlow was born. April 15, 2021.
Apr 16 I was on day one of a Python bootcamp.
ah, no wonder
that explains the planning experience
figured you were some sort of BA/PM
Likely. ๐
Did I tell you about ALAN yet?
nope...?
There is literally nothing like LanesFlow out there. The tagline...Complex Made Clear...that has to mean something right.
Well, ALAN has something to do with that...Automated Lanesflow Assistant Notifier...
He's coded into LanesFlow. He'll grow as I code more of him in. But basically, he's the business consultant that holds your hand (or not, you can turn him off)
ALAN works with LEE (Learned Experience Engine)
LEE is about humans working with the machine to learn the things they need to do. The support system built into LanesFlow uses LEE so that support team members get upto date checklists of what to do at any given phase or category of problem
One plan is to hire an ML expert to enhance ALAN and LEE to the next level. They're the foundation though
I've been doing process improvement for 25+ years. There is nothing like LanesFlow out there. And the beauty is, the idea can't really be stolen because without the experience it doesn't work.
And the vision for this came from every bloody complex website that assumes you're an expert. Search the KB....visit the Forums...Enter a support ticket....use cross-site search that is a crap shoot for relevance.
All broken approaches IMHO
Although I just removed the word "Task" at the beginning of those...
Correction...that is ALAN identifying that you did something unexpected in Project Management of a Process Improvement Project
So that is what ALAN is. It's the most exciting part of LanesFlow to me.
I feel like
the acronyms...
are a very marketing-oriented thing
I can see the usecase though
I know what you mean
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
my bad im sorry
Why would I be breaking laws?
lol
I thought i could get help on this server
because you are making access to web site with bots without consent of the site creators
whatever the reason, it is malicious, because your software breaks their terms of service for sure
and could potentially heavily increase the load, depleting resources from other users
basically it is a beginning of DoS attack
usually, when person has consent, he uses official API to the service.
But im not even using threading or async, it is just a simple program to learn python requests
understood tho
srry
if u do it to your own website, it will be considered as just testing
or if you have consent
Python is heavely used for scraping with or without an API, hundreds of atc bots are open sourced on github or stack overflow it does not affect by any means the creators of the site that I try or not to get help on this. imo ur just giving it too much importance it is not even ilegal. but hey, got it
Is it possible to pass through the same variable to each route?
I have around 20 routes under one blueprint, and I want to know if its possible to pass through a variable to each and every route, without having to manually add it to the render_template return
How can I make the second div within the wrapper to fill up 100% of the remaining height of the parent div instead of extending it?
<div style="width: 450px; height: 150px; background-color: #c3c3c3">
<div style="font-size: 1.5rem; text-align: center;">Text</div>
<div style="height: 100%; background-color: grey;"></div>
</div>
the div container is 150px in height in total
You could assign the text divs height to a variable and use calc(100% - var(--text-div-height) (not sure about the syntax, haven't used CSS in a while)
Yes, but 100% makes it overflow
Is there really no simple solution?
I don't want to, I want to change its size because it will have a chart
I just want it to fill up the remaining height
Figured it out, this is much better:
<div style="width: 450px; height: 150px; background-color: #c3c3c3; display: flex; flex-direction: column;">
<div style="font-size: 1.5rem; text-align: center;">Text</div>
<div style="flex-grow: 1; background-color: grey;"></div>
</div>
This may all sound a bit fuzzy, but there is something thinking around this. When conceiving the idea I realized that by giving ALAN a name it would provide an anchor for an identity. Human beings tend to anthropomorphize things, to impress upon them that they are human. If the idea is to build an automated assistant (Jarvis is a good name too) then having a name offers a potential of building a strong rapport than not. At any rate, I hear the comment about marketing. I'd be concerned by that if ALAN didn't add clear value to LanesFlow. LanesFlow is better, without a doubt in my mind, for ALAN. And as for giving ALAN a name, remember that ALAN sends messages offering guidance and suggested course corrections for users involved in what can be fairly complex activities. Having an identity to sign off on those letters just happens to make me smile.
Yello...Anyone online...I need help on django
@mystic lotus wrong server mate
Someone help
nginx question, when visiting 0.0.0.0/ I get the nginx introduction page.
But, when I visit a URL config the request is proxied to my django server.
Any reason for that?
just send your question
upstream backend {
server backend:8000;
}
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
Someone tell me how to get a response in django when I visit a site made with js
@mystic vortex make an API with django-rest-framework. Send API requests from your JS frontend.
I am new to this I don't know how to do that flask will be fine too but how to get the response
But didnt you ask "response in django"?
I want response from the js front-end whenever someone visits the page the frontend will send a response to the backend
But how?
Is it possible
??
Do what nicky said
send a request to the backend api
Hello, I'm working on a Flask website. I'm trying to make login based on Discord oauth. I'm using flask-discord extension.
My issue is that www.mysite.net and mysite.net get treated as different domains and give different sessions/cookies on visit. Any idea how to fix that?
Can I send request from one machine to another using it?@eternal blade
You can send a request to any valid domain or ip using that method
no
Hello, how do I set permission for a logged in user on django ? Using decorators or something else ??
@mystic vortex simply searching "how to make an API with Django"
Ok
Lemme try to make one
When your frontend and backend run in different context, they will have to communicate via an API.
I have to send a http request right?@opaque rivet
http request
Me dumb
Yes, your frontend and backend will communicate via http requests. APIs are an important topic, so learn them well
Ok
@nocturne juniper maybe you could use nginx to proxy the request and send it to the same domain each time? I'm not too sure, that's just a thought.
It's the same domain, just a matter of www. and no www.
And I've read that cookies stored on domain.net should be accessible on www.domain.net but they are not
Hello, looks like the built in django user model doesn't allow unique usernames but it allows duplicate emails, is it possible to change that behaviour?
I know that I can create a custom user model but isn't there any other way?
@eternal blade you could make a signal which checks if there is an entry with the same email, and raise an error.
But I think the best option would to create a custom user model.
Have you tried this hack
from django.contrib.auth.models import User
User._meta.get_field('username')._unique = False
Thanks for the advice ๐
I will make a custom user model
Thanks I'll try that too
@opaque rivet what libraries are there that can do this http request and post
For JS, I use axios
@opaque rivet I need to post the data from my frontend or I need to request the data from backend?
You make a request to your backend from your frontend. The backend returns a response.
That's the request/response cycle
I want like whenever someone visits my website my front-end will send a response to my backend and my backend will store that response in it
It will send a request. Not a response
Oops
Django views take in a request and return a response
For making requests
Flask is a backend
I know
Yes you can make an API with flask
Me getting confused that am I supposed to maake a request from frontend or request from backend
I want to send some data from my front end to my backend, but how, will it require api and who needs to make the request the front end or the backend
That is what @opaque rivet was pointing at when Flask was suggested. A web development framework, such as Flask, will allow you to accomplish the sending of data from the front-end to the back-end. It is what they are built for.
Sure, you could code from the ground up, but web dev Frameworks save you a lot of time and make it easier to get started.
Flask is great to get started. Django is great for when you've gotten started but want to build a much more complex/interactive web site that does lots of things.
r u there plz i need help asap @ionic raft
Wussup...I'm but a noob. If I can help I will
u have worked with OneToOneField?
I have one use of it...User to Profile. Profile has a user.
class Profile(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE)
image=models.ImageField(default='default.jpeg',upload_to='Profile_Pics')``` so this is my profile model so user can make thier profile user will be taken by thier account , and image will be option for them
how can i use it to show only profile of that particular user
how can i query data for only that particular logged in user
i have done that by Foreign Key not OneToOne field
@ionic raft
@login_required
def profile(request):
queryset=User.objects.all()
return render(request,'users/profile.html',{'queryset':queryset})```
{% for q1 in queryset %}```
I've managed that by running a queryset on the request. When a user visits their profile page I query for the profile that has user=request.user.
ohh
how can i do that my OneToOneField
i have done say thing with ForiegnKey
;-;
ig im filtering correct im doing wrong in this
Well, the field will have a populated value, right? Because it's OnetoOne that means, when you query the user_object = Profile.objects.get(user=request.user) you get that single object back, which you can then use as the item displayed on the detail profile view.
for loop
That would work for a ListView. But for a Profile you only need a DetailedView
A OneToOne field guarantees just the one related record. And as users are unique you're guaranteed just the single Profile object to query for.
yes yes ik that xD
that;s why using that
else i would have used foreignkey
TypeError at /account/profile/
'Profile' object is not iterable ```
@ionic raft
I think remove for loop?
sounds like you're trying to loop through an object and not a list
try this
u were right
yeah done
yea just show up ur data once without a loop
why?
Fantastic. Maybe I'm not an utter noob after all ๐
u dont need a for loop to show the profile? or do a profile page
Yah. We were working that out. I believe he's solved the problem
@rotund perch read from here
i need a loop cez how would i render that by db then
with this
That's different. If you query for a list of objects, now you've got a loop to iterate through with {% for %}
@login_required
def profile(request):
queryset=Profile.objects.get(user=request.user)
return render(request,'users/profile.html',{'queryset':queryset})```
ohk correct?
ok go to ur html and remove for loop
done removed now
Let me put it another way. Look to an object that has one or many FK. That will mean the potential for a list of objects when building the queryset. With a list of objects you use a for loop in a ListView
@rotund perch
try to run server now
yes done it working but how will i retrive the user PROFILE now
maybe he did not took those lessons yet.
class Profile(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE)
image=models.ImageField(default='default.jpeg',upload_to='Profile_Pics')
umm
how can i retrive now i have to use for loop
;-;
Side note. I discovered that deploying uploaded images to a production server becomes an interesting challenge for Django. When you get ready for promotion to production server ask me. It would be better to explain then.
sure
If you have a OneToOne field you will only have one Profile. With only one object you will NEVER have a list. YOu can always use objects.get()
show me html again
but in html im asking
Think...FK = list is possible.
OtO = get is always possible
And I'm suggesting to pick another model to flesh out the example.
Look to your models...pick a model that has a FK field.
Showing you how to work through a list for a OtO field in a template is not helpful
{% queryset %} i think?
i can do by fk it's ezz just query all() then variablename.modelname_set.all
and done
sorry {{ }}
i have done that by FK in ecommerce for order history
As for the raw html, yes
{% for object in objects %} # Where objects was the model/context sent by the view
<p>Such as show the object's id field: {{ object.id }} </p>
{% endfor %}
ezz
sorry {{ queryset }}
no just put {{queryset}} in the h1
<main id="profile">
<div class="profile">
<img src="" class="profile-pic" alt="profile picture">
<div class="profile-details">
<h1></h1>
<h3></h3>
<p class="discription">
discription Lorem ipsum, dolor sit amet consectetur adipisicing
elit. Cupiditate repudiandae recusandae
deleniti veritatis perferendis velit consequatur.
</p>```
take code
@login_required
def profile(request):
queryset=Profile.objects.get(user=request.user)
return render(request,'users/profile.html',{'queryset':queryset})```
class Profile(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE)
image=models.ImageField(default='default.jpeg',upload_to='Profile_Pics')```
USe this as a starting point...
{% for object in objects %} # Where objects was the model/context sent by the view
<p>Such as show the object's id field: {{ object.id }} </p>
{% endfor %}
ohk trying
you know, I've been working so hard on Django, it's awesome that I know that syntax by memory ๐
Started less than 2 months ago. Hope for me yet ๐
Well, I've been doing 6-10 days on average. Full time effort for me the past couple of months ๐
I actually have been using pure querysets. I'm not sure if that is it's REST Framework. But I call it, Dancing with the Django DB
TypeError at /account/profile/
'Profile' object is not iterable
Wow, Good Luck Man!
That makes sense. you ran .get() right?
Thanks. https://lanesflow.io is my first web project
objects.get() returns a single object. it is NOT iterable. The error makes sense.
It's why I asked you to use a different model with an FK.
ohh
but i have to do with OneTOOneField
done
changed that get to filter
and it worked
LoL
In that case, you don't need the for loop.
YOu simply send the object over as a context through Model = object_name
Then use use {{ object_name.attribute }} to call what you want.
Yes. You could do object.objests.filter(user=request.user) but it's slightly less efficient
XD
when you know there's only one object use .get()
At a guess, I suspect it would mean a more efficient query. It might be milleseconds, but they add up.
umm
OK. It sounds like you've got some momentum. I'm off to turn two InlineFormsets into dynamic forms with htmx