#web-development

2 messages ยท Page 185 of 1

ionic raft
#

That's not working. I'm going to need to add a new user...I just reset the password for that superuser and gtting the same error.

native tide
#

Guys, I got a problem with flask. Could you help me If I sent the Code and error here?

ionic raft
#

I just reset the password for lanesflow user. Copy/pasted password....same error.
Going to try and add a new superuser.

inland oak
#

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
๐Ÿ˜ฑ

ionic raft
ionic raft
#

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?

inland oak
#

with auto user creation

ionic raft
proper hinge
#

Is this an issue with authentication with the database, or authenticating as a Django user?

inland oak
ionic raft
#

Because this...what is happening...is making NO sense

#

At all

proper hinge
#

So can your app connect to the db or not?

inland oak
#

checking with console client would be a solution

proper hinge
#

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)

inland oak
#

or if firewall got enabled by accident or something

#

better start with pinging by telnet ipaddress port

ionic raft
#

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

ionic raft
inland oak
ionic raft
#

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

ionic raft
inland oak
#

/du shows users of the database to make connection to database

#

those are two separated entities

ionic raft
#

Ahhh...OK. I'll look up how to access user table.

#

And how to change password for users on that table

inland oak
ionic raft
#

Because THAT is what I need to get done

ionic raft
inland oak
ionic raft
#

Even though I have a password manager, apparently, the password stopped being accepted yesterday

#

And where exactly do I run python manage.py shell?

inland oak
#

in container with _web

proper hinge
#

Your database table might have been wiped

ionic raft
#

this all comes back to....that user's password suddenly not being accepted.

ionic raft
proper hinge
#

And to run that command you can use docker exec to launch a shell in the running container

inland oak
proper hinge
ionic raft
inland oak
#

docker ps

proper hinge
#

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

ionic raft
#

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....

ionic raft
#

I apologize for being so dense...your collective patience....is appreciated

inland oak
ionic raft
#

OK. So, now I can run python manage.py createsuperuser <name> and should get a prompted for a password?
Nope...that's not right

ionic raft
proper hinge
#

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

ionic raft
inland oak
#

docker-compose exec looks cool too

proper hinge
#

Yeah that's true if you don't have a running container yet; you can override the entrypoint and start one

ionic raft
#

I don't think that the console is where I can create a superuser

proper hinge
ionic raft
proper hinge
#

You need to be in a shell like bash or sh

#

You're currently in the Python REPL

inland oak
ionic raft
#

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

ionic raft
ionic raft
#

I can only assume that there was something in those single quotes that was getting in the way.

ionic raft
proper hinge
#

You're welcome

#

While I was debugging I took the liberty of cleaning up your Dockerfile, if you're interested

ionic raft
#

I need to push a new change up to turn debug off anyway ๐Ÿ˜„

#

You know...this Discord...without it...there would be no lanesflow

proper hinge
#

Since you said you're taking notes, I find that apt-get snippet handy

ionic raft
proper hinge
#

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

ionic raft
#

Frickin LOVE Docker for what it is. Just had to bang my head against a wall for a couple of days to get here...

ionic raft
#

As someone who has built word press sites in the past...shifting to Django....holy crap...FASTER!

inland oak
#

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

ionic raft
ionic raft
#

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...

inland oak
#

yeah, my learning queue is a long one too
it would be great to have 48 hours per day ;b

proper hinge
ionic raft
proper hinge
#

Oh yeah that last comment was just about the overkill build stage thing I mentioned

ionic raft
#

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

proper hinge
#

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

ionic raft
proper hinge
#

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

ionic raft
ionic raft
inland oak
#

after many months of usage I think to read a book though just in case to check what I miss

ionic raft
# inland oak this.

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.

inland oak
#

my micro company is having me as a single dev

ionic raft
# inland oak guess where I learned

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...

ionic raft
inland oak
#

it is possible to write unit test that checks media file existence

ionic raft
inland oak
#

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

ionic raft
#

Well, I put a workaround together

ionic raft
inland oak
#

