#web-development

2 messages · Page 134 of 1

glossy arrow
#

Hm

#

I guess I could help

native tide
#

So many ads that it can bring a AMD Eypc 128core CPU to its knees

spare iris
#

pls I haven’t coded in a while that I basically forgot most of python

native tide
#

xd

#

You'll find it again

spare iris
#

just doing hackerrank

hybrid bobcat
#

@native tide so what did you ping me for? do u have an answer to my question?

native tide
#

@hybrid bobcat no just your profile pic

native tide
#

@hybrid bobcat ask @glossy arrow

glossy arrow
#

Hm?

native tide
#

Aboo may have an answer to your issue. They're our local Flasker

#

@glossy arrow this is his question

glossy arrow
native tide
#

Wait for your issue wouldn't you want to remove the <path: part?

#

@hybrid bobcat I assume

#

I'm a bottle guy

native tide
#

But if its like bottle remove the <path part

glossy arrow
#

Most micro frameworks work the same

native tide
#

you already know the path

#

you just want the file

hybrid bobcat
#

i dont know the path, theres a lot more static files in the folder

glossy arrow
#

So your code can't locate your static files?

native tide
#
@app.route('/static/css/<filename>')
def static_files_css(filename):
    return send_from_directory('static', filename=filename)```

Try this
#

filename can be an absolute path + filename or filename

hybrid bobcat
#

no idea why

#

i changed nothing

glossy arrow
#

Maybe set the static files manually?

#

app = Flask('flaskapp', static_url_path='/static')

native tide
#

Aboo

#

TIL:

#

you can use CSS to do absolute positions

hybrid bobcat
native tide
#

TIL

glossy arrow
native tide
#

did you know you could do position: absolute?

#

then left: x
top: y

toxic flame
#

lol

glossy arrow
#

Lol

native tide
#

Why did no one tell me this before

#

this is magic

glossy arrow
#

I'm not that great with css

native tide
#

I can cram more ads onto a page

#

MORE ADS!

glossy arrow
#

I know enough to get by though lol

native tide
#

shoves 80k ads into a page designed to fit on a iPhone screen

glossy arrow
#

Lmao

native tide
#

yea

#

I'm not a HTML guy

#

does it show?

#

So yea no ideas

vestal hound
native tide
#

@vestal hound why not absolute?

toxic flame
#

i believe fixed is to ur screen width

vestal hound
#

that would be fixed

toxic flame
#

also sticky is fun to play with owo

native tide
#

@vestal hound I don't get static

#

so static means it will always flow with the page in an absolute position

toxic flame
#

why don't you google it

#

I'm sure google will show up an article that will display what you want to know 40% more detailed

native tide
#

I did google it

#

I'm still confused.

#

not a web developer

#

magic

toxic flame
#

oh

native tide
#

yea

#

so my understanding is fixed is fixed in it's viewport

toxic flame
#

Well

native tide
#

@toxic flame

#

so

#

ugh

#

hm

#

So the view port is like looking out a car window

#

and a fixed position is like a tree

#

the viewport can move and the tree will stay in the same position relatively?

#

Did I get that right...?

#

So static would follow the view

native tide
#

is it possible to add multiple of the same object to django's m2m field?

dapper tusk
#

I think django lets you set a custom through model which could have a count field

muted grove
#

Hello! I am using Flask to build a web portal to connect to a Discord bot. I am running into a bit of an issue with one specific part. I need the user to be able to enter in a date and time into a form, but the users could be anywhere in the world. I then need to be able to translate that time, which is theoretically set from any timezone in the world, to a UTC timestamp. Anyone know how I might do that?

vestal hound
#

okay so

#

basically everything in HTML is a rectangle.

#

by default, those rectangles will appear in the order you define them

#

left to right, and top to bottom.

#

so if everything on your page is static, it'll follow that order

#

however, you can also change the position attribute of individual elements, which will change how they render.

#

in particular, fixed and absolute take elements out of that flow entirely

#

and position them on the page according to coordinates that you provide

#

the difference between fixed and absolute is whether they take reference from the viewport (fixed) or their parent element (absolute).

opal needle
#

Where’s a good place to get started with django html and css

#

Also do I require to know is ?

vapid rivet
#

Anyone actually using Fabric2 for Django deployments? Seems like the complexity for the upgrade has everyone using some v1 base fork for Python3 compat.

umbral hatch
#

Why am I getting this https://pastebin.com/v9wCsP0m error in Django when trying to use a model from another app? django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet. I have searched online quite a bit and cannot find any information that helps me. Is it common to have to import models from other apps, or am I using poor design? ```python
from django.db import models
from django.apps import apps

User = apps.get_model('discord_user', 'User')
EnumModel = apps.get_model('registry', 'EnumModel')

Create your models here.

class HairColor(EnumModel):
pass

class EyeColor(EnumModel):
pass

class Race(EnumModel):
abbreviation = models.CharField(null=True, max_length=25)

class Sex(EnumModel):
abbreviation = models.CharField(null=True, max_length=25)

class Character(models.Model):
first_name = models.CharField(max_length=15)
last_name = models.CharField(max_length=15)
height = models.FloatField()
weight = models.IntegerField()
image = models.ImageField(null=True, upload_to="character_images/")
hair_color = models.ForeignKey(HairColor, blank=False, null=True, on_delete=models.SET_NULL)
eye_color = models.ForeignKey(EyeColor, blank=False, null=True, on_delete=models.SET_NULL)
user = models.ForeignKey(User, on_delete=models.CASCADE)
sex = models.ForeignKey(Sex, blank=False, null=True, on_delete=models.SET_NULL)
race = models.ForeignKey(Race, blank=False, null=True, on_delete=models.SET_NULL)
dob = models.DateField()
is_deceased = models.BooleanField(default=False)

def __str__(self):
    return f"{self.id}: {self.first_name} {self.last_name}"

``` This is the file that errors on line 4: User = apps.get_model('discord_user', 'User'). The User variable is only used in the "user" field under the Character class user = models.ForeignKey(User, on_delete=models.CASCADE)

indigo kettle
#

can you do from discord_user.models import User ?

#

instead of this apps.get_model thing?

#

@umbral hatch

#

I'm not really sure of the structure of your models here

#

is User a model inside of discord_user?

umbral hatch
umbral hatch
#

This is User model ```py
from django.db import models
from django.contrib.auth.models import AbstractUser

Create your models here.

TODO: Discord-based user

class User(AbstractUser):
pass

indigo kettle
#

ah ok

#

you can define foreignkeys with string

umbral hatch
#

Oh, that would be simpler I guess. Is that what is normally done?

#

I guess I wouldn't really need to import the models then?

indigo kettle
#
user = models.ForeignKey('discord_user.User', on_delete=models.CASCADE)
#

I would do it this way to prevent this problem, yes

umbral hatch
#

except for EnumModel, I'll see if I get the same error for that

#

yep

#

exact same issue, and I need to import EnumModel to inherit the class

umbral hatch
#

User = apps.get_model('discord_user', 'User', require_ready=False) this "worked" but the documentation states "When require_ready is False, get_model() returns a model class that may not be fully functional (reverse accessors may be missing, for example) until the app registry is fully populated. For this reason, it’s best to leave require_ready to the default value of True whenever possible." If someone knows of a better solution please let me know

indigo kettle
#

I've never used apps.get_model before

#

so I'm sure there's a way to do it without that

#

what does your registry.models look like?

#

maybe you can use the string foreignkeys there as well so that you do not have to import from whatever this models.py file is

umbral hatch
#

