#web-development

2 messages Β· Page 218 of 1

frank shoal
#

do it

warm aurora
#

Just refresh the page normally?

frank shoal
#

yes

warm aurora
#

Oh damn

frank shoal
#

click on one of the not found links.

warm aurora
#

The images r whats not found

frank shoal
#

Yes, click on one. It should show a pane containing the full url

warm aurora
#

When i click it it just highhlights the red part above

frank shoal
#

example:

warm aurora
#

Is it possible to get into a voice channel??

#

I can share screen

frank shoal
#

I'm technically at work.

#

Screenshots work fine

warm aurora
#

Inothing is happening when i click

#

Should i send a video of what it does?

frank shoal
#

In my screenshot, I clicked DASH_480.mp4, which brought up the pane to the right.

#

Preview was selected by default, but I clicked over to Headers

warm aurora
frank shoal
#

Now click headers.

warm aurora
#

O

#

Ok

frank shoal
#

What's the request url?

warm aurora
frank shoal
#

And please take screenshots. Stop using your phone.

warm aurora
#

Ok

#

So what do i do

frank shoal
#

Win+Shift+S

#

then drag a square around the part of the screen you want to capture.

warm aurora
#

Oh i know how to screenshot

#

Im saying what should i do next

#

Or u want a better screenshot forst

frank shoal
#

post your last image as a screenshot, because I can't read it.

tight pasture
frank shoal
#

And what's your directory structure?

warm aurora
#

U want the code?

frank shoal
#

no.

tight pasture
#

??

frank shoal
#

Folder structure.

warm aurora
frank shoal
#

idk.

#

Do you control the server or is it a school managed thing?

warm aurora
#

I control it

frank shoal
#

restart it?

warm aurora
#

I didnt link anything tho

#

Like im sure its just a path thing

frank shoal
#

I got the url from your screenshot

warm aurora
#

Ya ik

#

Im saying link as in in the code

frank shoal
#

no css?

#

<link href="pacific.css" rel="stylesheet">

warm aurora
#

Like that code was from google

frank shoal
#

you've got that.

#

What's in your images folder?

tight pasture
frank shoal
#

can you turn on file extensions? Should be in the view tab

tight pasture
frank shoal
#

Maybe upload to the server and restart it?

#

the issue isn't in your project.

#

probably

tight pasture
#

did u see my code?

frank shoal
#

Yes.

#

The images just aren't there.

warm aurora
#

Can i send u the zipped file??

lavish prismBOT
#

Hey @tight pasture!

It looks like you tried to attach file type(s) that we do not allow (.zip). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.

Feel free to ask in #community-meta if you think this is a mistake.

frank shoal
#

upload the zip somewhere

#

not here

tight pasture
#

where can isend it?

frank shoal
#

google drive?

tight pasture
#

can i email it to u

warm aurora
#

???

tight pasture
#

did this work?

warm aurora
#

@frank shoal

frank shoal
#

Works when I open it as a file://

tight pasture
#

ya but thats not my file

#

i have to download them and upload to cpanel

frank shoal
#

So you need to upload your images.

tight pasture
#

so when i download and unzip them do you thing the path changes

frank shoal
#

it's not in the images folder

tight pasture
#

so how do i add them

frank shoal
#

I've never used cpanel.

tight pasture
frank shoal
#

Looks like you should upload your zip, then extract it using cpanel

tight pasture
#

extract it in cpanel?

frank shoal
#

yes

warm aurora
#

WTFFFFFFFFFFFF

#

That workeddddd

lavish prismBOT
#

:incoming_envelope: :ok_hand: applied mute to @warm aurora until <t:1645740741:f> (9 minutes and 59 seconds) (reason: discord_emojis rule: sent 51 emojis in 10s).

normal pebble
#

!unmute 407310346257170433

lavish prismBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @warm aurora.

normal pebble
#

lol, careful

frank shoal
#

did he start spamming a bunch of emojis?

normal pebble
frank shoal
#

ah. that'll do it.

warm aurora
#

Hahahaaha

#

πŸ˜‚

#

I was just so happy

#

No one would helpp mee or figure out the problemm

outer fractal
native tide
#

i just learned flask today after someone recommended it here

#

now i consider myself pretty good at flask

#

i built a full api with it so

#

what i would do is check the request

#

get request i think

#

then log it to a text file or webhook

#

or smt

native tide
atomic horizon
#

Question:

Looking to build a website that has a login/registration that brings the user to a dashboard.
The back-end is built with Django and Django Rest API

I know that Django already has awesome built-in admin, user and registration -- but I know that I could also built it with React.

Could someone help me decide what the best route would be for me?

Is another option to built it out in the back-end with Django, and then use React to improve the UI across the dashboard + company website template?

UI will be very important to the overall main website and dashboard.

golden bone
native tide
golden bone
native tide
#

sorry, no. you say django for backend and react for frontend is a natural choice. but next, you propose they don't need react for something nicer. how come?

#

and if not react, what would you propose instead?

native tide
golden bone
native tide
#

yeah, I agree

fresh cape
#

Perl for life

native tide
#

i dont remember talking to you 🀣

bold lichen
#

Has anybody here used github codespaces for web development?

mint spear
#