anyway, u solved the intial docker deploying problem, I'll be not needed tomorrow then

ionic raft
#

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...

ionic raft
#

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?

fossil pond
#

How do I check that?

ionic raft
#

A missing slash...omg

fossil pond
ionic raft
#

It was a nasty one

inland oak
ionic raft
inland oak
#

we insert incorrect password until the pc agrees

ionic raft
#

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

ionic raft
inland oak
#

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

ionic raft
#

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

ionic raft
# inland oak build is build, can't be mistaken for anything

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')
]```

inland oak
#

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

ionic raft
inland oak
#

emm, is it still working now?

#

be sure you saved everything

#

before experimenting ๐Ÿ˜‰

ionic raft
#

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

ionic raft
inland oak
#

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

ionic raft
#

Documentation says...

opaque rivet
#

@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

opaque rivet
#

By the way in production you need a proper server to serve your staticfiles

opaque rivet
#

Ok nice.

ionic raft
#

It collects just fine...1490 static files.

ionic raft
# opaque rivet Ok nice.

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

ionic raft
inland oak
ionic raft
inland oak
#

I don't know how u store media

ionic raft
#

This has a suggestion...

#

there is a media directory in the root

inland oak
#

how is it called exactly?

ionic raft
inland oak
#

I see

ionic raft
#

But this makes sense...now I just need to get it working...

inland oak
#

the easiest approach would be making

#

volume connected to django and nginx

ionic raft
#

I tried

    root /app/web/build/media/;
  }```
#

settings.pyMEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

inland oak
ionic raft
inland oak
#
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

ionic raft
#

Right...was just realizing thattoo

inland oak
#

tbh it is really bad

ionic raft
#

Ok...that makes sense

inland oak
#

because we lose statelesness of django

#

u start storing data there

ionic raft
#

Well, the profile pics are resized to no more than 250px. Article images are for writers only

inland oak
#

no load balancing is possible any longer

ionic raft
#

I did wonder about storing images off to another server.

inland oak
#

u will go only with buying more powerful servers then

ionic raft
#

And use image storage server for article images

inland oak
#

based on any input from database

ionic raft
inland oak
#

or

#

you could store pictures in db

ionic raft
inland oak
ionic raft
#

I'll see what I can find w some research ๐Ÿ˜„

paper mango
#

how get data from button in html to Django view.py ---HTML button (
<td> <button class="crud" name="id" value={{ e.id }}>
<a a href="/eminfo/show/"><strong>EDIT</strong></a>

) ## in view.py like e=Employee.objects.get('id')

ionic raft
#

Not action attribute...type

ionic raft
inland oak
#

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

ionic raft
#

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

paper mango
#

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})
ionic raft
ionic raft
paper mango
#

okay thanks @ionic raft

vapid hornet
#

Any python expert

vestal hound
#

๐Ÿฅด

ionic raft
inland oak
#

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

vestal hound
#

auto reject

tawny pollen
#

hello, can you help me with a django problem?

vestal hound
tawny pollen
#

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

ionic raft
odd vapor
#

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.

native tide
#

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

paper mango
#

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'),

]

thorn igloo
solar fulcrum
#

Hi! do you think it's hard to show an interactive tree (like jstree) in django?

rigid anvil
#

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.

lavish prismBOT
near forge
#

Hey, does anyone know a smart way of sending data to a django channel (websocket consumer) via DRF?

strong palm
#

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?

fossil pond
opaque rivet
#

Looks like an ACL problem

cerulean badge
#
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?

native tide
#

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?

frank shoal
#

if it happens on the remote, it's the backend.

native tide
#

What do you mean by remote?

frank shoal
#

on the server

#

But there's no rule that says your backend can't be a frontend for another service.

native tide
#

Atm i gather the data into huge csv files and then upload them manually to the database

frank shoal
#

Then that is neither frontend nor backend

#

maybe you could call it devops

native tide
#

Oh its only backend if its an automatic process?

frank shoal
#

I believe so.

vital crest
#

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???

native tide
#

that's not rendering

#

that's just a static file HTTP server