@indigo kettle registry.models looks like this ```py
from django.db import models
from django.apps import apps

class EnumModel(models.Model):
name = models.CharField(max_length=40)

def __str__(self):
    return self.name

class VehicleColor(EnumModel):
pass

class VehicleMake(EnumModel):
pass

class VehicleType(EnumModel):
pass

class Vehicle(models.Model):
character = models.ForeignKey("Character", on_delete=models.CASCADE)
license_plate = models.CharField(max_length=25)
vehicle_type = models.ForeignKey(VehicleType, null=True, on_delete=models.SET_NULL)
vehicle_make = models.ForeignKey(VehicleMake, null=True, on_delete=models.SET_NULL)
vehicle_color = models.ForeignKey(VehicleColor, null=True, on_delete=models.SET_NULL)

class WeaponType(EnumModel):
pass

class Weapon(models.Model):
character = models.ForeignKey("Character", on_delete=models.CASCADE)
weapon_type = models.ForeignKey(WeaponType, on_delete=models.CASCADE)

class LicenseType(EnumModel):
pass

class LicenseStatus(EnumModel):
pass

class License(models.Model):
character = models.ForeignKey("Character", on_delete=models.CASCADE)
license_type = models.ForeignKey(LicenseType, on_delete=models.CASCADE)
status = models.ForeignKey(LicenseStatus, null=True, on_delete=models.SET_NULL)
``` I switched to using string foreignkeys, and it appears that only works for models defined in the same app. I am getting a lot of errors saying something along the lines of registry.Weapon.character: (fields.E307) The field registry.Weapon.character was declared with a lazy reference to 'registry.character', but app 'registry' doesn't provide model 'character'.

#

oh wait

#

I need to specify the app duh. Should be civilian.Character

indigo kettle
#

yep exactly

umbral hatch
#

@indigo kettle That worked, thanks for the help

indigo kettle
#

np

mortal mango
#

I set up a django project on ubuntu with nginx and uwsgi. The problem is that none of the images are loading. When I go into inspect > console, it says the server responded with 500 when trying to get the images. Does anyone know how to fix this? I tried changing permission to 777 but that didn't work.

barren moth
#

Glad it was recommended.

#

FastAPI is seriously powerful.

native tide
#

How do I use JavaScript with Flask?

toxic flame
#

just include it in your template

barren moth
native tide
toxic flame
#

Then serve static files

native tide
turbid estuary
#

any way I can create a confirmation message in flask?
I made a delete button and I want to prompt user "Are you sure you want to delete this?"

marsh kite
#

can anyone help me with spoify API called spotipy?

elfin ermine
#

!paste

weary belfry
#

hello

#

Can anyone tell me that how to give user only one option to input the value
like either he uploads the text file or copy paste the text code in the flask page
?

shrewd oasis
#

Hi

#

I new here.

#

Does anyone know django rest framework?

opal needle
#

do you guys recommend i learn web developement using python?

#

or the generic languages

brisk spear
#

Depends on u

#

What excites u more

silver plank
#

what exactly do you mean? django and flask only lets you write the backend.. you wont get around HTML/javascript either way

brisk spear
#

Hey amnesia

#

I have a problem

#

Are u well versed with flask and its database?

silver plank
#

not even a little bit, I've never used Flask at all actually

#

sorry

brisk spear
#

Ohk

#

Anyone good with flask and its database pls ping me

native tide
#

Hello i have a problem with my venv in django

#

all package is installed to

#

Python packages not installing in virtualenv using pip
When i launch my project he dont use the venv but the AppData\Local\Programs\Python\Python39\Lib

wicked elbow
#

to plain? it just doesnt feel right... just cant put my finger on why

wicked elbow
vestal hound
#

this kind of looks like it was built in 2005 or something

#

no offence

#

well

#

not all of it

#

the input part does

#

also "Creator" isn't aligned

#

which makes it look weird

#

or at least it doesn't look aligned

uneven wren
#

Hi am trying to do pagination in Django using javascript and am pretty done, but now i ve run to a problem. Website is not translating django tag urls. How can i solve this ?

not whole code.