Hi everyone. I have a general question of python.
just like we import specific module/package of a package/lib (sorry differences are not that clear, anyways) because if we import whole lib and only be using a specific module, it's not worth it, it will only take memory space and increase execution time. Similarly, in exception handling, let's say I corrupted my try block with intentional NameError but I except error-exceptional handling from Exception class on a whole and not just simply NameError, is the former one slower than later or there is no observable execution time delay?
I want to learn how things work internally, as most tutorials just tell us what python has to offer (abstracted high level syntax and it's working). I have learnt C and I still practice some C small C programs, I'm just a student never don't any real world project but I try my best will cooperate if you tell something complex.

wraith osprey
#

hey guys

#

I want to be able to use extensions from the google console

#

how can I manipulate such extensions ?

manic crane
#

im trying to remove a field from my models and i keep getting ValueError: Field 'occupiers' expected a number but got ''. even tho im trying to remove the field

sweet delta
#
from .forms import InputForm


def home_view(request):
    context = {}
    context['form'] = InputForm()
    return render(request, "site/index.html", context)



from django import forms


class InputForm(forms.Form):

    first_name = forms.CharField(max_length=200)
    last_name = forms.CharField(max_length=200)
    roll_number = forms.IntegerField(
        help_text="Enter 6 digit roll number"
    )
    password = forms.CharField(widget=forms.PasswordInput())



<form action = "" method = "post">
    {% csrf_token %}
    {{form.as_p }}
    <input type="submit" value=Submit>
</form>

could someone tell me why this isnt loading the forms, all i have is the button

native tide
#

hey im using github pages and it's only showing the readme file when i deploy

#

can someone help

#

this is html

native tide
#

😦

golden bone
native tide
#

Any cPanel geeks here.

#

Need a bit of help.

#

I'm hosting with namecheap and they have an exclusive hosting service for for Python Apps, can I start/stop my application remotely as a pose to going to my actual dashboard.

#

My idea is that if my local server stops responding or is turned to maintenance mode, my server running cPanel will kick in.

unborn cape
#

i created an animation which rotates in "inline-block" but doesn't when i use inline can anyone explain

#
body{
    font-family: Arial, Helvetica, sans-serif;
    background-color: black;
}

section{
    height: 10px;
}

h1{
    font-size: 100px;
    color: whitesmoke;
    position: absolute;
    text-align: center;
    top: 50%;
    width: 100%;     
    transform: translateY(-100%);
    letter-spacing: 2px;
}

h1 span{
    animation: anim 1s linear forwards;
    opacity: 0;
    display: inline-block;
}

@keyframes anim {
    
    0%{
        opacity: 0;
        transform: rotateY(-90deg);
    }

    100%{
        opacity: 1;
        transform: rotate(0deg);
    }
     
}```
#

can anyone tell

#

????

amber patio
#

best sites to deploy flask app except heroku?

inland oak
golden bone
#

Or free tier on any of the big three cloud providers might work

native tide
#

Hii

#

how to change discord username use request

#

i try find this info 1day in google

#

but nothing

#

i trying

import requests

payload = {
    'username:' "UserSwithed"
}

header = {
    'authorization': 'Token'
}
r = requests.post(f"https://discord.com/api/v9/users/@me", # cntrl, shift, i 
                data=payload, headers=header)

austere acorn
#
headers = {
  'Authorization': f'Token {token}'
}
native tide
#

'authorization': 'Token' Token is token xD

#

Token = token

trim spire
#

Using sockets, how can I get the position to a users cursor?

atomic horizon
golden bone
native tide
buoyant shuttle
#

how would i resolve this

WARNINGS:
reddit.RedditWallStreetBetsHotDB: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
    HINT: Configure the DEFAULT_AUTO_FIELD setting or the RedditConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
reddit.RedditWallStreetBetsNewDB: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
    HINT: Configure the DEFAULT_AUTO_FIELD setting or the RedditConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
reddit.RedditWallStreetBetsStocksDB: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
    HINT: Configure the DEFAULT_AUTO_FIELD setting or the RedditConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.
reddit.RedditWallStreetBetsTopDB: (models.W042) Auto-created primary key used when not defining a primary key type, by default 'django.db.models.AutoField'.
    HINT: Configure the DEFAULT_AUTO_FIELD setting or the RedditConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. 'django.db.models.BigAutoField'.

its just a warning

#

this is django

native tide
#

what are your models

quasi field
#

I have a quick (hopefully) question. I own a a domain ending in .dev I know there are requirements that I was must have a valid certificate to use this address for a website, but would I be able to create an API using this address and Heroku without a cert?

native tide
#

of course

#

you only need cert for https

#

meaning if you want your data you send to be encrypted then you will need to quickly install a cert on the heroku server

#

and then send calls to your API via https

#

but http will work without any certificates, but the traffic will not be encrypted so anyone on the wire can technically see what kind of requests you are sending

golden bone
quasi field
#

Thanks @native tide and @golden bone I have a starting point now

tall pike
#

web

#

πŸ•ΈοΈ

sleek phoenix
#

Questions for future reference: can I code a websites front end with HTML or CSS and code the back end with python? Is a backend really necessary for some sites?

inland solar
delicate frigate
#

Howdy! Looking for a library or any advice on Flask maintaining (refreshing when expired) a token to another app. This is not a user facing login but Im not sure if there's something built into Flask or another library already. Any ideas?

inland solar
#

can someone help me with my error

buoyant shuttle
#

I need help

#

Each time i make changes to my Css file

#

For some reason it doesn't show

buoyant shuttle
forest sonnet
#

if your website is static you dont need a backend

slender coyote
#

Hi

#

I am new to python

native tide
#

How to amke beautiful tables like in aave? https://app.aave.com/#/markets
if you want to help, ping me

autumn vector
#

hey django users, is it possible to insert stackoverflow style code indentation to django posts?

inland oak
#

your provided table was made with React

#

Basically it is just a combination of HTML/CSS/SCSS syntax with a bunch of Frontend Framework Javascript in order to hook drag/drop events with rerender of the DOM

native tide
#

Am using react currently

#

So you mean that i only need hook drag/ drop events?

inland oak
#

and model variables that are rerendered when their values are changed

native tide
#

Okay thanks!

inland oak
# native tide Okay thanks!

everything else looks to me implemented at html/css level.
the autohiding of top and bottom? Html/CSS, a bit unsure how to write it though, making strict size of DIV object, and moving children objects inside of it with forbidding overflow? πŸ€”
visual effect on hover? CSS
movements of objects? They used CSS transition thing
the rest is obviously just CSS formating too

native tide
#

Alright

inland oak
native tide
inland oak
# native tide Alright

Technically sorting feature can be implemented on the level of just resorting javascript array data without any other complications, just sorting based on different key

#

but they could have used Client Side SQL libraries to make it in a more advanced way

#

obviously they did not make requests to server side for resorted data, or they could pithink

#

probably the first option was used

#

it looks simplest solution

native tide
#

in their docs

inland oak
#

Simplicity for the win

native tide
#

Definitely

whole drift
#

hello

#

what are the topics I need to know for making a chat app using django?

native tide
whole drift
sleek phoenix
#

Mm, it’s complicated to put into words, but for lack of a better term I’ll say a art site but for me and my friends

#

So, kinda like Newgrounds but for me and my friends only (I guess, not super sure yet)

inland oak
slim maple
#

can anybody pls help me with something pls dm

stark tartan
#
class Item(models.Model):
    fileds

    @property
    def get_average_rating(self):    
        #get ratong from comments    
        return int(round(sum(rate_list) / (len(rate_list) or 1), 1))

how to order by get_average_rating method in my Item Model it also decimal flied in type (Queryset not list )

lament copper
#

Not sure if it works with queryset, but it’s worth a shot

wary flint
#

hi, some quick help here: I have a django app where users need to connect to an external api. What's the best way to store their api key securely?

indigo kettle
#

@stark tartan

raw field
#

Do Python Django "channels" (websockets), scale?

#

When I say scale, I mean at minimum 3 million concurrent connections.

#

Goroutines can have 10 million connections

#

It would be nice to know

#

No useful info on google

#

Just conjecture, and opinions, but no real solid info

#

the best ive found was this

#

Daphne is not as efficient as its WSGI counterpart. When considering only latency, Daphne can have 10 times the latency when under the same traffic load as gunincorn.

spark parcel
#

@raw field nothing can honestly scale to 3M connections..

spark parcel
#

It is.

raw field
#

pheonix did 2 million

#

in 2015

#

its even much mroe now

spark parcel
#

I think were talking past eachother .. if your JUST going for benchmark porn, sure.

#

But what I meant by really is more, you cant do anything useful with those connections..

#

Sending a ping every 5 minutes at 10M connections was roughly the limit of what the server could handle

#

No one is running 2 million connections on a single server for any non-benchmark workload.

raw field
#

my point tho is

#

how do you scale django channels

#

i cant find anything about it

#

lol

spark parcel
#

Thats likely because no one, for real world use cases, has that many clients connected, its a tweetworthy metric. You scale out servers in all production cases that are that loaded.

#

or just load test it πŸ˜„

raw field
#

My design concept is essentially that players will connect to the websocket and request a match, it will look for a free match that is available and then if there are enough players in the lobby to start the match it will then trigger an event (through the socket) to tell all of the users in the lobby what ip and port to use to connect

stoic marsh
#

What is the correct path way to follow to become a good web developer ?
Like first HTML & CSS then JavaScript then what?

inland oak
opal verge
#

Those 'steps' has more steps. For example, learn JS is learn EMACS, too

willow heron
modest hazel
#

Hey fellas, wondering how to make a query selector with multiple values, like document.querySelector(input[aria-label="Search"|aria-label="SearchBox"])

#

and so on and so forth

inland oak
#

then it will define your next things to learn πŸ€·β€β™‚οΈ

sleek copper
#

hey yall, I need some demo testers for a big project I'm working on! Involves cloud torrenting, let me know if you're up to it, nothing illegal lol :P, just testing out my flask skills

willow heron
#

but the back end map itself confuses me

inland oak
#

It should be pretty beginning stuff to begin pithink

willow heron
#

the content isn't intimidating me just what to learn and what not to learn πŸ˜…

inland oak
#

i mean, if you want to do in python as backend language (answered like that because you are in python server)

#

if you wish to use another one... like javascript, replace flask with express or whateve ris their framework

willow heron
#

it uses mongodb and express i guess

#

but my question is that once i get a hang of basic js where do i go from there?

reef spruce
#

do someone knows how to use multiple functions in a flask route? for example, i have a route called /dashboard/ and I have one function in there already but i want to add another function, but i dont have any idea how will i do it.

inland oak
#

Code without testing is garbage waiting to be collected πŸ˜‰

#

get used to Jest as example

inland oak
#

so it would be self documented and readable

willow heron
#

honestly i just want to get a job right now and no offence these would only help once i get a job and want to get good from there

inland oak
#

learn about OOP, how to have inheritance and etc
And just learn the basics about your chosen language as main one fully

inland oak
#

The rabbit hole is deep one, it continues further without any stop

willow heron
#

πŸ’”

inland oak
#

at least basics of raw SQL and able to use ORMs

#

Raw SQL needs to be learned to understand what you are doing in ORM

#

PostgreSQL is a good database to work with

#

Get yourself familiar with Linux systems and Docker
Learn how to deploy your application with Docker at Linux server
it should be minimum any backend dev should know

willow heron
#

guess ill kill myself because i would never be able to pay my student loan this way

inland oak
#

We are finishing it only as a... template ready to be filled with real knowledge and skills to use

inland oak
#

a combination of a lot of self studies and a real commercial programming experience is the key to be ready

inland oak
#

plus they help to get hired more easily

willow heron
#

but i dont have a year

#

3 months and ill be on the street

inland oak
#

in theory you can learn and make enough of pet projects practice to impress people for Junior positions

inland oak
#

what's your background

native tide
wheat verge
#

its an unusual question but how do i learn git... I mean i have seen few vids on youtube but how to practice it?

native tide
#

its easier than you think

#

like 5 commands will see you good. paste them in a notepad

#

git init

#

makes the folder a .git project

#

git add . --all

#

takes all the new stuff you changed or added and gets it ready to save

#

git commit -am "Changed stuff"

#

saves it.

#

now. to sync that with everyone elses code. first you pull

#

git pull origin master

#

then push back

#

git push origin master

#

that's about all you need to know if you work on your own. after that you can learn branching. but get comfy with that first.

wheat verge
#

ok thanks

native tide
#

i'd avoid using a GUI like vscode plugin until ur familiar with the commands

wheat verge
native tide
#

well. maybe ignore me on that. it is kinda useful. i just think it also useful to know what your actually doing first.

#

also use git status and git log frequently.

#

like between every other command. just to make sure it's as you expect

native tide
#

if it ever goes wrong

#

delete the folder and reclone it

#

git clone https;//path to folder

wheat verge
#

is there any website where i can refer whats actually happening behind the scene

native tide
#

lots. also the .git folder itself has all the blobs in and configs etc

#

i.e. when you do git init it makes an invisible .git folder take a look in there

#

due to all the changes on github and not being able to use a password unless you gen a ssh key etc. it might be easier also if you just install git desktop... https://desktop.github.com/

#

and clone with that

agile pier
#

hii, I want to display only the first few characters of the URL

#

But the answers given there is not working, pls tell how to do?

brazen laurel
#

I’m trying to build an api with flask and was trying to use marshmallow, marshmallow-dataclass, and marshmallow-dataclass[enum] to do serialization before returning objects from the api. I can’t seem to get any EnumFields to have by_value set to true on them

#

Has anyone done something like that before?

ocean slate
#

hello hello

#

I deployed my web app on Heroku and now I want to see database file, how can I see that ?

clear anchor
#

try unplugging it and plugging it back in

lethal jacinth
#

Hi guys, new to web dev

#

how should I start

ocean slate
#

or*

wraith osprey
#

any one knows about message passing in chrome extensions?

#

how can I pass the content_script document to the background

lethal jacinth
#

like I want to develop a skill

#

already learning ML so thought web dev being the hype felt a good field

ocean slate
#

I mean expert in Python

raw field
#

in larger organizations writing clean code is important

odd junco
inland oak
#

Clean code matters how long they will be trying to read your code
Hell, it matters how long you will be reading your own code you forgot after few months

raw field
#

yeah

golden bone
raw field
#

@golden bone do you know anything about Django Channels

#
socket.send()socket.on("message", data => {  console.log(data);});
socket.emit()socket.on("greetings", (elem1, elem2, elem3) => {  console.log(elem1, elem2, elem3);});
golden bone
raw field
#

Dang

#

My main experience with websockets is ith socket.io

#

And I love the syntax because you can do stuff like i just pasted above

#

custom 'event' based work

#

so like you can send a signal to the websocket on "message" or whatever

#

and the websocket will send a response lol

#

but django channels doesnt seem to have this built in functionality

#

you have to do it yourself

#

it makes the development really beautiful and easy to work with

digital bone
#

Just, to give an overview, I am trying to build a number based chatbot(like predefined one) where you get a list of options and like it will ask how may I help you and give a list of options :

  1. Seeking for career advice
  2. Seeking jobs etc
    and the user will enter a number according to what they are looking for.
    So what I did is created a form and tried to route it with the python file.

Now the thing is I'm not able to route the logic and send it back to display it.

Trying it in django

lethal jacinth
lethal jacinth
native tide
#

would anyone know if its possible to force load all the elements in a page (or specific elements) using selenium? Because on a website I'm trying to scrape some elements only load when you scroll over them and considering the size of the website, it would take far too long for selenium to scroll through the entire site and make sure the elements properly load. Thanks

raw field
#

i refuse to believe this

#

ruby on rails has a setup command to create the database

#

rails db:create and rails db:setup

#

create creates the db and stops, setup creates the db, runs migrations and adds any seed data

#

does django really n ot have the capability of creating an initial database?!

steel night
#

I don’t think so.

golden bone
#

I have used a while loop to scroll until multiple attempts do not increase the length of the document, that's probably about as good as you can do I guess

native tide
#

let response = await fetch(url);

let commits = await response.text(); // read response body and parse as JSON

alert(commits);```

Keep getting error "SyntaxError: await is only valid in async functions and the top level bodies of modules
    at /script.js:3:16"
#

Anyone know why this is?

manic frost
#

well, await is only allowed in async functions

native tide
#

how do i call an api and set a variable to the value i receive?

manic frost
#

Where is this code from?

native tide
#

stackoverflow lmao

#

im trying to call my flask api

manic frost
#

You can only use await in an async function

native tide
#

okay

#

how would I call an api and save the response in a variable

#

because i dont want it to be Promise {}

manic frost
#

when do you want the request to happen?

native tide
#

or undefined

native tide
#

i want the api call to finish

#

and then set the variable to the response

manic frost
#

when do you want to make that call? when the page loads? when you click some button?

native tide
#

when the page loads

#

sorry i misunderstood

#

yes when the page loads

#

first line

manic frost
#
async function doSomething() {
  const response = await fetch(url)
  const commits = await response.text()
  alret(commits)
}

doSomething()
native tide
#

okay

#

wheres the variable tho

#

would like to assign the value of response.text() to a variable

manic frost
#

You can work with the variable in the doSomething function

#

Do you know how promises and async/await works in javascript?

native tide
#

no i dont

#

so i can only use the response.text inside the async function?

#

is that correct

manic frost
#

You can set a global variable:

let commits = null

async function doSomething() {
  const response = await fetch(url)
  commits = await response.text()
}

doSomething()

but then you'll need to wait until the variable is set before you can use it

native tide
#

is there a way I can stop loading the page until the request goes through?

manic frost
#

why?

#

what do you want to do, in general?

native tide
#

the website contains a table, all the values are from the api call, I create the table in js and use all the values from the api call to fill it in with data

manic frost
#
async function main() {
  const response = await fetch(url)
  const commits = await response.text()

  // create the table here
  // for example:
  createTable(commits)
}

window.addEventListener('load', main)
native tide
#

thank you man i appreciate it

#

ill research promises await and async now i think

manic frost
broken mulch
#

I have 2 servers, one for API one for WS and I cannot combine them into one ( financial issues ) how would I communicate between these 2 servers at lowest cost possible?

#

People said just build another API on the WS and request it, and some people said using Redis pubsub which I also have to host on the cloud

#

I think one single pubsub channel might be better than API calls in long term?

steel night
#

If your cloud provider has a message queue that would probably be the easiest solution that does the job well

broken mulch
#

Client -> POST -> api/channels/channel_id/messages

api -> db -> Success? -> POST -> WS server’s API

WS server -> dispatch MESSAGE_CREATE event to client

#

This is my current flow chart

scarlet kiln
#

I want to individually animate strokes in an svg, someone have suggestions as to what I am doing wrong ```js
let svg = document.getElementsByClassName(".draw")[0];

interStrokeDelay = 0.1;
strokeSpeed = 0.05;
timePassed = 0;
for (let stroke of svg.children[1].children){
if (stroke.nodeName == "path"){
console.log(stroke);
let strokeLength = stroke.getTotalLength();
let strokeDuration = strokeLength * strokeSpeed;
stroke.style.strokeLength = strokeLength;
stroke.style.strokeDuration = strokeDuration;
stroke.style.strokeDelay = timePassed;
stroke.style.strokeDashArray = String(strokeLength) + "px";
stroke.style.strokeDashoffset = String(strokeLength) + "px";
stroke.style.animation = "stroke" + String(strokeLength * (0.1 / strokeSpeed)) + "sz` linear" + timePassed+ "s forwards";
timePassed += strokeDuration + interStrokeDelay;
}
}```

#

I realized I was missing a space in the text for animation

#

serves me right for writing it like that ^^

snow ravine
#

I'm interested in learning about web development in Python, but 90% of the job/internship postings related to Python in my city seem to be about data science, and rarely anything about web development. Should I learn Javascript instead even if I do like Python?

scarlet kiln
#

if you want to do web dev some amount of javascript is basically a must

#

since the frontend will inevitably use js

#

but for the backend python exists

#

most jobs in my area are java spring or nodejs though

#

ymmv

ocean slate
#

Hello I am using Flask for a project

#

I need help plz

#

there are two user roles

#

admin and normal user, normal user can post their complaint and admin can see them all and can also give feedback( or respond) to those posts

#

here posts are some type of complaints which user have on a specific topic

#

MY PROBLEM is that when admin gives respond to the complaint then that complaint should not be visible on the admin dashboard in future( means just after giving response)

#

How to do this

#

I hope i am able to justify my problem clearly

prisma ravine
#

hey guys [[1,2]] how can i get the acces of the element 2 in this list?

acoustic harness
#

Hey i need to know how to use stegnatography to hide a code inside an image and when omage opened by someone it pastes a code inside the browser console , pls this is the imformation i required for my project if u know pls help

rustic sky
#

django help...
storage setting ManifestStaticFilesStorage breaks my admin panel and causes ValueError exceptions related to the static files for the panel... why?

hidden kettle
#

hello

#

django developers

native tide
#

what's difference beetwen let and var?

golden bone
wheat verge
unique shore
#

but legacy browsers don’t support let so you might still use var if you are making websites to support legacy browsers

unique shore
nimble python
inland oak
#

it would be easier to delete it

#

you used float: left and display: flex

#

without knowing what is it, just in every element

#

I bet all other things you used in the same style

#

you should read this book in order to gain basic understanding what you are doing

#

and building stuff bit by bit with elements you know how to use

#

and not just copy pasting from some random place

wet hinge
#

hiho, I am building a django + react project. I want to do the following:

  1. User goes to 127.0.0.1:8000/book/<TITLE HERE>
  2. Django gets info about this book from some other API
  3. User sees info about the book in react frontend

I heard I should use django rest framework to communicate django with react. Though, I don't know how to do that, since I won't be storing any data in my DB. How to pass info fetched from some other API to react frontend?

steel night
#

If you're not storing any data in a DB, why does the data need to pass through Django at all? But the easy answer is write a REST API endpoint in your django server, where all it does is run the request to the other API then return the same data the other API gave it

wet hinge
ocean slate
#

Hello, how can I see my database file after deployment?

#

I deployed my web app on Heroku and now I want to see data and tables and the records inside table, how can I see that

ivory lotus
#
def error_404_view(request, exception):
    return render(request, 'pagenotfound.html')

this is my view for a 404 page handler
handler404 = 'thedogenet.views.error_404_view' added this to urls.py, and also DEBUG is false. this was working until idk what shit I did and then it now shows a Server Error(500). I don't know why this is happening

#

A server error occurred. Please contact the administrator. okay

native tide
#

we will need to see the full

#

error message on the server's side

ivory lotus
#

ok

steel night
# wet hinge lets say I want to enable user to add the book to database using a button could...

I don't know your codebase, so I don't exactly what you'd want in the return from the REST API POST call initiated by the button press. But standard behavior would be to return HTTP 200 on success. If no other info is required by the frontend (or other API users), that's all. A typical pattern in API design is to return the serialized database object that was created by your POST call tho. Ideally, the API implementation should be totally independent of how it is being called on the client side - by frontend, other server, or curl calls. All http hits to POST myserver/book/title are treated the same

wet hinge
ivory lotus
#

do you want the error raised when using the inspect element?

#

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

#

didn't see anything in the console particularly concerning

#

only the Server Error

steel night
#

no need to tag me or anyone else individually

wet hinge
ivory lotus
#

oh nevermind

#

I fixed it

#

the <img> tag was screwing the whole thing up

native tide
#

there should be a full error message

#

oh nvm then

ivory lotus
#

thanks for trying to help πŸ˜„

grizzled estuary
#

In flask I want to run a script and if someone requests to run it again it will display that its already running. How can i achieve that? I tried to setup a variable and increase it on script run but if someone leaves the page while the script is running it never resets so you cannot run the script again despite it is finished

native tide
#

if you're checking against the increased variable, just decrease it after the script is finished

#

not sure how you're doing that atm, but you should use something outside of flask to store the content of this variable

#

you'll be running multiple instances of your flask app in production

crimson monolith
#

Hello. Is it a good practice for a PUT request to return the modified resource besides returning 200 OK? Or should it only return an HTTP code and call a GET method?

native tide
#

its a good practice for APIs that are "models" oriented

#

so for something like django rest api

raw field
#

https://channels.readthedocs.io/en/stable/topics/channel_layers.html
They do not allow you to enumerate or list the channels in a group; it’s a pure broadcast system. If you need more precise control or need to know who is connected, you should build your own system or use a suitable third-party one.

Does anyone know another system that can do this? I would like to be able to know how many users are in a group

#

And some information about some status info of a group

golden bone
#

No, of course not. You're in the web development channel. Why would anyone here know anything about web development?

#

Just kidding... What I mean is, don't ask to ask, just ask

#

Or just ask your question. How can I know if I can help or not if you don't ask anything?

indigo kettle
#

I'm gonna need you to sign this contract saying that you will help after I ask though

ivory lotus
heady kite
#

in pycharm whenever i try to run a code it says Unable to create process using(blah blah blah files)

#

anyone know a fix?

cold helm
#

Hi Everyone, I'm building Doctor's App using Django. I have trouble with time slot system

#

Any idea about it?

tidal halo
inland oak
#

I think focus is working only for specific html elements like input

#

that's the issue

tidal halo
inland oak
#

at CSS level you have option only to use target

#

otherwise it requires already javascript

#

frontend framework like Vue.js/React for easy way, Vanilla JS/Jquery for hardway

inland oak
tidal halo
inland oak
#

in frontend framework this action is heavily simplified πŸ€”

#

There is an option to use frontend framework as static library, so I could I guess write and show you it without complicated installations

inland oak
tidal halo
inland oak
# tidal halo I would love that πŸ™‚
<!DOCTYPE html>

<head>
    <meta charset="utf-8"> 
    <style>
        body{
            background-color: lightgray;
            margin: 100px;
        }

        div{
            display: flex;
            justify-content: center;
            align-items: center;

            width: 600px;
            height: 200px;

            background-color: green;
        }

        select{
            width:300px;
        }

        select:focus{
            outline: none;
        }

        .ActiveSelect {
            background-color: red;
        }
    </style>
</head>
#

<body>
    <script src="https://unpkg.com/vue@3"></script>

    <div id="app">
        <div @mousedown="is_select_active=true" @mouseup="is_select_active=false" @mouseout="is_select_active=false">
            <h3>Cities</h3>
            <select :class="{ActiveSelect: is_select_active}">
              <option>Berlin</option>
              <option>Paris</option>
              <option>London</option>
            </select>
          </div>
    </div>

    <script>
    Vue.createApp({
        data() {
        return {
            is_select_active: false
        }
        }
    }).mount('#app')
    </script>
   
</body>

</html>
#

Hmm, we have even focusin and focusout events

#

we could try them

tidal halo
#

it is just changing background color of select. not showing option elements

cold helm
#

I got ('CheckoutView' object has no attribute 'object') while I'm registering

#

def dispatch(self, request, *args, **kwargs):
if self.request.user.is_authenticated:
return HttpResponseRedirect(self.get_success_url())
return super().dispatch(self.request, *args, **kwargs)

def post(self, request, *args, **kwargs):

    form = self.form_class(data=request.POST)

    if form.is_valid():
        user = form.save(commit=False)
        password = form.cleaned_data.get("password1")
        user.set_password(password)
        user.save()
        return redirect('accounts:login')
    else:
        return render(request, 'accounts/doctor/register.html', {'form': form})
#

This is the code

inland oak
#

the principle of technology is the same

#

well, i guess i could write it to for you

tidal halo
inland oak
tidal halo
#

okay

lavish prismBOT
#

:incoming_envelope: :ok_hand: applied mute to @inland oak until <t:1646147048:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 110 newlines in 10s).

river raven
#

!unmute 370435997974134785

lavish prismBOT
#

:incoming_envelope: :ok_hand: pardoned infraction mute for @inland oak.

river raven
#

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

river raven
#

Please use this for large code blocks

inland oak
inland oak
inland oak
tidal halo
#

broken link

inland oak
#

there is some mess in css, not sure what is not necessary πŸ€” a bit lazy to clean 😁

#
        .option:nth-child(1) {
            top: calc(-1px + 49px * 0);
        }
        .option:nth-child(2) {
            top: calc(-1px + 49px * 1);
        }
        .option:nth-child(3) {
            top: calc(-1px + 49px * 2);
        }
#

this thing needs to be wrapped into for loop from scsss

#
@for $i from 0 through 5 {
  .option:nth-child(#{$i}) {
    $number: $i - 1;
    top: -1px + 49px * $number;
  }
}
stark tartan
#

Gaja linux

frank shoal
#

navigation is missing a very important command

#

cd -

#

that will undo the last cd

stark tartan
#

I seen it 🀣 🀣

frank shoal
#

^D doesn't work to clear the line

#

in zsh at least

stark tartan
#

Sorry control + U

#

Now working @frank shoal

#

??

frank shoal
#

πŸ‘

stark tartan
#

You have mac lg

frank shoal
#

Nope. WSL

#

I just like zsh.

#

Also, the default shell in manjaro is zsh

stark tartan
#

😫

frank shoal
#

windows terminal isn't too bad.

#

console host is terrible however

stark tartan
frank shoal
#

are you talking about windows terminal, or cmd?

stark tartan
#

Fuck things

frank shoal
#

no they are not.

#

windows terminal is a terminal application that supports many shells

#

cmd is the original windows shell

stark tartan
frank shoal
#

you mean bash?

stark tartan
#

It is awesome bro

stark tartan
frank shoal
#

What do you think WSL is?

stark tartan
frank shoal
#

It runs an actual distro.

#

You may be thinking of cygwin

stark tartan
frank shoal
#

cygwin is what powers git for windows

#

it fakes a unix environment

stark tartan
#

We only have one terminal that does all jobs πŸ™‚

frank shoal
#

Only one?

steel night
#

gettin some old school mainframe vibes here

frank shoal
#

let's count all the shells linux has. csh, tcsh, sh, bash, fish, zsh

stark tartan
frank shoal
#

And I use manjaro

#

But I use windows at work, and ssh to linux servers

stark tartan
stark tartan
frank shoal
#

because that's what work gives me

stark tartan
steel night
#

lolwut

stark tartan
frank shoal
#

Why are you asking?

stark tartan
frank shoal
#

because I use manjaro at home?

stark tartan
#

So I am asking

frank shoal
#

I am 29

stark tartan
dreamy anchor
#

Hey guys I have an existing django project with three js front-end. I want to use webpack for the front-end however am a bit confused in how to change the file structure. The example projects for the django-webpack-loader have very few files (see snapshot for the assets) https://github.com/django-webpack/django-webpack-loader. Is there a way I can maintain the current structure and convert on build? thanks in advance

zinc lagoon
#

does anyone know what dispatch function does in django class based view

native tide
#

can someone help me with this

golden bone
# native tide can someone help me with this

It's telling you that you haven't allowed the PowerShell script to execute. This may help:

https://stackoverflow.com/questions/4037939/powershell-says-execution-of-scripts-is-disabled-on-this-system

runic sparrow
#

I'm trying to use an API which takes a session ID header with each request for authentication. Up until now I've been manually copying it over from a session cookie, however I'm wanting to upgrade the program so I can add in my credentials in some sort of configuration file (less preferable) or create some sort of "integration" which allows me to authenticate more securely than that. All I know so far is that I log into the account using a Microsoft account integration, but I'm not sure how much that helps. So far, I've got a capture of the web traffic during the login process, but it might as well be in Latin for me. Does anyone have any pointers? Thanks in advance.

#

(I'd rather not supply the capture, as it contains potentially sensitive information)

frank shoal
#

A fast config file could be created using dotenv

#

!pypi python-dotenv

lavish prismBOT
frank shoal
#

access it via os.getenv("CONFIG_KEY")

zinc lagoon
#

i created a new a custom user table in django but it does not have id column can anyone guide?

scarlet kiln
#

I want to make an svg by letting the user draw on a html canvas, but instead of listening for mousemove events while mouse is pressed I want to sample the mouse position regularly (like say 50x second) as long as the mouse is down and update a variable with the delta x and delta y

frank shoal
#

You'll want to make a tick loop. Though I'm not sure if that exactly is web dev

#

Oh, html

#

You can use setInterval(func, delay)

visual cedar
#

I'm at my wit's end. I have apache up and running with a django installation on windows. I can't seem to get them to connect--error logs show "no module named XX", so I'm sure I messed up somewhere but I haven't had luck debugging this. Any hints?

#

specifically, wsgi.py seems unable to find my modules

native tide
#

hey guys! i am a beginner and have been facing lot of small issues with every other step i take. lot of errors have been popping up. I am unable to setup virtual env in specific locations. Do you guys recommend me to delete literally everything (after backing up important projects) and installing each software again. If so how should I proceed?

split snow
#

how to merge 2 list of dict and remove duplicate?

hard whale
#

Hello, I need to make REST API for my python program to make it possible to link it with 3rd party web services. Can anyone recommend any course to learn how to make APIs? I have no background...

inland oak
lavish prismBOT
#

@inland oak :white_check_mark: Your eval job has completed with return code 0.

{'a': 1, 'b': 10, 'c': 11}
inland oak
#

dict is data structure that has unique hashable keys

split snow
#

data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]

how to find duplicate and extract it expected output is

{"pet" : "cat", "name": "ivan"}

inland oak
split snow
#

duplicate dict in a list

inland oak
split snow
#

example

data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]

output = [{"pet" : "cat", "name": "ivan"}]
#

yes sir

inland oak
lavish prismBOT
#

@inland oak :white_check_mark: Your eval job has completed with return code 0.

{'{"pet": "dog", "name": "mark"}': 1, '{"pet": "cat", "name": "ivan"}': 2}
inland oak
#

you are trying to count duplicates in a list, not in a dict

split snow
#

sorry

inland oak
#

!e

data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]
import json
ans = {json.dumps(i):data2.count(i) for i in data2 if data2.count(i) > 1}
print(ans)
lavish prismBOT
#

@inland oak :white_check_mark: Your eval job has completed with return code 0.

{'{"pet": "cat", "name": "ivan"}': 2}
split snow
#

but can we extract what has dup?

inland oak
#

!e

data2 = [{"pet" : "dog", "name": "mark"}, {"pet" : "cat", "name": "ivan"}, {"pet" : "cat", "name": "ivan"}]
import json
duplicates = {json.dumps(i):data2.count(i) for i in data2 if data2.count(i) > 1}
for duplicate in duplicates.keys():
  print(duplicate)
lavish prismBOT
#

@inland oak :white_check_mark: Your eval job has completed with return code 0.

{"pet": "cat", "name": "ivan"}
split snow
#

Thank you so much sir @inland oak

covert yew
#
    date_created = db.Column(db.DateTime(timezone=True), default=func.now())

Output = 2022-03-02 09:11:49
So I have this and I want to show how much time has passed since then and I'm having trouble find a solution...

peak lily
#

Hi I'm need of help. I'm currently making a project in Django, but the question isn’t specific to Django… In adapters.py, I’m trying to import model classes from models.py (see image below). I’ve tried using

from ...grandfather.app.models import *

, but I get an error saying that β€˜attempted relative import beyond top-level package’.

In general I don’t fully understand the path system fully + I don't know what the best practice is for this problem.

Any guidance would be much appreciated.

update:

I've also tried adding 'init.py' files to the grandfather and project directories too, as suggested by somebody on StackOverflow.

https://stackoverflow.com/questions/68554755/valueerror-attempted-relative-import-beyond-top-level-package-python

steel night
# peak lily Hi I'm need of help. I'm currently making a project in Django, but the question ...

I would strongly recommend to not do what you are trying to do. Even if you get the β€œabove top-level import” to work, it will be extremely brittle to any changes in the folder structure or, from which working directory you run the β€˜python manage.py’ commands used to run the Django server. Consider either making an installable library out of whatever is in β€œgrandfather”, or moving it into a child directory of β€œapp”.

#

And yes, you should always add dunder-init files in every directory containing python code

peak lily
steel night
#

You can’t move β€œproject” to a β€œapp/project”?

#

Er

peak lily
#

I'll give it a go.

steel night
#

That’s the key here

peak lily
#

It's in the grandfather

steel night
#

Oh

#

Then there should be no problem.

#

Which import is failing?

peak lily
#

2 seconds, just going to attempt the relocation

steel night
#

No I was confused- you shouldn’t move project into app if project is already a child of the Django work directory

#

So you were trying β€œfrom …grandfather.etc import blah”. Just get rid of the β€œβ€¦β€

#

As long as you’re launching the server like β€œcd grandfather; python manage.py blah” there shouldn’t be any issue

peak lily
#

Sorry for the lack of transparency here. I'm going to add another layer of confusion here, but 'project' is not the directory with 'settings.py' in.

#

So I think the naming conventions might be confusing me. If I place users inside my true project directory, will it still work. I've remained with topic/users because it specified in the docs

#

Also the redirects work when 'project' isn't the true project name

#

So the parent directories are called 'project', 'actual project name' (with settings.py in), and 'app'.

steel night
#

You’ve thoroughly lost me

#

What redirects

#

Please just tell me where your manage.py is lol the only thing that matters for imports in a Django application is the path from the file you’re working on back to manage.py

peak lily
#

Sorry, I really appreciate the help, I'm lost myself .. haha

#

also the redirects
get_login_redirect_url(self, request)
get_logout_redirect_url(self, request)

steel night
#

Not sure why you’re bringing that up it seems entirely irrelevant to the import issue

peak lily
#

I want to import my models as I have a cookie session and want to set a cookie session on login

#

Scrap the models for a second. How can I set a cookie session in these redirect views?

#

Maybe you're right about trying to import the models in general, and I should rethink the approach.

steel night
#

It’s been a a solid year since I played around with Auth in a Django app. I don’t remember how I did it. Sorry

#

And yeah so β€œwhat You want to do with the code you import” is entirely irrelevant to β€œhow to write the import statement”

peak lily
#

Agreed.

#

Hopefully next time I can really figure out what I'm trying to ask too.

#

I think that what I want to do can probably be done via signals and I'm trying something impractical. Back to the drawing board ... xD @steel night thanks for your time, and advice.

prisma ravine
#

Does web design falls under web development?

steel night
#

@native tide see the channel description.

#

you can ask about stuff that is referred to in the channel description.

#

"Help with web technologies such as FastAPI, Flask, Django, HTML, CSS, and JS."

native tide
#

Hey πŸ‘‹ What's your favorite admin panel solution for Django? Django Admin or something else?

tidal halo
warm aurora
#

Heyy

tight pasture
#

@frank shoal

frank shoal
#

?

tight pasture
#

do you rmr my project from the other day

#

the one i had to exract for it to work??

warm aurora
#

@frank shoal

frank shoal
#

Ask your question

warm aurora
#

My question is if u have to modifiy the last codes how do i do that while i keep it zipped

frank shoal
#

Why is it zipped?

warm aurora
#

Because otherwise the images wouldnt upload

frank shoal
#

You can't rezip it?

#

The images are already uploaded anyway.

warm aurora
#

No each assisgnment we upload a new website link

#

So like we build on last weeks code

frank shoal
#

You should make a new zip file each time.

warm aurora
#

I didnt make the first one

frank shoal
#

And you should be able to copy a folder

warm aurora
#

Ik but its not workin

#

I just dont understand the problem

#

As in why the images dont upload if not zipped

frank shoal
#

They do upload, but they upload to the folder you dragged them to

#

i.e. not in a subdirectory

#

the folder doesn't get uploaded. Each file in the folder gets uploaded

warm aurora
#

So inside last weeks zipped file theres 5 things… images folder and then file 1 file 2 file 3 and file 4

#

Files 1-4 r different this week but the images r the same

#

I tried to replace files 1-4 but it wouldn’t work

frank shoal
#

windows explorer doesn't support updating zip files. Use 7-zip instead

native tide
#

Any chance anyone know how to fix this

frank shoal
#

powershell uses ` for escapes