#

as a side tip: using Nginx as a server for static files is more responsive

#

generally speaking

native tide
#

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.

  1. 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?

  2. 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.

unique ore
#

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

vital crest
#

i think

native tide
inland oak
#

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

native tide
manic frost
#

FastAPI is growing in popularity from what I've seen.

#

You might also want to try Starlette, on which FastAPI is based

native tide
#

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

distant trout
#

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?

native tide
#

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.

distant trout
#

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

native tide
#

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

ancient loom
#

Fastapi vs flask vs django. I feel fastapi can do almost everything in lot less code!

light cloak
#

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 ๐Ÿ™‚

fossil pond
#

nvm i solved it

#

cries in happiness

distant trout
#

kinda conflicted, should i store dark mode preference in the db or cookies/localstorage?

quick cargo
#

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

distant trout
#

ah true, yeah ill store it in db.

ionic raft
native tide
#

is there any html, css, js discord server??

fossil pond
#

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)

calm plume
native tide
#

!code

lavish prismBOT
#

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.

slender whale
#

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.

native tide
#

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

quick cargo
#

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

serene delta
#

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

manic frost
#

is the IO you're doing really expensive?

serene delta
#

no but's it's the diff between simple string validation on the body and hitting a database for the query

manic frost
serene delta
#

thank you

#

i forgot the gitter existed

manic frost
#

oh right

fleet vault
#

i need help with php dose anyone know ?

#

how to fix this

native tide
#

Im new-ish to Python, not at all new to webdev. Could someone give me a quick comparison between FastAPI, Starlette, and Flask?

lavish ferry
#

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.

native tide
#

Not trying to render html im gonna have a react app for the frontend

vestal hound
#

FastAPI is like React but better

#

Django is like Angular

inland oak
#

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?

vestal hound
manic frost
#

why are we comparing them to frontend frameworks and not backend frameworks? ๐Ÿค”

versed python
dusk portal
dusk portal
native tide
#

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?

manic frost
#

@native tide window doesn't have a replace attribute. Where did you find this code?

native tide
#

There

#

Fixed

manic frost
#

@native tide What argument are you calling it with?

native tide
#

A string.

manic frost
#

Can you show the error you're getting?

native tide
#

It it currently a rickroll since it was a trial.

native tide
#

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?

manic frost
#

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.

native tide
#

Would you like to try?

#

Or privacy?

#

@manic frost

native tide
#

Nevermind then. Maybe it is only mine cuz I have JavaScript disabled or some fancy extension on.

native tide
manic frost
#

If you have JavaScript disabled, then yes, JavaScript won't work lemon_pleased

native tide
#

No. I don't have it disabled by default.

#

But maybe

#

Just mAyBe

#

Because of some extension I installed and forgot lol.

vestal hound
opaque rivet
#

@fossil pond nice, how'd you solve it?

fossil pond
#

Not only the bucket, had to make the folders public access as well

opaque rivet
#

Remember when making the bucket, did you untick a setting regarding public access? Is that only for the bucket and not its contents?

versed python
# vestal hound yup

Never used angular but people don't really love it. People love Django though

vestal hound
#

I guess you could say the learning curve isn't as steep

versed python
inner gulch
#

has someone experience with fastapi so far ? i struggle with posting a list to the api right now ^^

opaque rivet
versed python
#

Yes it depends on how you look at it

#

In the end it all boils down to preferences

sleek pine
#

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)

native tide
#

Hey there I wanted help

#

anyone willing to?

opaque rivet
#

That being said, what AWS service can I use to deploy my backend? Its containerized

stark axle
#

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

native tide
#

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

native tide
#

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

naive hawk
#

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?

glossy ore
#

How can I show this form orderly ?? like Enter Title and then in next line Enter the content ??

ornate swan
#

pls send the link to download sublime text here

#

hi`` pika b

#

hu

glad pendant
#

@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

glossy ore
#

who r u talking to ?? @glad pendant

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

glossy ore
#