data.map((restaurant) => {
container.append(`
          <div class="col-xl-3 col-lg-4 col-md-6 mb-4 restaurant">
  <div class="bg-white rounded shadow card card-hover">
      <a class="card-link" href="{% url 'restaurant_detail' slug=restaurant.slug %}"> ${restaurant.name}</a>
</div>
</div>`)}
wicked elbow
#

thats what im saying. its not set in stone. its bottom aligned

vestal hound
#

colour scheme seems a bit off

wicked elbow
#

whole site is that color scheme.

vestal hound
wicked elbow
# vestal hound what?

im saying it doesnt look quite right. like it works, but not super modern. and the creator is bottom aligned with the username

vestal hound
#

might be a function of different font size and font weight

#

shrugs

#

anyway the main thing is the input

#

when was the last time you saw an input field with a full black border

#

on a social media website

wicked elbow
# vestal hound how did you come up with it

i pulled the original scheme of a website scheme builder. then it was to plain so i added the dark redish brown/green because they are complimentary colors to the blue and tan

vestal hound
#

well

#

you do you

#

it looks a bit odd to me

wicked elbow
vestal hound
#

what font is that

#

is that Arial

#

I think you might want to consider a different font

wicked elbow
#

my font choices font-family: Quicksand, Helvetica, sans-serif;

vestal hound
#

it's giving me 2000s vibes

#

I suspect

#

your line-height is too low

#

incidentally

#

I feel like the alignment of almost everything is weird

wicked elbow
#

i dont have quicksand so its pulling Helvetica i think not sure

vestal hound
#

I Googled Quicksand and it doesn't really look like what you have there

wicked elbow
#

its a common font, my pc is just really old

vestal hound
#

@wicked elbow some small things

#

also...I get the vibe that you are randomly throwing colours around

#

I can see no discernible pattern

#

to when you are using which colour

#

which confuses me, as a user

vestal hound
#

I hope you will forgive my bluntness

wicked elbow
#

the blue is used in page link bars, the tan is the side bar colors, the green is anything editable, and the dark reddish color is for NSFW posts.

#

the blue is also used for SFW posts

vestal hound
#

but WHY?

wicked elbow
#

i drew them out of a hat? lmao

vestal hound
#

like you don't just arbitrarily assign colours

#

to actions

#

okay

#

for example

#

look on Instagram

#

and tell me

#

what you associate black with

#

the website, not the mobile app

#

never mind, I'll just tell you

#

everything black is clickable.

vestal hound
#

the rest send mixed signals

#

okay I suggest

#

go read some UI/UX articles on colour palette construction and usage

#

because (correct me if I'm wrong) it REALLY feels like you're just throwing colours around randomly

wicked elbow
#

ya. nothing is set in stone. its my style sheet, and its only like 7 lines to completely change the scheme.

vestal hound
#

it's not about which colours you choose for your scheme

#

it's about what each colour MEANS

buoyant shuttle
#

anyone used web2py

vestal hound
#

okay for example

#

for my website

#

everything in the primary colour is an action

#

100%

#

and the primary colour is not used for anything else

wicked elbow
#

i got a thumbs up from my web designer friend who works for a firm in NZ.
thats how my site is too. its uniform across the pages.

vestal hound
#

if you're fine with it

#

so am I

#

just one last thing

#

"web designer" can mean many things

#

there's some overlap between frontend dev, UI designer, and UX designer

#

but each of them do unique things

#

and all skillsets are necessary to make something good

#

that's point one

#

actually, I'm just going to stop at point one because the rest is irrelevant

wicked elbow
#

eh, i just know theres like 10k lines of code to put this whole thing togther. worked on it for about a month now

#

not perfect, by any means. im wearing to many hats

vestal hound
opal needle
#

Js, php

wicked elbow
#

theres a lot more options then that

opal needle
#

Well that covers the use of python correct ?

#

Cause you need html and css

vestal hound
#

huh.

#

well

#

I mean

#

for backend the popular options are Java, PHP, Python, and JS

wicked elbow
#

c# and ruby as well

vestal hound
#

do you intend to be working with anyone?

#

and how good of a coder are you?

#

ye I forgot Ruby

opal needle
#

Well I would say I know more than the basics of python

#

And basic html

vestal hound
#

hm.

#

how many languages

opal needle
#

And no by myself

vestal hound
#

do you know

opal needle
#

Actually know or just the minimal basics

wicked elbow
#

i dont know flask, so cant comment, but django to me had a huge learning curve. its like its own language in itself

#

python wise

vestal hound
#

I would suggest you stick with Python

#

if you're still a beginner

#

might as well leverage your existing ability

#

and get good @ one language

#

that

opal needle
#

But wouldn’t learning django be more harder in the long run ?

vestal hound
#

or do a full JS stack

opal needle
#

Hm ok

#

Php or js

vestal hound
#

...why?

wicked elbow
#

not any different then php or js. a language is a language. each has their own quirks

opal needle
#

Hm k

#

I just heard from people django is very hard to learn

vestal hound
#

I don't think so...?

#

but anyway

#

that's not something you'll know

#

until you try

#

different people have different learning speeds

wicked elbow
#

you can learn flask as well, its not django thats hard, its the syntax you have to use to accomplish things, but again thats true of every language. its still python you just have to do things a certain way

opal needle
#

Hm k

#

Thanks

wicked elbow
#

basic django is easy, once you get the hang of it.

uneven wren
#

Sorry for reposting this
Hi am trying to do pagination in Django using javascript and am pretty done, but now i ve run into a problem. Website is not translating django tag urls. How can i solve this ?

not whole code.

data.map((restaurant) => {
container.append(`
          <div class="col-xl-3 col-lg-4 col-md-6 mb-4 restaurant">
  <div class="bg-white rounded shadow card card-hover">
      <a class="card-link" href="{% url 'restaurant_detail' slug=restaurant.slug %}"> ${restaurant.name}</a>
</div>
</div>`)}
wicked elbow
#

wish i could help, i went with front end pagination. so i could control it better

vestal hound
#

^

uneven wren
#

its pretty much working, but its taking the ulr as string

wicked elbow
#

im still not much help. i do everything through an api. everything is done in json

uneven wren
#

i was googling like a mad man, but found nothing sadly

outer pier
#

does anybody know how to refer a model to more than one type of users
i have normal users and some other special users . I want to refer both this user into one model . so whenever I call normal users django should automatically switch to that users and whenever I call special users django also should do so . with my limitted knowledge I cant use foreign key . Is there any better solution . somebody help plz

vestal hound
#

I didn't really understand that

#

you mean like

#

uh.

#

why can't you just have a BooleanField or somethign

outer pier
#

but how

vestal hound
#

honestly

#

I don't really get what you're trying to do

#

maybe you can give an example

outer pier
#

say that model is posts . so whenever a normal user want to post something django post model should refer to the normal user so that he can post posts . or else it should refer to the special users who can post

vestal hound
#

what do you mean "refer"

outer pier
#

just we do the same with foriegn key

vestal hound
#

so what makes a special user "special

#

"

outer pier
#

if there is no second user could we easily do it with foriegn key no ??

#

take normal user as may be like teachers and special users as students . just like so .

vestal hound
#

this doesn't really say much.

#

what is the difference?

#

in terms of attributes

outer pier
#

actually i am doing a project on social media, the normal users are the people like us . special users are the organisations who registered in this social media

#

I created a model shared so that both users can access it . so that I dont want to repeat the models in both of this model . All I want to switch according to users .

#

is there any way to achieve

vestal hound
#

do you need

#

2 separate models

#

?

#

for "normal" and "special" users

#

I don't see the point

outer pier
#

because both they have different functionalities . like an organisation user have branches . normal users doesnt have those functionalities

outer pier
#

No , like branches of a head organisation . I am just mentioning the differences between those users and the difference in their functionalities

#

but both of them have some functionalities in common . so i decided to create another app. but all i want to switch between users

vestal hound
#

uh

#

I feel like

#

you don't have a very clear data model

#

so I would suggest

#

you work on that first

vestal hound
#

you're talking about

#

business requirements

#

but my question is about how those affect your architecture

outer pier
#

let me clear it first . A user is simply a facebook type users . but an organisations users are those who can raise their company , invest on other companies . etc .... their functionalities are entirely different . but they have something in common . like both they can create posts . engage in group activities .

#

so and so ... so all i want to make their common tasks into one seperate app ...

vestal hound
#

...so what's your data model?

outer pier
#

u mean the common database model right ?

vestal hound
#

no.

#

in other words, what's your plan for reducing business requirements into code

outer pier
#

sorry i dont have a vast knowledge

vestal hound
#

okay

#

let me

#

explain

vestal hound
#

you are asking the wrong question

#

because

#

you only understand

#

what you want from a business perspective

#

but not

#

how to plan

#

the data/software architecture appropriately

outer pier
#

yah , may be right . I wish I know it all

vestal hound
vestal hound
#

to be better able

#

to ask the right questions

outer pier
#

ok thankyou . but atleast can you explain how to achieve method overloading in django

outer pier
#

could you suggest some good reference .

vestal hound
#

nope

tiny patio
#

where should i learn flask microframework of python

native tide
#

Hello i have a problem with my venv in django
all package is installed to
Python packages not installing in virtualenv using pip
When i launch my project he dont use the venv but the AppData\Local\Programs\Python\Python39\Lib

brisk spear
#

Now I myself am learning flask but it's not going on good track

#

Facing a tough time

tiny patio
#

mm

#

but i cant find the right channel

brisk spear
#

U use what?

#

Linux, windows, mac

tiny patio
#

win

brisk spear
#

Ohk

#

See what I suggest

tiny patio
#

mm

brisk spear
#

Watch multiple videos and find yourself which suits u best

#

Like whose language u understand

#

Etc....

tiny patio
#

English and tamil

brisk spear
#

By language I don't mean English and that

#

I mean which content creators way of explaining suits u

tiny patio
#

python

brisk spear
#

Bro u don't know hindi

tiny patio
#

mm no

brisk spear
#

You can check corey Schaefer, tech with tim, programming with mosh etc...

tiny patio
#

mm

#

thx for help

brisk spear
#

Bro I am facing problem with database

brisk spear
solemn thistle
native tide
#

So has anyone found a good project to work on

#

Or does anyone want to work on a communal project

wicked elbow
#

@vestal hound i made the input just for you, the color scheme and font ill work on. still working on where to put the reply at, i dont like where they are either

toxic flame
#

Are you using websockets owo

wicked elbow
mortal mango
#

I have a django project that's running on an nginx webserver with uwsgi. The problem is that none of the images are loading. When I go to example.com/static/gradient.jpg it works. The images loads. But when I go to the website, it's giving me 500 when trying to load the image. Does anyone know why this is happening?

In the image below, the app directory holds settings.py and the other "admin" files. The urlshort directory holds the django app files, like my templates, models, views, etc. All my images are located in the static directory. In my settings.py I have urlshort/static as the STATIC_ROOT.

#

I think I found the solution

#

urlshort/static is the wrong directory. Does anyone know how I could change it to /static? I tried changing the STATIC_ROOT directory in settings.py from urlshort/static to /static/ but that didn't work. It's still trying to get the images from urlshort/static.

wicked elbow
#

serving from nginx not django. django doesnt serve files in production mode. so youll have to modify from nginx. at least thats my guess @mortal mango

mortal mango
#

so in my .conf file?

#

@wicked elbow

#
# the upstream component nginx needs to connect to
upstream django {
    server unix:///home/internet/AtomURL/short_url.sock;
}

# configuration of the server
server {
    listen      80;
    server_name atomlink.tk www.atomlink.tk;
    charset     utf-8;

    # max upload size
    client_max_body_size 75M;

    # Django media and static files
    location /media  {
        alias /home/internet/AtomURL/urlshort/media;
    }
    location /static {
        alias /home/internet/AtomURL/urlshort/static;
    }

    # Send all non-media requests to the Django server.
    location / {
        uwsgi_pass  django;
        include     /home/internet/AtomURL/uwsgi_params;
    }
}
#

this is my .conf file

wicked elbow
#

i dont know anything about nginx configs unfortunately, im just telling you django doesnt serve files in profuction. your actually better off moving your static files to a seperate server and linking to them there

#

i use aws s2 for my static files, as for uploads, the correct path should be set in your database once its complete i would assume, havent tried yet

toxic flame
#

Just install whitenoise and pillow.

hybrid bobcat
#

Does anyone have solution for Flask not serving static files? I'm using the Flask default url base endpoint /static for static files, and that's how my template files reference them like href="/static/css/main.css" or smth like that. I'm currently using the Flask server for that and am not planning on using Nginx or any other web servers just yet. I swear it was working fine just yesterday and now it's not today, the web page looks crap without css and favicons. I even tried clearing the browser cache and cookies and trying different browsers but still the same results, does any have a solution to this?

cedar niche
#

Hello I'm looking for some help with Django-tenants.
My project is a work order management system for mills. I have a postgresql database where each schema is a different mill location. How would I be able to switch between locations(schemas)? currently I do this

 <li>
  <div class="container-fluid">
   <div class="col-xl-6 col-md-6 mb-4">
    <a href="http://{{ mill.domain }}:8000/index">
    <div class="card border-left-primary shadow h-100 py-5">
    <div class="card-body">
    <div class="row no-gutters align-items-center">
    <div class="col mr-2">
    <div class="text-xxl font-weight-bold text-primary text-uppercase mb-1">
    {{ mill.domain }}                                          </div>
   </div>
   </div>
   </div>
    </div>
    </a>
    </div>
    </div>
    </li>

Which works in a testing env but not when trying to deploy

#

Essentially I want to have a card with the name of the location (Location1) and when you click on that card it will take you to the index page for that location. Which would have the domain https://location1.workorder.com

vestal hound
#

there is literally NO app or framework I can think of that uses square black border in 2021

wicked elbow
#

unless your talking the buttons border

wicked elbow
#

lol i know i changed it the youtube comment bar, and reply bar. it took like 10 minutes to do

vestal hound
#

okay

#

I know what turns me off

#

for the button

#

it’s too dark

#

accessibility issues

#

so basically there’s a guideline that says

#

you should have a certain contrast ratio

#

for all your text

#

this is especially important for visually impaired users

#

I’m eyeballing it but my gut feel is that the shade is a bit dark

#

so it might be hard for some people to see

#

AESTHETICALLY it’s not a problem (and would be subjective anyway)

wicked elbow
#

button only shows when the comment input has been entered. and the button clocks in at 10.01 and chrome says its good in terms of contrast. its not black on white. thats like a 21, but anything above like a 4 is considered ok in chrome

vestal hound
#

also

#

re: positioning

#

this might be useful if you haven’t read it

vestal hound
#

I’m not good with colours tbh

#

my colour vision is average to below average

#

so I’d say go with what Chrome says

#

also I’m seeing it with night mode on

#

what’s your font size btw

wicked elbow
#

the logo i need to make darker, because that tan is to light on white. just havent done it yet

#

im using a 12px standard, links and headers are 16 i believe, but headers are bold as well. some things are 10px. looks good on my pc 1920x1080. might be large on smaller screens. i need to convert to em

#

i lied, the font size in that comment section is a 14px

vestal hound
#

12 is very small.

#

Google minimum webpage font size

wicked elbow
#

i dont like large fonts, but i could see 12px being to small. like i said stuff like the timestamps are 10px on the comments. i had the font bigger, but it seemed to big

vestal hound
#

when I changed

#

but I’d say the guideline exists for a reason

#

I can personally make do with 12

#

and honestly it’s a PITA to handle 16 on mobile

#

you run out of space super fast

#

I guess the question is: how much does accessibility matter to you?

wicked elbow
#

okay so if you look at that picture, the username is 16px, the creator is 12px, the comment is 14px, and the timestamp is 10px. which is why it may look slanted to some.

vestal hound
#

I think the RATIO is good

#

but the comment is basically body text

#

which might be a bit small.

#

is all

#

it’s not egregiously tiny

wicked elbow
#

yea, fonts/sizing/spacing i planned on working last. its a whole job in itself. im just trying to make the user not scroll to see content. like i think youtubes fonts are to large honestly. and thats running 1080p. sizing is one of those dumb cases. that some things are good for some people, but to small for someone else and vice versa

vestal hound
wicked elbow
#

already have one. and it looks good on my phone

vestal hound
#

on desktop you have a ton of space so you can change fonts later

#

but IME

#

increasing font size on mobile is nontrivial

#

all of a sudden you have two buttons that can’t fit next to each other

wicked elbow
vestal hound
#

which is just 😦

wicked elbow
#

yea, i ran into that issue. but my mobile site cant be zoomed. so i dont have to worry about it not fitting

vestal hound
#

I don’t get it

#

what does zooming have to do with it

wicked elbow
#

i guess nothing. zooming isnt the same on mobile as it is in a desktop browser. my bad

#

ive converted anything that doesnt need to be text it icons. so font size dont matter so much

#

there is a bug in that in case you look at it. the register will register you, but itll white screen you. i fixed it, just havent updated the code yet

vestal hound
#

okay again IME

wicked elbow
#

i google the icons and modify to my color scheme

vestal hound
#

after I started user testing

#

I realised HOW UNINTUITIVE SOME ICONS CAN BE

#

or rather

#

how much potential for misunderstanding

#

so I redesigned more or less everything to either be text only

#

or icon and text

wicked elbow
#

i suppose my text is a little small on mobile, at least in the browser dev tools

vestal hound
#

because there were times I was thinking “obviously this icon is appropriate”

#

and my user would be confused af

vestal hound
#

etc.

#

and when you have relatively low contrast AND small text

#

it can be hell to read

#

is why 16px is the reco

vestal hound
wicked elbow
#

lol if the site takes off, the first person i hire is a UI designer. cause i just dont have an eye for it. i mean ive only been doing this for 2 months, and wearing all the hats mediocrely. theres like 300 some files to be the site that it is. its insane.

#

im also changing the timestamps to be relative to now. so itll say 10m ago or whatever, just not been a top priority. trying to shrink things that dont need to be big to not be distracting

lament charm
#

Is building APIs from scrapped data something people do? I want to scrap my countries covid-19 data from the government website and build a graphql api from it.
I'm not exactly sure where to start though. I want to be able to host the API somewhere online and people can query from it and get the data. Could anyone point me in the right direction please?

formal axle
#

how would i make a website responsive lol, i looked on youtube but they didnt rlly help

formal axle
#

ok thanks lol

pulsar copper
hybrid bobcat
vestal hound
#

it's not as fluffy as many people think tbh

#

and when a site isn't designed with UX in mind it shows

maiden tulip
#

Hi, currently setting up a mail server. Is there any norm (like a IEEE or RFC) for mail names that should exist?
For example: admin, mail, info, noreply, ...

toxic flame
#

Any way in getting creative? 😂 😂 😂

|| Im just kidding ||

copper lagoon
#

i just moved from flask to quart
and my wsgi needs to be asgi


if __name__ == "__main__":
    app.run()```
 this is wgsi
how do i make it work for asgi?
#

ping me

vale charm
#
music = open(r"extra/music.mp3", "rb")


  <audio autoplay loop id="myaudio">
    <source src="{music}" type="audio/mp3">
  </audio>
```So for some reason my code doesn't work before you say anything rather than my file problem I tried a music file from google and it worked so it's my local file that's a problem!
vale charm
#

what

fallow void
#

I mean <audio ... > is in python file itself?

vale charm
#

i dont understand u

#

no

fallow void
#

music = open(r"extra/music.mp3", "rb")

vale charm
#

its an html file

fallow void
#

This line is python

vale charm
#

i wont show all

fallow void
#

so browser can fetch it from server

vale charm
#

yes i did that too

#

didnt work

fallow void
native tide
#

hey i got a quick question. I made some updates to my domain site and it works perfect locally, but when i try to update the domain via file manager on cpanel, it comes out different

jagged matrix
#

Hi, I need to use Jinja2 to copy values, the main aim is to automate a testing process, I've never worked with template libraries, can I ask about Jinja in this text channel?

cloud kestrel
#

hey guys, what module do you recomend more. flask or django

native tide
#

@cloud kestrel i love flask. it is simple and easy to use and you can expand it as much as you want. django is the opposite, but more powerful from the start.

marble pasture
#

hey there, i am new in django. Is there any mentor/project to join for a practice?

native tide
#

i have a question regarding streaming data in flask. my problem is this: i have a route that makes various API calls to update a dataframe. This takes several minutes. I want to run this route once a day in the morning with cron-jobs.org, but now that i deployed it to heroku, it sends a timeout after 30 seconds. The heroku timeout variable cannot be altered. But i thought i could send data after some seconds until i finally return success after updating.

#

i thought a way to do this is to yield some simple response while the function is running. does someone have a good and simple example how to do this in flask?

tardy heron
#

how do i show user a file picker to save a bunch of data to disk?

mystic grove
#
def load_user(user_id):
    return User.query.get(int(user_id))```
#

This is giving me error - TypeError: user_loader() missing 1 required positional argument: 'callback'

fallow void
#

you should remove those parenthesis

uneven wren
#

Hello, am trying to get cookies and django work for my cart in Django app.
Now ive run into problem.
cookie before paid..

{
"143":{"25":{"quantity":3}},
"None":{"25":{"quantity":3}}
}

when i pay i need to delete user and his cart from my cookie am using this:

def update_cookie(self, response):
  user_id = f"{self.request.user.id}"
  cookies = self.request.COOKIES
  cart = json.loads(cookies["cart"])
  del cart[user_id]
  response.set_cookie("cart", cart, max_age=settings.EXPIRE_DATE)

"{
'143':{'25':{'quantity':3}},
}"

where is the problem ? bcs then i cant use it as an object in my js even if i use JSON.parse its still a string

real mesa
#

dict can't have duplicates right?

north cedar
#

But for values, no

real mesa
#

yeah it's working fine for me in a scratch file

#
import json
cart = '{"143":{"25":{"quantity":3}},"None":{"25":{"quantity":3}}}'
cart1 = json.loads(cart)
del cart1["None"]
print(cart1)```
#

hey, I'm new here, how do you get python highlights?

#

got it!

uneven wren
real mesa
uneven wren
#

still the same why am i getting string in js when am parsing this from cookie:

"{
'143':{'25':{'quantity':3}},
}"
real mesa
#

Can you post the before (python) / after (JS)?

real mesa
uneven wren
#

i dont have duplicate keys

#

that "25" and "25" is in other object

real mesa
#

'25':{} was in both main keys. Because you were getting unexpected counts of results that Could* have been because of what you were calling out of them

#

I could be wrong, I didn't fully understand your question

formal gull
#

im starting to learn how to make websites and want to incorporate python into this learning. should i be going full into learning django or just use flask? django seems harder but im just looking for opinions if its worth it to just do more django

native tide
formal gull
native tide
#

i think you will end up gravitating towards django in the end, it's great to have a grasp of both though... that's how i started.

formal gull
#

flask seems easier to "get started" from what i am seeing as well

native tide
#

once I did a good chunk of flask, i actually started looking at django and I hated it so much, now I can't even remember how to make an api in flask lmfao

#

yeah it's a bit more beginner orientated, I think it has more guides/tutorials for beginners

#

and iirc codecademy has a course on Flask, it's pretty good

formal gull
#

ill have to check it out. yeah i started something in django and it was quite overwhelming tbh

native tide
#

the only reason I switched from flask -> django because looking at local job markets django was 2x in demand to flask

#

so just keep the long term in mind

#

but for fundamentals it's great

formal gull
#

yeah thats what im looking for is the fundamentals. as long as it isn't like a terrible transition to django in the end then 👍

native tide
#

oh yeah you'll be fine, the knowledge on what to do carries over, its just the how which changes. and all that changes is you'll just need to learn the django syntax

formal gull
bronze epoch
#

Hi All! Im trying to use Zeep for sending a SOAP request, the thing is that the request needs an attachment I cannot figure out how to send it. my request should look like:

<soapenv:Body> <ws:uploadContent> <!--1 or more repetitions:--> <uploadContentBeans> <number>1315856</number> <!--Optional:--> <revision></revision> <!--Optional:--> <iteration></iteration> <objectClass>Document</objectClass> <contentType>PRIMARY</contentType> <!--Optional:--> <limitedDownloadAccess></limitedDownloadAccess> <!--Optional:--> <securityLevel></securityLevel> <fileName>test.txt</fileName> <dataHandler>cid:test.txt</dataHandler> <checkinComments></checkinComments> </uploadContentBeans> </ws:uploadContent> </soapenv:Body>
As you can see we have fileName and dataHandler that references the name of the file to upload, but how can I attach it to the request?

limpid salmon
#

Anyone here running large mature codebase on NodeJS or Python (with MongoDB as the database)?

surreal horizon
#

Is there a way in flask to only allow a user to access a route by being redirected? Like they cannot simply type the route in the browser of something, they have to fill a form, and then be redirected to the route. if they simply type the route in the browser, they should be redirected back to the index page.

night patrol
#

I would like to use profile_form.instance.class_key in other views or make it a global variable.THe profile_form.instance.class_key variable only works on the register view('home.html' template).How can I make it work in other templates too? views.py

def register(request):
    registered = False
    if request.method == 'POST':
        user_form = UserForm(data=request.POST)
        profile_form = UserProfileInfoForm(data = request.POST)

        if user_form.is_valid() and profile_form.is_valid():

            user = user_form.save()
            user.set_password(user.password)
            user.save()

            profile_form.instance.class_key = request.user.class_key
            profile = profile_form.save(commit=False)
            profile.user = user 
            profile.save()

            registered = True
            return redirect('/login/')
        else:
            print(user_form.errors, profile_form.errors)
    else:
        user_form = UserForm()
        profile_form = UserProfileInfoForm()

    return render(request, 'home.html', {'user_form': user_form, 'profile_form':profile_form, 'registered' : registered})
I defined the forms and the models.
``` please help me...
native tide
#

what is considered advanced django? I haven't learnt anything new for django in a while now.

warped timber
#

Is there a way to have a flask error handler only apply to a specific path?

#

like only on /api/*(so I can return json error responses) but returning the default html error pages anywhere else

toxic flame
#

I started with django though

formal gull
toxic flame
#

Django is huge though ( using the default django starting )

#

I have seen flask and it does seem alot easier than django

#

But if I were to give an advice to my younger self, I'd tell myself to start with compiled lagnauges instead lul

wicked elbow
#

can you do this?

def create(self, request, *args, **kwargs):
  serializer_class = CommentLikesPostSerializer
  return super().create(self, request, *args, **kwargs)
``` change the serializer for just the create method?
nimble epoch
wicked elbow
#

should call the the default create im pretty sure. imma try it anyways haha

nimble epoch
#

but it should work

#

dont return it and i tried it actually with save methods of models

#

like super().save()

#

but anyway see how you do it

wicked elbow
#

since i have foriegnkeys, i need different serializers for the post, cause otherwise it doesnt work correctly

#

man, i make way to many migrations, good thing this is just the development database

#

why do peoples django code snippets look so huge? all of my stuff looks tiny compared to their code

mystic wyvern
#

hi. i have a simple question when i finish my project i have put him in a public server but if i search how to do this all of them tell me to buy something call domain and server ,should i buy them or can i do it for free like i make them?

#

Hope that's is clear.

wicked elbow
#

im using AWS servers for my project, youll want a domain though if you want a unique link for your page, most are pretty cheap, some as low as 8$ a year. but some hosting places, give you their domain to use. so up to you

mystic wyvern
#

@wicked elbow ok, i also want to know something ,if i done all thing (buy domain and server) the website will be work all time

wicked elbow
mystic wyvern
wicked elbow
# nimble epoch but anyway see how you do it
def get_serializer_class(self):
  if self.request.method == "POST":
    return CommentLikesPostSerializer
  return CommentLikesSerializer
``` that was the solution in case you wondered
elder echo
#

How can I make a portfolio website with python?

#

I know html and css

#

I'm trying to learn flask

#

but I don't want anything too hard

#

JUst something simple for fun

amber oxide
#

Is there anyone who would like to help me with django urlpattern?

amber oxide
# austere acorn sure

I want to create endpoint like 'admin/create/<ip_address>/", but I dont rly know how to create regex for this

austere acorn
#

ok

#

first you have to be carefult cause /admin is already used by django

#

are u aware of that ?

amber oxide
#

oh yes, u right

austere acorn
#

u can use a different name in development

amber oxide
#

Ill change it for api/create/

austere acorn
#

ok

#

so

amber oxide
#

Btw, I've created regex for retrieve it look like this r'^(?P<ip_address>(?:(?:0|1[\d]{0,2}|2(?:[0-4]\d?|5[0-5]?|[6-9])?|[3-9]\d?).){3}(?:0|1[\d]{0,2}|2(?:[0-4]\d?|5[0-5]?|[6-9])?|[3-9]\d?))/'

austere acorn
#

this is how it's done

#

i am not that good at regex

#

u can just use variables like that

#

then in views

#

the function should accept two arguments

#
def view(request,ip_address):
#

then u can do regex on it in the view

#

there are a lot of other data types, other than <str:>

amber oxide
#

yeah, I know about this types

#

btw I'm using DRF,

austere acorn
#

DRF ?

amber oxide
#

django rest framework

#

I'm affraid that this pattern will match anythink I put to the url

austere acorn
#

you can then check for the ip

#

in the view

#

match the string with how a proper ip address should look like

amber oxide
#

so I can do sth like validation in the view, right?

austere acorn
#

yes exactly

amber oxide
#

sounds good

austere acorn
#

imo that would be cleaner

amber oxide
#

yeah, u right

amber oxide
toxic flame
#

I can't seem to get the ip address

native tide
#

am i missing out on anything by using functional views > class based views, for django?

toxic flame
#

its the same

#

Both of them can do anything

#

Here u go

#

More context

glacial orchid
#

Hello,
I am trying to make a lister Item web app with HTML Sass and JavaScript, which let the user add items in a list and removing them at will. I have also provided a search feature so when the list goes long, User can find an Item easily to maybe remove them. ‘Now I wish to add a feature that prevents adding the same item more than once.’
I have tried to get the HTML Collection of the list items present in the list and making it an Array and looping through it to make sure if the list item to be added is already present.
I even tried to compare their textContent and after console logging them,they are same but for some reason when I compare them, they are not same.
I tried some other methods
Nothing worked…
Please help me!
You may visit this link to see the code right into your browser
https://github1s.com/RocTanweer/FrontEnd/tree/master/Projects/ItemLister
Just to to ./Projects/ItemLister
Thank You

versed python
#

@glacial orchid How exactly are you comparing the elements in the array? That sounds like the correct approach

glacial orchid
#

then getting all the 'li' as HTML Collection

#

converting them into array

#

looping

#

The fact is I am creating a list item same as an item already present
and them I am comparing if they are equal
But they are not
Even though they look exactly the same

#

If I cant compare them correctly, How am I suppose to prevent duplication?

#

I just need to know how to compare properly

#

Their tags are same
their class are same
Textcontent
button
everything

versed python
#

I can't find it

glacial orchid
#

If so

#

wait a bit

versed python
#

yeah please do

glacial orchid
#

comparing the first child of new list item and existing items

#

on console logging
they are same but on comparing it gives false

#

See there are two items in console

#

one is what I created
and other is first element of the already existing lists

#

they are same

#

but comparing does not work

#

Here this pic's code

#

Note: I am not appending the newItem here thats why its not added into the list here

versed python
#

Instead of comparing the elements themselves, try to compare the innerText attribute

#

The reason that comparison doesn't evaluate to true is because the Teo elements you are trying to compare are different nodes

mystic grove
#
def login():
    if current_user.is_authenticated:
        return redirect(url_for('home'))

    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and bcrypt.check_password_hash(user.password, form.password.data):
            login_user(user, remember=form.remember.data)
            return redirect(url_for('home'))
    else:
        flash(u'Login Unsuccessful. Please check username and password', 'danger')
        return render_template('login.html', title='Login', form=form)```
#

I am not able to login despite writing this peace of code

#

peice*

#

when i enter the id and password which I have registered into my database and hit login, the password field gets empty and nothing happens.

jagged matrix
#

Hi, I'm trying to use Jinja to pass values from an excel sheet to an automation script as the API has only custom data types, so I can't pass arrays to it. Someone recommended me to use jinja/mako as the values would be hard-coded. I believe I would have to extract the values from my excel sheet in a separate script and then use Jinja to pass them on to my main automation script. I do not have any experience with template libraries. Is there anyone who help me get a better idea about this whole process? I'm not able to find many examples where Jinja is used to pass values from one python file to the other. Thanks.

#

I basically want to define the datatypes in my main script and use them as placeholders to pass my values to iteratively.

native tide
#

Can I make a website without HTML/CSS/JS just python?

night patrol
#

nope

native tide
#

ah this bad news

night patrol
#

you need html

#

html and css are very easy

native tide
#

yeah but it is hard

night patrol
#

no

native tide
night patrol
#

these are not even considered programming languages

native tide
#

ah nice

tame vector
#

and dont use PHP, php is hard

verbal obsidian
#

Just because they are not considered programming languages doesn't mean it cannot be hard for someone

#

I'm terrible at photoshop for instance.

vestal hound
#

most people who say that HTML and CSS are easy have not fully apprehended their complexity

#

just my two cents

elfin ermine
#

hey

#

i know python and python and mysql and i want to make web with login system.
how i do it?

#

just learn to use flsak/django and add the sql database+ code to there

native tide
#

is that python web dev?

nimble epoch
#

php is a diff language

#

not related to python

verbal obsidian
#

@vestal hound Definitely, it might not be hard to make some basic static html pages with simple css but the real deal is when you start with more complex frameworks such as Vue.js, React and what not, Scss, perhaps bulma, boostrap, tailwind.. etc suddenly you don't make simple static pages but Full fledge web sites, SPA's with tons of api's and we are not even talking about making it all beautiful and sensible which is a whole new story.. hell there are a hundreds of things I'm missing in this comment, there is way much to it than 'css and html is ezz lmao'

native tide
night patrol
#

well, my opinion about django is that you don't really have freedom to add your own functionalities.Most things are built in adn it s hard to implement your unique ideas.

#

But i only know django and I can't compare it with node or orher backend frameworks

#

so

#

if anyone can?

elfin ermine
#

is it an option to make site without flask or django

nimble epoch
elfin ermine
#

html and css for front end then python and mysql for back end

vestal hound
#

CSS animations

#

flexbox

#

accessibility concerns

#

there's a lot of detail.

night patrol
#

STILL NOT A PROGRAMMING LANGUAGE

#

sorry for caps

vestal hound
#

of course, in a practical sense they're not really programming languages in the same way

#

that doesn't change the fact that it's not easy to do HTML/CSS well

wicked elbow
#

@vestal hound since you said it didnt look modern enough, what do you think about that? put a lot of work into it yesterday

vestal hound
#

not sure why your text looks a bit gritty? could be just compression

#

not really sure about the positioning of the icons though

#

also correct me if I'm wrong but

#

new comments will appear at the bottom, right

wicked elbow
#

image i think, the text username is 18px, text is 16.

vestal hound
#

so why is the comment input at the top

vestal hound
vestal hound
#

btw did you check your contrast ratios?

wicked elbow
#

so if theres an entire page of comments you dont have to scroll to the bottom to leave a comment

vestal hound
#

is a design choice though

#

up to you

#

that's how Spotify does it too

wicked elbow
#

and yea, eveything checks out in chrome

vestal hound
#

yeah my worry is just that

#

with the icons there

#

it'll get quite chonky

#

if there are many comments

#

wait sorry

#

what's the reply icon for?

dense niche
#

Guys, I'm losing will to live over my project. My Flask endpoints work nicely in dev but none work in production on PythonAnywhere:

Flask:

...
...
from flask_cors import CORS, cross_origin


blog_blueprint = Blueprint('blog', __name__, url_prefix='/blog', template_folder='../../templates')

CORS(blog_blueprint, resources={r'/*': {"origins": ["https://www.coinme.com"], "allow_headers": "Access-Control-Allow-Origin"}})


@blog_blueprint.route('/fetch_current_rates')
@cross_origin()
def fetch_rates():
    ...
    ...
    return jsonify({'status': 'success', 'usd': usd, 'gbr': gbr, 'eur': eur, 'czk': czk, 'ngn': ngn}), 200

React front-end:

useEffect(async () => {
        const config = {headers : {"Access-Control-Allow-Origin": "*" }};
        const resp = await axios.get("https://www.mydomain.com:5000/blog/fetch_current_rates", config);
        ...
        ...

  }, []);

this is what I'm getting in the console:

wicked elbow
#

its only loading to 20 comments, and no replies, the rest will be pulled in. i thought the same thing, goes back to screen sizing though. to big of a screen and buttons on say the left side look bad

vestal hound
#

like how it works

dense niche
#

it determines which domains will be allowed to consume resources or data from endpoints.

vestal hound
#

ye basically

#

okay I don't know how Flask handles CORS but

#

you should inspect your headers

wicked elbow
# vestal hound responsive deisgn?

the biggest thing is i want it to look the same everywhere you use it so i dont want to make it side buttons on some and under the comment on others

wicked elbow
#

ease of use. sites are one thing to impliment that in. say the difference between m and desktop versions, but comment sections, you dont want people to have to constantly shift what they know depending on their device. if i built an app though, they would be on the right side as butons

vestal hound
vestal hound
#

fair enough

wicked elbow
#

im getting there though work in progress. id have never guessed comment sections actually took so much to make them work, like 500 lines of code for just the react code to make it work like that

glacial orchid
wicked elbow
#

JSON.stringify what your comparing

#

@glacial orchid

formal gull
#

i have this html (using bootstrap. i dont fully understand html yet). how would i update this without a refresh from python using flask?html <textarea class="form-control" id="exampleFormControlTextarea1" text="test" rows="12">{{ result }}</textarea>

wicked elbow
nimble epoch
covert trench
formal gull
#

alright thanks. ill have to look into simple javascript then i guess. i dont need it for design or anything. thanks @wicked elbow @nimble epoch

nimble epoch
#

yvw

formal gull
nimble epoch
#

what would be a simple task?

formal gull
#

refreshing an element without a page refresh

nimble epoch
#

of course

formal gull
#

okay ill do my research. thanks

nimble epoch
#

yw but i suggest you to go for axios

wicked elbow
#

i mean i wouldnt call javascript a simple task. minor modifications are simple, but using a framework is complicated. React, Vue, Angular are sites completely built in javascript

nimble epoch
#

true

mystic grove
#
def login():
    if current_user.is_authenticated:
        return redirect(url_for('home'))

    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and bcrypt.check_password_hash(user.password, form.password.data):
            login_user(user, remember=form.remember.data)
            return redirect(url_for('home'))
    else:
        flash(u'Login Unsuccessful. Please check username and password', 'danger')
        return render_template('login.html', title='Login', form=form)```
#

I am not able to login despite writing this piece of code

when i enter the id and password which I have registered into my database and hit login, the password field gets empty and nothing happens.

native tide
#

How can I get the query params for a url like this:
http://127.0.0.1:8000/api/auth/#access_token=........&expires_in=315360000&token_type=bearer&refresh_token=......&account_username=....?

I tried request.GET and printing *args but it's empty.

wicked elbow
#

in django?

native tide
#

yep

wicked elbow
#

self.request.query_params.get('param_your_looking_for', default=None)

#

then you'll do an

if VAR is not None:
  do something here!
native tide
#

my query_params is empty, probably because the URL in question is in the following format:
<base_url>/#key=value
instead of the usual
<base_url>/?key=value
possibly?

vestal hound
native tide
#

I don't know anything about query params

wicked elbow
#

oh yea, without the ? you dont have query params

vestal hound
#

<base_url>/#key=value <- ill-formed URL

#

# is used to identify fragments

#

actually it might not be ill-formed I'm not sure if = is a valid identifier hm

wicked elbow
#

and you can use them to focus the screen

native tide
#

Oh I see:

    The fragment identifier introduced by a hash mark # is the optional last part of a URL for a document. It is typically used to identify a portion of that document.

The part after the # is info for the client. It is not sent to the server. Put everything only the browser needs here.
wicked elbow
#

so if your id="Footer" and you do #Footer itll focus your footer

verbal obsidian
#

#foo will focus in any of your id='foo' elements

native tide
#

oh damn, so there is no way for me to extract that info from the URL

verbal obsidian
#

why not

#

http://<base_url>/?test=1 should work just fine

native tide
#

http://<base_url>/#test=1 in my case it's like this, with the fragment

#

and that's not sent to the server

verbal obsidian
#

can you not change it

#

from # to ? ?

native tide
#

it's an external API, I can't

#

Oh...

 The access token is returned to your application in the fragment as part of the access_token parameter. Since a fragment (the part of the URL after the #) is not sent to the server, client side javascript must parse the fragment and extract the value of the access_token parameter.
#

A bit more reading on my part would've solved all my doubts

verbal obsidian
#

Makes sense haha

#

I was about to tell you that you could configure your webserver to add a cookie or header to the request with the full raw URI

native tide
#

I was going to start my own imgur API package for easy usage, so I wanted to automatically get those parameters, but I guess the user will just have to do that part themselves

sullen basalt
#

Hi Im using Django and was trying to do an order_by on a queryset after already having used distinct. I get the error that I cannot do that since they need to be on the same field. Is there any other way to do this since I want them to be on different fields?

native tide
#

hey, im using requests-html to do some webscraping. How would i find the meta information?

verbal obsidian
#

Hi Im using Django and was trying to do an order_by on a queryset after already having used distinct. I get the error that I cannot do that since they need to be on the same field. Is there any other way to do this since I want them to be on different fields?
@sullen basalt Do two queries using the value of one into the other one or just get the distinct query and then use sorted() on the object list

formal gull
# nimble epoch yw but i suggest you to go for axios

im trying to get my information through a python script running in the back ground. i am reading that i can use ajax to call python in javascript. am i on the right track you think to get a python script information through axios essentially?

nimble epoch
formal gull
#

ahh okay so that is built into axios then essentially? i dont necessarily need to make an api i dont think? what i am making is just needing user input to run through a python (selenium) script that is running and then print results into a text box

nimble epoch
#

oh ok

formal gull
#

would this need an api? nothing needs to be stored at all either

nimble epoch
#

so what is going to be requested?

formal gull
#

i believe what is being requested is the information from the python function that gets run?

nimble epoch
#

ok imagine you have something like localhost:8000/users/ that displays all users or a post request you want to send data from frontend so when you want to get or send data you add the location that you want to get or send data to. get it? like (localhost:8000/users/)

nimble epoch
#

if im right it was like @route('/path/') in flask

formal gull
#

yeah i do have the page routed like that

nimble epoch
#

so get that by that

formal gull
#

sorry i am extremely new to flask and web stuff so trying to break down things to understand 🙂

nimble epoch
#

but i forgot flask

formal gull
#

the python function?

#

or in axios?

nimble epoch
#

you want to get data from the function that you defined

formal gull
#

so axios.get('something.py')?

nimble epoch
#

like imagine a function that displays all users like return User.objects.all()

nimble epoch
#

the route

#

got it?

formal gull
#

partially i believe

nimble epoch
#

and i dont know something

#

i dont know what you gotta use in flask to intract with frontend

#

or maybe nothing while you are doing it in the same address

#

i dont know much about flask

formal gull
#

gotcha. i have an idea. ill keep reading google

#

thanks 🙂

nimble epoch
#

yw

formal gull
#

first real web project i am doing so a lot of terminology i am learning now lol

#

well more so what the terminology actually means and does lol

nimble epoch
#

wish you luck

stiff kite
#

i want to lear Django can i gets some tips for beginning

amber oxide
# stiff kite i want to lear Django can i gets some tips for beginning
nimble epoch
toxic flame
#

Yep, read the docs. Its very documented

stiff kite
#

thanks @toxic flame @nimble epoch @amber oxide for helping

elfin bluff
#

this my code for login:

when my login is successful it renders index.html

#

I can see index.html but url don't seem good as i need 127.0.0.1/ after login

haughty cape
#

can someone help me

polar nova
elfin bluff
#

i dont want to see doLogin, i need 127.0.0.1 after login

actually when i go to :
127.0.0.1/login i get login form
127.0.0.1/doLogin process my form and provide response
and for successful login it sends me to index.html
but url doesn't change

lean wolf
#

Hey people, anyone here familiar with pyppeteer?

glacial orchid
#

@wicked elbow it's night
Will try and let you know 🙏

glossy arrow
young hemlock
#

Hi everyone, I was wondering if anybody had advice how to display data from an api to a view through django

quiet ridge
#

hey can you please tell me how can I understand concept in flask
Bcoz the syntax are bit hard
and I m not getting any resource that can help me
please help

nimble epoch
glossy arrow
#

If I do it from the shell, it works fine

#

but when I import it, it doesnt work fine

nimble epoch
#

check you directories

#

what framework?

nimble epoch
quiet ridge
#

I have tried them but still can't get the concept

nimble epoch
#

what you mean concepts?

glossy arrow
nimble epoch
glossy arrow
#

My framework

#

I made one

quiet ridge
glossy arrow
#

I've deployed it to pypi

quiet ridge
#

and it is the most important part I think

nimble epoch
quiet ridge
nimble epoch
#

ok wait

quiet ridge
#

but for beginners

nimble epoch
quiet ridge
#

okay then

nimble epoch
#

forget about the book let me send you a link

nimble epoch
#

if you are using

glossy arrow
#

Its a WSGI framework

#

So I can use anything to run it

nimble epoch
#

oh so this is your own framework?

glossy arrow
#

Yeah

nimble epoch
#

so you gotta tell us whats the solution lol

glossy arrow
#

Lmao

#

Im trying to figure that out

compact mason
# elfin bluff this my code for login: when my login is successful it renders index.html

I'm assuming you are using django. The problem here I believe is that you are just rendering index.html. This is basically saying that when you go to doLogin and the login details are correct, render the index.html file. You never tell the url to move to the index page. What you could do instead is make a redirect to the link of the index page (see https://docs.djangoproject.com/en/3.1/topics/http/shortcuts/#redirect)

#

Tho you don't really need a new view to act as the middle man between login and index. You could just add that logic to the original login page itself

austere acorn
compact mason
#

Yeah I said that in the message above that one

violet vector
#

what's the right way to set per-request timeouts in a flask app served by gunicorn with gevent workers?

EDIT: answering my own question, use gevent.Timeout like so:

with gevent.Timeout(time_in_seconds, exception_type_to_raise_on_timeout):
    do_some_work()
supple vault
#

hey

#

After a request I get back stuff that is encased in {}, that is JSON correct?

quiet hornet
#

Yeh sounds like it

supple vault
#

calm

silver pollen
#

Not sure which channel is the right one for this, but anyway I have a flask API where I POST commands and the command can take up to 30 minutes to run on the server. Is there a standard way to somehow get the progress of this task to my client?

#

maybe if i post a generated hash with the command and the server stores the progress in the database with this hash, then i can poll it..?

cerulean vapor
#

@silver pollen the way I'd handle something like this is, I'd create a db table that functions as a work queue. When someone submits a task, it gets put into that queue, and they can then visit a page that looks up the job ID for it to see if it's finished.

#

and you can also have it so that any new submissions to the queue purge anything older than X days or what have you, so it doesn't get too unwieldy.

silver pollen
#

@cerulean vapor yes something like that is what i thought about, but my problem is i can't return the job id because that would close the request and the job is not run. that's why i thought maybe the client can generate the job id and send it. if it already exists (which is extremely unlikely) the server can return an error.

cerulean vapor
#

@silver pollen You don't want to have the client generate a job ID, because the universal rule of client-server anything is you cannot trust client input

#

If the job in question takes that long to run, then you need to find a way to set up a job ID for it before it's triggered

silver pollen
#

yes i guess so, but this is for an internal app at work so i kind of trust all users. but maybe it would be nice to have an endpoint where i can request a job id and then send that in the post request.

cerulean vapor
#

I think that makes sense

#

the job ID can be logged in the backend, and then can be used later

silver pollen
#

i'll try something like that, should work.. thanks.

dawn heath
dawn heath
wicked elbow
#

well as long as you json always looks the same you can destruct to

data.map(({title, items, subobj:{subtitle, querries}) => {
  <h1>{title}</h1>
  <p>{items}</p>
  <h3>{subtitle}</h3>
  <p>{querries}</p>
})

im not sure what your asking. if items is also an array, you just map inside the map

stable root
#

Hey there, I want to host a site that will showcase a random portfolio website. Is <iframe> the way to go?

timid forum
#

Hi, I am looking for someone to help create a website that utilizes some music machine learning algorithms I created. Anybody who knows Django and/or JavaScript please DM me if you are interested! Also would like someone who is actively working, because I need to finish this project fairly soon 😬 . A developer who can do frontend and backend would be a godsend....

wicked elbow
stable root
#

@wicked elbow With permission of course, and that's my concern with the iframe, but I can't think of a better way.

wicked elbow
#

iframes have major security issues. better just to link to them then do display them

stable root
#

I guess I can just host some JS to do a redirect to a random site too. Then there's no issue.

#

With permission. 😉

wicked elbow
#

take a screenshot of them and display that, with a link to the site or something

toxic flame
#

You can also save their public html into a folder and display it inside a div

wicked elbow
#

you could, but thats getting to the point of unethical coding. the whole idea seems sketchy honestly. thats like scraping reddit and redisplaying on your site.

toxic flame
#

true

#

Also

#

Why is iframe insecure?

wicked elbow
#

iframes can link jack. basically gives the site with the iframe the same control the browser has

toxic flame
#

um

#

What's wrong with that

#

Isn't that the point of iframe

wicked elbow
#

thats how you get your username and password stolen... lmao

toxic flame
#

?

#

Iframe just displays another site inside a box

#

Not sure how will someone steal your crede

#

maybe explain a little bit with more context

#

if you're free

wicked elbow
#

correct, you cant see the address. you also cant see what the iframe is doing. iframes can be controlled completely in javascript. lol just google why iframes are bad

toxic flame
#

ok

wicked elbow
#

no one uses iframes for anything good and everyone should have scripts in their code breaking iframes. very very few actual uses of iframes

toxic flame
#

I see i see

#

YouTube embedded uses iframe ;-;

wicked elbow
#

videos are one of those specific use cases.... how else do you plan on transferring video data?

toxic flame
#

U still can change iframe link reeee

wicked elbow
# toxic flame U still can change iframe link reeee

https://stackoverflow.com/questions/7289139/why-are-iframes-considered-dangerous-and-a-security-risk read that. think about it this way. for instance, if you loaded a malicious page that looks identical to say facebooks login page, you wouldnt know if it was a malicious link or the real link because you cant see the address

toxic flame
#

Oh wouldn't that be the guy who made the site's fault!

#

?

wicked elbow
#

yes, and users shouldnt trust iframes. if your loading another site into your site, chances are your doing something malicious. like i said very few legitimate uses

toxic flame
#

Ah I see. So if someone puts your site into an iframe as well. It can execute js as if it was from that domain.

wicked elbow
#

besides if i was paying a developer team 1 million a year to keep a site up the last thing id want is someone to iframe to my page and steal the credit of my site and display ads and make money from not doing anything but stealing my work

toxic flame
#

Hahahaha damn.

wicked elbow
#

i mean im just saying 1 million isnt that much. thats 10 programmers making 100k a year.

toxic flame
#

Well

1 tech lead
3 full stack

Is probably all you need

wicked elbow
#

technically speaking, iframes arent bad, but they can be

#

haha, look at facebook for instance or youtube or google. they all have way more then 4 developers. and no one hires full stack unless your a small company

toxic flame
#

4 full stack developer

#

Unless they hire by parts too ( fronted, backend )

#

Well I'll have to be applying for startups... I won't have a degree any time soon.

#

By the time i will be getting a degree. I'll be starved to death lol. ( If i dont have a job )

wicked elbow
#

front end, backend, UI/UX and networking plus a programming lead and a project manager. is pretty standard. JS is a huge job for big projects

toxic flame
#

I assume full stack only contains fronted + backend?

#

Ui/UX & networking is included too!

#

?

#

Damn.

wicked elbow
#

thats the full team for web yes

toxic flame
#

Oml

#

Kendal, are you like a business owner or something?

wicked elbow
#

full stack doesnt do networking normally, but depends how small the company is

toxic flame
#

You seem to know kinda alot about this

wicked elbow
#

ive done my research, in the next month im opening a beta to a new social media site