#

i.e. ```py
ts-node foobar -e x
-t z

muted meadow
#

I currently use pypyjs to compile the python code in the web so I ownt have to send it to the backend server then people would be able to do all sorts of stuff with it

#

But maybe there is a better solution

stiff bramble
#

guys, how do i start my api in procfile (heroku, fastapi)?

#

my server is on file, now boot is on another

untold scroll
#

Hi guys, I have a doubt about Django. I have a BlogPost model in which I have three attributes (author, title and content). Both title and content are editable when I want to create a new post with CBV, such as:

    model = BlogPost
    # hits .save() after all the fields are validated
    fields = ["title", "content"]
    # looks for model_form.html if template_name isn't specified
    template_name = "pages_app/blog_form.html"
    success_url = reverse_lazy('pages_app:blog') ```

but one thing I'm not sure is how to use the current logged in user's username to use as the "author" attribute. I'd love to know what to do from here, thanks in advance!
arctic hamlet
#

same with if you wanted to access a user's email: request.user.email in the view logic

untold scroll
young hazel
#

Hey there Friends ! I need help. I'm creating A django app,where after search data is fetched from the api and rendered as list content cards
But I want to create a seperate page,where when user clicks each card is redirected to the page of that card with more data in it
How should I do that ?

agile pier
#