okayy (although don't know exactly)

glad pendant
#

Like it depends on the context, but most CMS and static pages being dynamic is a waste -they rarely change.

glossy ore
glad pendant
#

I mean - you could also just use a flexbox

glossy ore
glad pendant
#

You could also be lazy and do my old horrible ways

#

<div>X</div><br /><br /><div>Y</div>

glossy ore
glad pendant
#

Flexbox is 98.29% + 1.3% = 99.59% supported

#

#winning

#

unless you live where I do where IE11 just never dies

glossy ore
final geode
#

How can I fix my video page

#

The high-quality videos are ruining my page load time

glad pendant
#
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

cerulean badge
#

when you order from an ecommerce site do they generally send you invoice on your emails?

opaque rivet
#

@cerulean badge yep

cerulean badge
#

and an option to download them on them from their site as well?

#

also can you name a few?

opaque rivet
#

I've not seen that before. Usually just an email invoice.

cerulean badge
#

ok

mint folio
#

@cerulean badge Do you mean for a customer or from the admin side?

cerulean badge
#

for customer

#

also how about a download invoice button for admin side?

mint folio
#

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.

cerulean badge
#

ok thanks

inland oak
glad pendant
#

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.

opaque rivet
#

Company name - order number

#

Like if you've ever ordered from a business that uses woocommerce, check their confirmation emails

glad pendant
#

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

mint folio
#

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.

distant trout
#

has anyone used RTMP before to implement live streams?

#

very few resources out there on this topic

cerulean badge
cedar star
#

CAN ANYONE HELP ME WITH DJANGO?

thorn igloo
#

don't ask to ask

#

just ask

broken mulch
#

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?

opaque rivet
#

@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.

broken mulch
opaque rivet
#

@broken mulch are you using django?

broken mulch
#

yes

opaque rivet
#

@broken mulch there's a pluggable package for django

broken mulch
#

alr i'll check it out

opaque rivet
#

Easy to setup. Just install, add to installed apps, add middleware, then list valid origins

broken mulch
#

kk

opaque rivet
#

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.

broken mulch
#

yeah

broken mulch
opaque rivet
#

Yeah you can use *, but in production list them explicitly

broken mulch
#

alright

#

I don't think I would change my React's port

#

so I'll just insert localhost:3000

opaque rivet
#

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.

cerulean vapor
#

@outer arrow

outer arrow
#

okay

#

one sec

#

I can get a screenshot of it

cerulean vapor
#

please use a code-sharing site; screenshots are difficult to work with

#

!paste

lavish prismBOT
#

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.

outer arrow
#
#!/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
cerulean vapor
#

what's in polls/urls.py?

#

and mysite/urls.py

outer arrow
#
from django.urls import path

from . import views

urlpatterns = [
    path('', views.index, name='index'),
]
``` This is what is inside polls/urls.py
cerulean vapor
outer arrow
#
"""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

cerulean vapor
#
urlpatterns = [
    path('polls/', include('polls.urls')),
    path('admin/', admin.site.urls),
]
outer arrow
cerulean vapor
#

that's what the tutorial indicates you need to have int hat file

#

you didn't include path('polls/', include('polls.urls')),

outer arrow
#

oh that's probably the issue

cerulean vapor
#

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

outer arrow
cerulean vapor
#

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>"
outer arrow
#

yeah that's alot less complex

#

I might look at some flask documentations, and try to figure something out on my own

cerulean vapor
#

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

outer arrow
cerulean vapor
#

Yes, it might be best not to start with Django as your first outing

outer arrow
#

let me look at some flask documentation

cerulean vapor
outer arrow
#

@cerulean vapor Thank you for the help. I really appreciate it.

cerulean vapor
#

YW

lost pivot
#

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!!!

broken mulch
#

guys, I'm using react frontend and I cannot access any HTTP headers. Anyone knows how I can see those headers

ionic raft
mortal isle
#

Hi guys๐Ÿ‘‹
Does anyone know that
How to download zoom records from its site with Python?

opaque rivet
barren moth
tranquil fossil
#

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!

barren moth
opaque rivet
#

for nginx config, in /etc/nginx/sites-available/<site_here>, what is the filetype of <site_here>? Is it .conf or .txt?

fossil pond
opaque rivet
#

I checked and EC2 would be the one. It's also an RDP (I think?)

#

just briefly checked it

low badger
#

NameError: name 'HttpReponse' is not defined

Those Django errors really gonna destroy me

ionic raft
ionic raft
low badger
ionic raft
low badger
ionic raft
#

!code

lavish prismBOT
#

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.

ionic raft
#

It's MUCH easier to read code pasted directly in

low badger
#

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")
]

ionic raft
#

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...

low badger
#

!code

lavish prismBOT
#

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.

ionic raft
#

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

low badger
#

maaaaan

ionic raft
#

Bruh...I spent two days recently on finding an issue where I had a : instead of =

low badger
ionic raft
#

Trust me....this is coding

ionic raft
low badger
low badger
ionic raft
# low badger Accuracy of observation

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 ๐Ÿ˜„

low badger
#

thank you and good luck too

ionic raft
ionic raft
# low badger 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

low badger
ionic raft
#

have dedicated email working in prod now. Emails come from info@lanesflow.io ๐Ÿ˜„

inland oak
ionic raft
#

Now I have to code a webhook for Stripe

ionic raft
inland oak
#

I think I will never go for front.

I already go for too many back directions.
Backend/devops/devsecops/architect

ionic raft
#

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

ionic raft
#

Jenkins methinks...

inland oak
ionic raft
inland oak
#

Quite recommending gitlab, I love it

ionic raft
#

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

ionic raft
#

I'm using checkout...

inland oak
#

That is my current task

ionic raft
#

I think I need to throw a webhook function in the view

inland oak
#

I can say that integration itself is not the hard part

#

Hard part is passing security audit known as PCI DSS compliance

ionic raft
#

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! ๐Ÿ˜„

inland oak
ionic raft
rotund perch
#

Hello guys, I wanted to ask does django needs any additional security checks or packages to be ready for production?

ionic raft
rotund perch
#

heroku deployment, is it safe enough?

ionic raft
rotund perch
#

only ?

ionic raft
ionic raft
rotund perch
rotund perch
ionic raft
#

OK. Well, you've got the most obvious elements prepared.

ionic raft
# rotund perch Postgres

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.

rotund perch
#

Okay Thank you ! really appreaciate your help!

ionic raft
#

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

broken mulch
#

What's the best way to remember a user's login session?

autumn hedge
#

@broken mulch use cookies

broken mulch
#

ok

#

httpOnly?

#

what does discord do

#

I think discord uses WWW-Authenticate

autumn hedge
#

discord most likely using some sort of auth token

broken mulch
#

yeah they are

#

so if i use cookies

#

will there be security issues?

autumn hedge
#

theres always security issues. Auth tokens are more secure

#

do some research on google

distant trout
#

does someone know if node media server scales for live streams?

broken mulch
#

Alright, how would I do Auth Tokens

#

in React.js

#

HTTP headers are not visible

broken mulch
#

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

autumn hedge
#

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

whole valley
#

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

frank grove
#

Hi, im in github and trying to add this thin line after a header

#

how do you add that line after "materials"

broken mulch
ionic raft
#

Well, that was interesting...building a Stripe webhook ๐Ÿ˜„ Did it though. Bit of a journey to get there

ionic raft
ionic raft
frank grove
#

@ionic raft i believe so, unless there is a better alternative

ionic raft
copper hinge
#

@frank grove you can use three or more asterisks, dashes or underscores

#

e.g.

#
***

---

_________________
lost pivot
#

thank you both @thorn igloo and @opaque rivet , your site really helped me!!

frank grove
#

@ionic raft thanks!

tranquil fossil
plucky swallow
#

how should i structure my dashboard flask app so i can easily update data sources?

manic frost
#

@broken mulch a benefit of cookies is that they're sent with all HTTP requests, including, for example, images

cerulean badge
#

(context django) if you are going to add a minvalue and maxvalue validator to a integer field anyway should you use IntegerField or PositiveIntegerField?

ionic raft
#

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.

cerulean badge
#

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__?

ionic raft
#

__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.

cerulean badge
#

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?

ionic raft
# cerulean badge 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!

cerulean badge
#

ok thanks

vestal hound
#

that's extremely impressive

ionic raft
vestal hound
#

I hope you are Following Proper Software Engineering Practices though

#

๐Ÿ˜‰

ionic raft
# vestal hound that's extremely impressive

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 ๐Ÿ™‚

vestal hound
#

it sounds like @ least you have good planning skills

ionic raft
#

But yeah...this Discord....I don't know I would have done it without this Discord.

vestal hound
#

which is something people often fail to understand makes a big difference between "writing code" and "engineering software"

ionic raft
# vestal hound do you mind sharing what you did before?

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.

vestal hound
#

that explains the planning experience

#

figured you were some sort of BA/PM

ionic raft
vestal hound
#

nope...?

ionic raft
#

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

ionic raft
vestal hound
#

the acronyms...

#

are a very marketing-oriented thing

vestal hound
#

I know what you mean

inland oak
#

!rule 5

lavish prismBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

rigid anvil
#

my bad im sorry

rigid anvil
#

lol

#

I thought i could get help on this server

inland oak
#

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.

rigid anvil
#

But im not even using threading or async, it is just a simple program to learn python requests

#

understood tho

#

srry

inland oak
#

or if you have consent

rigid anvil
#

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

past cipher
#

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

velvet yew
#

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>

https://codepen.io/martinmarko/pen/NWjoLOb?editors=1000

past cipher
#

it is 100% height already

#

minus the text block

velvet yew
#

It's more than 150px height

#

I want it to be 100% minus the text div's height

past cipher
#

the div container is 150px in height in total

velvet yew
calm plume
velvet yew
past cipher
#

do as dawn said

#

or hide overflow

velvet yew
velvet yew
#

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>
ionic raft
# vestal hound are a very marketing-oriented thing

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.

native tide
#

Yello...Anyone online...I need help on django

opaque rivet
#

@mystic lotus wrong server mate

mystic vortex
#

Someone help

opaque rivet
#

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?

mystic vortex
#

Helle I need help with js and django

#

Plz help

#

Help

#

Help

#

๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ

eternal blade
#

just send your question

opaque rivet
#
upstream backend { 
    server backend:8000;
} 

server { 

    listen 80;

     location / { 
        proxy_pass http://backend; 
    }
}
mystic vortex
#

Someone tell me how to get a response in django when I visit a site made with js

opaque rivet
#

@mystic vortex make an API with django-rest-framework. Send API requests from your JS frontend.

mystic vortex
eternal blade
#

But didnt you ask "response in django"?

mystic vortex
#

But how?

#

Is it possible

#

??

eternal blade
#

send a request to the backend api

nocturne juniper
#

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?

mystic vortex
#

Can I send request from one machine to another using it?@eternal blade

eternal blade
#

You can send a request to any valid domain or ip using that method

mystic vortex
#

Hmm

#

@eternal blade do u know any tutorial that explains how to do this?

eternal blade
#

no

native tide
#

Hello, how do I set permission for a logged in user on django ? Using decorators or something else ??

opaque rivet
#

@mystic vortex simply searching "how to make an API with Django"

mystic vortex
#

Lemme try to make one

opaque rivet
#

When your frontend and backend run in different context, they will have to communicate via an API.

mystic vortex
#

I have to send a http request right?@opaque rivet

eternal blade
#

http request

mystic vortex
#

Me dumb

opaque rivet
#

Yes, your frontend and backend will communicate via http requests. APIs are an important topic, so learn them well

opaque rivet
#

@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.

nocturne juniper
#

It's the same domain, just a matter of www. and no www.

eternal blade
#

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?

opaque rivet
#

@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.

native tide
#

Have you tried this hack

#

from django.contrib.auth.models import User
User._meta.get_field('username')._unique = False

eternal blade
mystic vortex
#

@opaque rivet what libraries are there that can do this http request and post

opaque rivet
#

For JS, I use axios

mystic vortex
#

@opaque rivet I need to post the data from my frontend or I need to request the data from backend?

opaque rivet
#

You make a request to your backend from your frontend. The backend returns a response.

#

That's the request/response cycle

mystic vortex
opaque rivet
#

It will send a request. Not a response

mystic vortex
#

Oops

opaque rivet
#

Django views take in a request and return a response

mystic vortex
#

What is request library used for

#

??

opaque rivet
#

For making requests

mystic vortex
#

So shall I use it or can I use flask

#

Will it be able to do that?

opaque rivet
#

Flask is a backend

mystic vortex
opaque rivet
#

Yes you can make an API with flask

mystic vortex
#

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

ionic raft
#

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.

dusk portal
#

r u there plz i need help asap @ionic raft

ionic raft
dusk portal
#

u have worked with OneToOneField?

ionic raft
dusk portal
#

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 %}```
ionic raft
dusk portal
#

ohh

#

how can i do that my OneToOneField

#

i have done say thing with ForiegnKey

#

;-;

dusk portal
ionic raft
# dusk portal how can i do that my OneToOneField

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.

dusk portal
#

for loop

ionic raft
dusk portal
#

yes

#

wait lemme try

ionic raft
#

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.

dusk portal
#

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

rotund perch
#

I think remove for loop?

thorn igloo
dusk portal
#

um um

#

yues

dusk portal
#

u were right

dusk portal
rotund perch
#

yea just show up ur data once without a loop

dusk portal
#

bro

#

im making Profile page

#

i have to use for loop

#

damn

rotund perch
#

why?

ionic raft
rotund perch
#

u dont need a for loop to show the profile? or do a profile page

dusk portal
#

XD

ionic raft
dusk portal
#

i need a loop cez how would i render that by db then

ionic raft
dusk portal
#
@login_required
def profile(request):
    queryset=Profile.objects.get(user=request.user)
    return render(request,'users/profile.html',{'queryset':queryset})```
#

ohk correct?

rotund perch
#

ok go to ur html and remove for loop

dusk portal
#

done removed now

ionic raft
dusk portal
#

@rotund perch

rotund perch
dusk portal
#

yes done it working but how will i retrive the user PROFILE now

rotund perch
dusk portal
#

class Profile(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE)
image=models.ImageField(default='default.jpeg',upload_to='Profile_Pics')

dusk portal
#

how can i retrive now i have to use for loop

#

;-;

ionic raft
ionic raft
rotund perch
ionic raft
ionic raft
dusk portal
ionic raft
#

Showing you how to work through a list for a OtO field in a template is not helpful

rotund perch
#

{% queryset %} i think?

dusk portal
rotund perch
#

sorry {{ }}

dusk portal
#

i have done that by FK in ecommerce for order history

ionic raft
#

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 %}
dusk portal
#

ezz

rotund perch
dusk portal
#

;-;

#

no need of for?

rotund perch
#

no just put {{queryset}} in the h1

dusk portal
#
    <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')```
ionic raft
dusk portal
#

ohk trying

ionic raft
#

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 ๐Ÿ˜„

dusk portal
#

its my 3 month

#

django , its rest framework

#

and channels

ionic raft
#

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

dusk portal
#

TypeError at /account/profile/
'Profile' object is not iterable

ionic raft
dusk portal
ionic raft
dusk portal
#

doing same thing but different model types

#

differ

#

too much

ionic raft
#

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.

dusk portal
#

ohh

#

but i have to do with OneTOOneField

#

done

#

changed that get to filter

#

and it worked

#

LoL

ionic raft
#

Yes. You could do object.objests.filter(user=request.user) but it's slightly less efficient

dusk portal
#

XD

ionic raft
#

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.

dusk portal
#

umm

ionic raft
# dusk portal XD

OK. It sounds like you've got some momentum. I'm off to turn two InlineFormsets into dynamic forms with htmx

dusk portal
#

but i feel depressed

#

i feel low

#

i feel bad