how to lock a user after 5 unsuccessful login attempts in django?

covert yew
#
@views.route('/delete-comment/<comment_id>')
@login_required
def delete_comment(comment_id):
    comment = Comment.query.filter_by(id=comment_id).first()
    db.session.remove(comment)
    db.session.commit()

    return redirect(url_for('views.home'))

I have tried fixing this for a while and Im not sure what is the problem

arctic hamlet
covert yew
#

wow im dumb

#

Thanks @outer apex

#

my brain was not working

amber patio
#

I'm finding flask more flexible and versatile than django but since I'm relatively new to python as it I'm getting more people's opinions that django is used more than flask. Although I don't think that there are any drawbacks using django over flask but I want some overall opinion especially in terms of demand in the market and usage. Which one do you prefer over the other and why?

modern inlet
eternal kestrel
#

Hi I need some assistance, using python3, flask, apache2, mod_wsgi

#
activate_this = '/path/to/env/bin/activate_this.py'
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))
#

will not work for me because I dont have activate_this.py

#

i got it but it didnt work

#

im using python3 venv

#

not virtualenv

crystal pelican
#

activate_this is meant to be the file you run that activates the venv

eternal kestrel
#

Hi @crystal pelican so if its the regular venv bin/activate it doesnt work, it has to be python

#

virtuenenv has an onld file flask docs refer to called activate_this.py

#

i downloaded it and put it in bin like stackoverflow said because it should work

#

but it did not solve my issue

#

my issue is

#

I cant import local python files to my flask app.py

#

I sorted out venv pip imports

#

which now work

#

so i guess it is using my venv

#

idk

#

im lost

#

local files wont import

#

pip files will

#
front
β”œβ”€β”€ app.py
β”œβ”€β”€ frontvenv
β”œβ”€β”€ func.py
β”œβ”€β”€ __pycache__
β”œβ”€β”€ static
└── templates
#

is my layout in /var/www

#

imoprt func

#

does not work

#

ModuleNotFoundError: No module named 'func'

#

WSGIDaemonProcess app python-home=/var/www/html/front/frontvenv python-path=/var/www/html/front

#

doesnt work

#

still not importing

eternal kestrel
#

fixed it

#

whats this issue

#

Target WSGI script <path> does not contain WSGI application

#

this is in my .wsgi

#

from app import app as application

eternal kestrel
#

got it

#

solved

manic crescent
#

Hi
I am using function based APIs (in views.py) in DjangoRestFramework and want to access variables from one API to another using request.sessions
However, I am able to add into sessions for only one API at a time and when I access the session dict in another API, it is empty.
If anyone has any clue on how to get this working please contact me. Thanks!

#

If you know any other way of doing (except global variables) it you're welcome to answer

valid garnet
#

Vague/Open-ended question, what is the neatest way to make a website chatbot?

golden bone
golden bone
pure furnace
#

yooo

#

can someone check an error in my website

#

scihigh.online/surp.html

agile pier
golden bone
agile pier
# agile pier

i m getting this error, i assume this is because i haven't given view name

#

path('captcha', include("captcha.urls")),

pure furnace
agile pier
#
def cap(request):
    if request.method == "POST":
        form = MyForm(request.POST)
        if form.is_valid():
            print("success")
        else:
            print("fail")
    form = MyForm()
    return render(request,"cap.html",{"form":form})
golden bone
agile pier
golden bone
#

Duh, that's for Flask. But you're right that it's just not pointing to your route, some gotcha somewhere

agile pier
#

i m using django

agile pier
golden bone
agile pier
#
<!DOCTYPE html>
<html>
   <head>
      <title>Captcha</title>
   </head>
   <body>
      <form method="POST" novalidate>
         {%csrf_token%}
         {{form.captcha}}
         <input type="submit" value="submit">
      </form>
   </body>
</html>
#
from django import forms
from captcha.fields import CaptchaField

class MyForm(forms.Form):
   captcha=CaptchaField()
cold helm
#

Hello, I'm working on 2 apps. App (A) only accounts(login/signup), and App (B) is for e-commerce(sell) .In-app B (e.g when the user try to add to cart it shows an error regarding on No User exist) but the user is logged In, in App A

#
Environment:

Request Method: POST

Request URL: http://127.0.0.1:8000/addtocart?id=1

Django Version: 2.2

Python Version: 3.7.9

Installed Applications:

['django.contrib.admin',

'django.contrib.auth',

'django.contrib.contenttypes',

'django.contrib.sessions',

'django.contrib.messages',

'whitenoise.runserver_nostatic',

'django.contrib.staticfiles',

'appointment',

'accounts',

'bootstrapform',

'myuser']



Traceback:

File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\env\lib\site-packages\django\core\handlers\exception.py" in inner

34. response = get_response(request)

File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\env\lib\site-packages\django\core\handlers\base.py" in _get_response

115. response = self.process_exception_by_middleware(e, request)

File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\env\lib\site-packages\django\core\handlers\base.py" in _get_response

113. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\myuser\views.py" in addtocart

88. cart(User = request.session['User'],item_id = id , item_name = objmeds.name, quantity= quantity , saleprice = objmeds.sale_price, totalprice = (int(objmeds.sale_price) * int(quantity))).save()
File "C:\Users\Talat\Downloads\django-doctor-appointment-master\django-doctor-appointment\env\lib\site-packages\django\contrib\sessions\backends\base.py" in __getitem__

54. return self._session[key]
Exception Type: KeyError at /addtocart
Exception Value: 'User'
pallid frost
#

Hey guys. When making an API, what framework would you say is the most in demand in the professional scene: FastAPI, Flask or Django?

golden bone
pallid frost
#

OK, thanks

wicked pier
#

Hi, got a question.
I'm trying to make a simple Flask app which saves to SQLite, but every time I try to save to the db, I get some error about the initiating thread and the thread adding to the db being different

summer galleon
#

Anyone here have experience using Microsoft Authentication Library (MSAL) for authentication with fastAPI as backend and a React frontend?

wicked pier
#

What is the idiomatic way to have a long-lived connection to the database?

torn valley
#

hi
im a new python programmer
and i want to know how can i improve my power of write code in python in any platforms
can somebody give me some info ?

golden bone
surreal thicket
wicked pier
#

Yes, but I've been having a hard time figuring out how that's done.
I think I did find something though

surreal thicket
#

some of them do connection pooling for you

#

also sqlalchemy does connection pooling

wicked pier
#

Not asyncio. Sqlalchemy also looked a little heavy for what I'm trying to do.
I think I found a way to do what I want using Flask's g object

surreal thicket
#

so you can use flask.g to set the connection to be used, but you will still want a connection pool that survives between contexts

#

a global, or an instance attribute on your flask app object, is fine for this

runic sparrow
#

I'm trying to interact with a website API, however I'm a bit stumped on authentication. When I use this web service, the only way to authenticate is via a Microsoft integration, however I'm not sure how to do that programmatically. Is there a Microsoft endpoint I have to utilise? Do I have to look into OAuth2? Or would the best way be to replicate the user's process in navigating the page sign-in?

Sorry that my question is a bit open-ended, I'm pretty clueless on this topic and don't know what direction to head in to proceed. Any help is greatly appreciated!

surreal thicket
#

@runic sparrow that's an unusual problem. is this some kind of automation task for your job?

runic sparrow
surreal thicket
#

VLE?

runic sparrow
#

virtual learning environment

#

like Google Classroom

#

however, we use "Firefly Learning" instead, and to be honest it's quite a pain

surreal thicket
#

i see. this is teetering on the edge of rule 5, so honestly i'm not sure we're allowed to help with this

#

let me ask

runic sparrow
#

I doubt it's breaking any rules - I'm not web scraping or acting as an user, it has a proper REST API (https://[SchoolName].fireflycloud.net/api/v2/)

surreal portal
#

Since the wheel isn't available yet on Selenium, how do I scroll to bottom?

golden bone
golden bone
runic sparrow
#

even their own developers seem to struggle - the mobile app implements only around a quarter of the site's features

wicked pier
#

I'm looking for as simple an answer to this as possible

#

aka, no ORM or anything needed

distant plover
#
@app.route('/add/<int:n1>,<int:n2>')
def add(n1,n2):
    sum = n1+n2```
#

here instead of n1 and n2 just , i want to take a whole list or tuple of integers

#

idont know how to do that

wicked pier
#

with the numbers you're looking to add in the request body

distant plover
#

i m building a rest api

surreal thicket
#

in general you'd have to inspect the network requests to see what headers and other payload information is sent

#

maybe an auth header, or an access token as a url query parameter, or something in the request body even

surreal thicket
#

this is more like a procedure call

surreal thicket
#

but this is more of an #async-and-concurrency question: "my database library does not provide connection pooling, how can i build a connection pool? what problems do i need to watch out for?"

astral thistle
#

Hi guys excuseme, is there another way to create a Relational Database without using Mysql and ForeignKeys?

golden bone
eternal kestrel
#

Hi please assist me

#

I'm using flask, apache, mod WSGI, I can run the same set up locally and everything works fine. on my VPS I get error 403 Forbidden

You don't have permission to access this resource.

#

I have 755 file permission on /var/www/html where my files are

#

and 644 on files

#

chown is www-data:www-data

#

still doesnt work

#

what do i do please

#

wheres the flask experts

native tide
#

default pfp gang

eternal kestrel
#

sudo what? lol

#

its apache

native tide
#

have u never used linux

#

oh

#

u cant use flask with apache i think

#

oh u can

#

mb

#

im not good w flask

#

lmao

eternal kestrel
#

flask recommends using a production server with WSGI module

#

yea

native tide
#

try gunicorn

wicked pier
eternal kestrel
#

Probably caused by your application running as the wrong user. Make sure the folders the application needs access to have the proper privileges set and the application runs as the correct user (user and group parameter to the WSGIDaemonProcess directive)

#

user=www-data group=www-data

#

doesnt work

#

I might try gunircorn

#

I want to use apache

eternal kestrel
#

why is flask trying to serve my files from /var/www/html instead of the dir configured in apache which is /var/www/html/data

#

i get 403 on /var/www/html/requestedfile instead of /var/www/html/data/requestedfile

#

Hi, apache and mod_wsgi are trying to serve my flask routes at /var/www/html/requestedroute instead of /var/www/html/data/requestedroute wihch is configured in my apache configruation and site conf. as a result I get 403 error. how do i fix this please?

tepid lark
#

How would I go about storing a requests (the http library) Session between requests in Django?

#

I'm using a pre fork worker gunicorn setup

tepid lark
#

what about it

visual cedar
#

any easy to digest resources for learning how to let others see my app? all I know is that I need a web server?? so I installed apache, and I now need to somehow find a way to throw my app in front of port 80 but this feels a little over my head

rotund perch
#

Hello, I have a question more focused on web hosting. If you created a Django RESTful API & created a seperated Frontend to request Django API endpoints to get responses, is it possible to host it on one webserver like making the Frontend & the Backend on the same Domain or create subdomains for it? Also similar situation is it possible to host 2 or more Backend apps (APIs) on one domain/webserver as I mentioned above? (I usually use Heroku because it is free, if there is a free alternative to achieve my goal or even a paid provider, good to share).

inland oak
#

in any configuration

#

usually there are two approaches

#

Web server/Reverse proxy like nginx will allow you to configure it

rotund perch
#

Do you have any idea how to achieve that on Heroku? Because it requires to detect the language you used in the file (Like Python) and do some configurations so I dont know if I had a node js and a Django file how it would work

inland oak
#

Linux server like Ubuntu 20.04, is all that is needed for simple setup

#

For more advanced setups people deploy stuff like that to Kubernetes ;b

rotund perch
#

Okay. Thanks for helping!

inland oak
#

U a welcome.

inland oak
#

Docker + Docker-compose should be a good start for simpliest setup

native tide
#

usereditview() missing 1 required positional argument: 'form'
this err comes to me
and this is my
views.py

def usereditview(request, form):
   UserProfileForm(request.POST, request.FILES, instance = Profile.objects.get(user=request.user))
   if request.method == 'POST':
       if form.is_valid():
           form.save()     
           return redirect('profile')  
   return render(request, 'registration/useredit_form.html', context={'userprofile_form': UserProfileForm})

can any one help me to fix it
django

rotund perch
rotund perch
inland oak
#

it is cheap and quality provider to get started

#

and concentrating first on... getting used to linux+docker
and testing is good idea too

rotund perch
inland oak
#

everything is automatized to setup servers

#

u just aren't probably ready for this yet, regular Linux + Docker/Docker-compose should be a start on this road

native tide
#

Ω„Ω…Ψ§ Ψ¨Ψ΄ΩŠΩ„Ω‡Ψ§ Ψ¨ΩŠΨ¬ΩŠΩ„Ω‡ Ψ―Ω‡

#

ايرور برآو

native tide
#

k

rotund perch
agile pier
#

how do i get prev 6 months data from django models?

rotund perch
#
TheModel.objects.filter(dateField__lte=<date>)

#Or
Sample.objects.filter(date__range=["2011-01-01", "2011-01-31"])
open kayak
#

hi i have two user models (A and B) in flask, and i'm trying to figure out how to use flask-login's user loader to login either A or B, any idea how to do that?

agile pier
#

how do i apply strftime or something similar to get only month from my DateTime field while filtering a django model?

#

graphs = graph.objects.filter(organisation__name = username, month = prev_mon)

#

Here, month is a datetime field, so it is in the format 'YYYY-MM-DD' , and prev_mon is 'Feb'

#

How do I compare only month of the month field?

rotund perch
#

Try graphs.TheDate.strftime('%M')

tacit kestrel
#
def register_collector_process():
    """Process collector registration."""

    if request.form.get('Collector'):
        return redirect('/register_collector')
    if request.form.get('Store'):
        return redirect('/register_store')```
Keep getting a 405 that it wont redirect after I check one of the options in the checkbox. Any ideas why?
agile pier
rotund perch
#

Your variable graphs returns a querset right?

agile pier
#

Yes

rotund perch
#

Whats the field on the model graph that holds the date?

agile pier
#

month

rotund perch
#

Uts name is month?

agile pier
#
class graph(models.Model):
    organisation = models.ForeignKey(organisation, on_delete = models.CASCADE, null = True)
    active_assets = models.PositiveIntegerField()
    inactive_assets = models.PositiveIntegerField()
    vul = models.PositiveIntegerField()
    dataleaks = models.PositiveIntegerField()
    month = models.DateField(null=True, blank=True)
rotund perch
agile pier
#

it is giving error in month = prev_mon while filtering as i told

#

['β€œFeb” value has an invalid date format. It must be in YYYY-MM-DD format.']

rotund perch
#

Wait how are you saving data?

#

How are u creating the graph model objects?

rotund perch
#

No this is the model

#

I mean

#

The fields on the db

#

Go to the admin

#

And scrnshot

agile pier
rotund perch
#

Oh I see

agile pier
#

Yes

rotund perch
#

If you notice the Month field is "2021-06-15" So prev_mon must be the same way

agile pier
#

can't we do strftime like we do normally?

rotund perch
#

I think it gives you a number not a name

agile pier
#

Okay, thanks for the try though

rotund perch
#

You want to get all the data for the prev month right?

agile pier
#

Yes

rotund perch
#

you can with graph.objects.filter(month__lte = "2022-02-28")

#

lte stands for less than or equal

agile pier
#

okay thanksπŸ‘

rotund perch
#

your welcome

eternal kestrel
#

token is a variable you defined in your for loop statement so it only exists within the loop

#

after loop is over its gone

#

so after you print each token on each line token doesnt exist when the loop ends

boreal parrot
#

oh

eternal kestrel
#

Can anyone help with this: apache and mod_wsgi are trying to serve my flask routes at /var/www/html/requestedroute instead of /var/www/html/data/requestedroute wihch is configured in my apache configruation and site conf. as a result I get 403 error. how do i fix this please?

eternal kestrel
#

<Directory /var/www/html/front> <<---- this is my directory block in front.conf

#

this is the error in apache logs

#

AH01630: client denied by server configuration: /var/www/html/buy

#

my flask app is supposed to server /buy from the root level

#

i dont get why it says /var/www/html/buy when it should be /var/www/html/front/buy

#

and also, does this indicate flask routes are working