#web-development

2 messages · Page 68 of 1

native tide
#

okay, thanks

#

They're the best resource imho and many people more knowledgeable than me recommend it too.

#

I wonder what WordPress uses

wind escarp
#

@molten quarry Hey
I have read that book you suggested till chapter 6, I have really enjoyed it till now, chapter 7 is about memory management, not something I am interested in and the next chapters are something like getting inside node.js and js's inner functionality.
I am planning to take a look at some major JavaScript frameworks, do you think the other chapters are necessary or something?

stable plover
#

I'm learning about oauth 2 and I want to implement a flask app that makes a user login with discord and prints out their username and profile picture
I'm following this guide, but for discord: https://github.com/authlib/demo-oauth-client/blob/master/flask-google-login/app.py

My /login endpoint which redirects the user to discord works fine, and discord correctly sends the oauth code in the URL. However, when I try to exchange the code for tokens, that's when my flask app throws an exception authlib.integrations.base_client.errors.OAuthError: invalid_client: invalid_client

#

I'm not sure why this exception is being thrown

#

to exchange code for token shouldn't you use token = oauth.discord.fetch_access_token()

#

please do let me know if you need any other info

stable plover
#

OH MY GOD

#

It was just an incorrect client secret

white garnet
#

hello all, what is the difference between django and drango rest framework? when to pick one over the other.

dense slate
#

@stable plover it do be like that

stable plover
#

believe me I spent a day debugging this

#

the RFC is not very clear on that

craggy lava
#

Hey can someone help? I wanted to make a simple Flask app, so i started a template app from visual studio 2019, but whenever i try to start the local server, Python returns "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 3: invalid continuation byte", i have no idea what's wrong or where it's wrong

dense slate
#

I spent a week on google oauth. It is so unecessarily complicated.

stable plover
#

@craggy lava can you post your trace?

#

@dense slate I would say once you understand the concept, it becomes more clear

dense slate
#

I agree. Once it works, it's like "well yea, obviously that's how it works. Why didn't they just write it the way I now understand it."

lavish prismBOT
#

Hey @craggy lava!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

craggy lava
stable plover
#

what are you listening on?

#

are you making a url request somewhere?

#

see the last line of the trace
hostname, aliases, ipaddrs = gethostbyaddr(name)
I think something is up with name

craggy lava
#

I'll check the code, i just fired up the template on VS2019 and i'm very new to Flask, so i'll do some searching

craggy lava
#

Ran again from Visual Studio instead of starting from console, it says the wrong byte is coming from this part of runserver.py (probably the script that starts the server)

stable plover
#

what is the SERVER_HOST value?

#

when set via environment variable

#

try replacing both HOST and PORT temporarily with localhost and 5000

craggy lava
#

SERVER_HOST is 'localhost' on the environment var

#

I'll see if it works

try replacing both HOST and PORT temporarily with localhost and 5000

#

Also tried '127.0.0.1' just in case

stable plover
#

@craggy lava give it a named parameters

#

like host='localhost'

#

port=5555

craggy lava
#

OHGOD I CAN'T BELIEVE IT

#

MY MACHINE'S NAME WAS "ROGÉRIO" WITH AN "É"

#

SO IT WAS MESSING WITH THE HOST NAME

native tide
#

i have a class called loggedin and a class called loggedout on my flask app, i use these to know which style to use, but it doesnt work, thoughts?

#

nvm got it

stable plover
#

@craggy lava huh? domain names are supposed to be UTF-8

#

can you file a bug report?

craggy lava
#

Yeah, i thought it was strange too as UTF-8 supports that kind of accent, i checked it just in case and it worked

#

I'll file a bug report later

native tide
#

all the code im seeing makes me scared to start using djanog

#

django

icy wasp
#

@native tide have to be more specific

#

hey all. I'm in Flask.jinja.
any simple way of multiplying the string "more" by the loop.counter in jinja?
https://paste.pythondiscord.com/wejemubali.js

I want the output to be something like,
"some text..."
"some more text..."
"some more, more text..."
and so on.

molten quarry
#

@native tide I feel the same way, even after spending the last 2 months working through a Django textbook. However, like every programming language, what you don't understand will always look intimidating until you've learned gotten comfortable with it.

Find a resource and get goin!

icy wasp
distant trout
#

can someone guide me to the right direction

#

i know the basics of flask

#

like i can build a fully functional blog with flask but i wanna build more

#

is there other courses/tutorials i can follow to go more indepth into flask?

marble carbon
#

yep hold on

#

@distant trout it's a series that covers a lot ^

distant trout
#

thank you! @marble carbon this seems to have a lot of information regarding flask 😄

marble carbon
#

yep

quasi thorn
#

what are some front-end frameworks that work well with django

native tide
#

Quick q’s what is better for a beginner flask or django

quick cargo
#

Flask probably

native tide
#

When i want to run flask on linux for testing with sudo python3 app.py it doesnt do anything

quick cargo
#

do you actually have app.run() for testing

#

or have you been running it on your pc with Flask's cmd line

native tide
#

i have it on gcp

#

if name == "name":
app.run(host="0.0.0.0", port=80)

native tide
#

@quick cargo

quick cargo
#

i wouldnt bind it to your external address if i were you

native tide
#

Why not?

#

@quick cargo

quick cargo
#

Are you deploying this site?

native tide
#

i want to show it

#

only

#

and later deploy

quick cargo
#

eh then thats alright ig

#

still risky

native tide
#

risky??

#

but it doesnt still work

quick cargo
#

whats your full code

native tide
#

The whole?

quick cargo
native tide
#

where can i copy it

#

Paste it

#

Okay here

quick cargo
#

Quart is not Flask

#

🤔

native tide
#

I had the same problem with flask before

#

I didnt fix it

quick cargo
#

dont you need to run it as sudo?

#

sudo python3 ./app.py

native tide
#

i run it

#

./?

#

It doesnt do anything

#

It doesnt matter where my files are located right?

quick cargo
#

i mean yes?

#

If youre not cd'd into the folder containing the file its not gonna run a non existant file

native tide
#

IM there

#

I just saw that i have an apache server somehow running

quick cargo
#

thats pretty normal for appache running on port 80

#

just run it on a port > 1000

native tide
#

Apache or flask

quick cargo
#

Quart

native tide
#

Still doesnt do anything

quick cargo
#

stop saying Flask when its not Flask, it just makes life confusing

#

What is the exact command you're running?

native tide
#

doesnt say anything no errors

quick cargo
#

🤨

native tide
#

Why??

coral raven
#

Cd into the folder and run by saying
python app.py

native tide
#

I do it

#

and its sudo python3

coral raven
#

This is if you have __name__ == __main__

native tide
#

i have it

coral raven
#

Then what happens

#

It doesn't run?

native tide
#

Nothing

#

No errors nothing

coral raven
#

What does it say

native tide
#

nothing

#

i said nothing

coral raven
#

Drop the sudo

#

And run

native tide
#

Still nothing

coral raven
#

That's odd

#

What os

native tide
#

linux

coral raven
#

Try this

#

export FLASK_APP = app.py
export FLASK_DEBUG = 1
flask run

native tide
#

I use quart

coral raven
#

In the terminal

native tide
#

so i got it to run

#

Put on localhost

#

I need it to run on external ip

coral raven
#

SET FLASK_ENV=development

flask run -h [yourIP] -p 8080

you will get following o/p on CMD:-

Serving Flask app "expirement.py" (lazy loading)

Environment: development

Debug mode: on

Restarting with stat

Debugger is active!

Debugger PIN: 199-519-700

Running on http://[yourIP]:8080/ (Press CTRL+C to quit)

Now you can access your flask app on another machine using http://[yourIP]:8080/ url

#

I found this on stackovflow

native tide
#

k i got it to run but its not accesible

#

with this command sudo QUART_APP=app.py quart run -h 0.0.0.0 -p 1000

terse surge
#

hello

#

im using django-storages

#

and i get the following error

#

when i try to upload media files

#

'NoneType' object has no attribute 'stat'

vagrant owl
#

Guys, how do I get started with learning building rest apis in python? I wanna use Flask. Apart from the documentation, are there any good sources you'd recommend?

quick cargo
vagrant owl
#

Thanks dude

#

I've trying to Google and stuff but I haven't had much success

#

I will check it out

vagrant lynx
#

Hey, does anyone know of a framework similar to Dash that is a bit more open ended on the front end? I'm looking to build an enterprise reporting tool with a Python backend and Angular9 front end and I'm curious what else might be out there to help abstract the transformation of a web request to an analytics DB query?

limber laurel
#

How do you create the ability to rollback in flask-migrate, if your migration failed? Because once I destroyed my database that way.

#

Or should I just back up my database

feral owl
#

I'm trying to create a webpage in django that contains a search box. After submitting form data, it connects to a java library and returns the search term in a new page. I'm using django 3.0, so jython doesn't look like it's supported. How can I import a java library into django?

zealous siren
#

@vagrant owl I'd also look at FastAPI if just need APIs

vagrant owl
#

@zealous siren FastAPI?

zealous siren
#

Yes, FastAPI

vagrant owl
#

Aah, okay. Yeah, thanks bro.

stray coral
#

I am trying to filter my posts by dates but it is not working with pagination - when I go the next page - the queryset is forgotten https://dpaste.org/O9A1

dark hare
#

@limber laurel yes you should backup, also is there an option for an atomic transaction in flask, but how did your migration fail?

viral sphinx
#

Hey guys so I’m working with Django right now and I wanted to know what’s the best software for caching memory ?

cold anchor
#

redis

viral sphinx
#

Thanks

#

There are very minimum documentation on it

#

Is it easy to configure?

cold anchor
#

are you making a cache to use in your django app?

viral sphinx
#

Yeah I want to be able to store some data in the clients browser to reduce request time

#

I’m also new to memory caching

molten quarry
#

Easiest is memcached. However redis has more options that you can grow into, which for me makes it more worth knowing. Nothing wrong with memcached though, it works great.

viral sphinx
#

Memcached is built in with Django or dependent?

#

Independent *

teal patio
#

Just started webdev, any tips from you guys would be much apreciated. Looking to use flask to put some of my python projects on here. https://tisbury.tk

limber laurel
#

@dark hare I had migrated my database and created a new column that is not nullable, dont know how I would bypass that in future, as today when migrating even with a default field, my previous objects had None inside of that spot instead of my default value, so maybe you know how I could make it use the default value

dense slate
#

Is deleting the column an option?

molten quarry
dense slate
#

Could you delete the column, the recreate it with a default?

#

If all of it is null.

#

@limber laurel

molten quarry
#

Biggest advantage with redis is that you can persist data. So it could act like a second, very fast, database. Useful for storing values that change frequently (views on a page, stats, etc)

warped falcon
#

I want the get_choices_list() to be called every time the SampleModel is instantiated but that doesn't happen...how do i do it?

limber laurel
#

@dense slate Only one row ends up being jull, if I were to delete the whole column then my data would be gone

There is something called server default, will look into that

odd oar
#

@warped falcon Put it in the init function then, since that is what runs when you instantiate an object

#

Right now you have it as a class variable

#

e.g. SampleModel.user_choice gives you the value, you don't have to instantiate it

viral sphinx
#

Thanks fishy

#

I’ll look into it, appreciate it

#

Also what’s the different between memcache and just storing/caching information locally (on browser)

#

Would we have to use JavaScript for browser based caching ?

zealous siren
#

yes

warped falcon
odd oar
#

That's a glitch with your IDE, self is an argument to the function

#

But also that's not what I meant

warped falcon
#

@odd oarcan you show how to do it?

odd oar
#

If you want user_choice to be different for each instance it needs to be an instance variable

#

so set self.user_choice to what you have now inside the __init__ function

native tide
#

🐍

broken basin
#

Anybody Using Python for web development.

cold anchor
#

Yes many of us are

broken basin
#

I am using Python. Is Node better than python for backend development?

odd oar
#

if you have a lot of people working on it that know js better than python yeah

plain zealot
#

I am trying to connect these two text boxes however they are apart by a space. Originally, I just added all of them into <p></p> but that did not work at all. Anyone has suggestions on getting these two text boxes together?

brittle iris
#

hey guys

#

i have this

#
{% block content %}
    <div class="row">
        {% for product in products %}
        <div class="'col-lg-4">
            <img class="thumbnail" src="{{product.imageURL}}">
            <div class="box-element product">
            <h6><strong>{{product.name}}</strong></h6>
            <hr>
            <button data-product="{{product.id}}" data-action="add" class="btn btn-outline-secondary add-btn update-cart">Add to Cart</button>
            <a class="btn btn-outline-success" href="#">View</a>
            <h4 style="display: inline-block.float: right">
                ${{product.price|floatformat:2}}
            </h4>
        </div>
    </div>```
#

i want it when i click View

#

it opens up a small overlay of the item and the item description

#

how can i do this ?

slow briar
#

Guys

#

I wanted to start a twitter-like website

#

So which framwork should i use

#

Django or Pyramid

#

[ Flask is too micro for this, sigh ]

native tide
#

I'd use Flask, it depends what features you want on your app.

opal robin
#

hi

deep cave
#

hiya.

#

you mean rest as in the Django REST Framework, right?

opal robin
#

so hm is rest very different from django

#

yes

deep cave
#

well, DRF sits on top of Django as a sort of add-on

opal robin
#

i'm new on web development and i've just learned django

#

kind of

deep cave
#

Django is big and has many features to learn

#

DRF is basically just another one of those features, once you install it

#

it's not that hard to work with

opal robin
#

with drf you mean rest?

deep cave
#

yes

#

the django rest framework

opal robin
#

ok

#

but django is a framework itsself right?

deep cave
#

yes, Django is a web framework

#

DRF, even though it literally has framework in the name, is really just a Django application

#

it extends the functionality of Django

opal robin
#

ok thank you

deep cave
#

it's not a web framework in and of itself

opal robin
#

one more question please, i've heard that django has more things built in compared to flask

#

so why do poeple still use flask

deep cave
#

yep

#

well

opal robin
#

if django make there way easier

deep cave
#

sometimes people don't like the things that are built into Django

#

they want more control

#

with Flask, you can still get those features that are built into Django - stuff like migrations, object-relational mapping, and so on

opal robin
#

yeah i get it

#

but is it worth it

deep cave
#

but you would install them as third party modules

opal robin
#

to make everything from the begining

deep cave
#

you don't have to make them yourself

#

there's lots of flask extensions out there

opal robin
#

but then why does dajngo and flask exists why there isn't only one

deep cave
#

haha

#

because everyone thinks they can do better

#

and then they try. and sometimes they do

opal robin
#

oh lol

#

but that's good

#

having more variety

#

that's how capitalism works right

#

competition makes things better........i suppose

deep cave
#

Django is wonderful. Flask is great too. They're different. Flask gives you more freedom to choose. Django imposes its really excellent set of tools.

#

Django comes with batteries included

#

I use Django for all my personal projects, but we use Flask where I work.

opal robin
#

what are batteries

#

or were you joking

#

I use Django for all my personal projects, but we use Flask where I work.
@deep cave i was required to learn one of the 2 for a job and i chosed django

#

i was surprissed how could a company use both languages

deep cave
#

batteries included is a term that means "comes with everything you need"

opal robin
#

yeah i get it thanks

#

thank you for your explanation

#

you can find very polite people in this web servers

deep cave
#

we try

opal robin
#

but why do you use your time to help others

#

i've never understood that

#

and i have always wanted to ask

deep cave
#

because when I was learning how to code, I didn't have a place like this to go and ask questions.

#

and I wish I did.

#

so I'm trying to be the change I want to see in the world.

opal robin
#

yeah right when i started learning c++ at first it was the same

#

you're a good person

#

thank you

deep cave
#

but also, it's because helping others is a great way to master your own skills

opal robin
#

that's right too

deep cave
#

you don't really know anything until you know it well enough to teach it to people.

opal robin
#

true

#

i'm going now

deep cave
#

see ya

opal robin
#

it was nice to meet you

#

bye

deep cave
#

you too

slow briar
#

It is very difficult to iplement multi-user login in Flask

native tide
#

What do you mean by multi-user?

#

And, I doubt it

slow briar
#

Like twitter

native tide
#

you mean users following other users etc

slow briar
#

It is gonna be used my multiple users at the same time

native tide
#

Don't get you, but there are third parties that make the feature feasible.

slow briar
#

Like, many user will be logged in at once, and it should mess thigns up

#

It is very difficult with Flask

native tide
#

User flask-login as third party and you shouldn't have a problem.

#

I'm not a daily Django programmer, but it is definitely feasible and quite straightforward in Flask

#

Choose the fw you're most comfortable with

slow briar
bleak bobcat
#

Yea, both django and flask have third party for social login

stray coral
#

Hi, Using django - I am trying to filter my posts with post_date and newspaper_title - was able to do so with only post_date but how to do it with newspaper_title as well or with only newspaper_title. Here is my code : https://dpaste.org/oTQu

kindred ether
#

Does someone have django example for discord?

#

Cause I am not sure if I wanna use django or flask yet.

bleak bobcat
#

Do you already have a project idea or do you just wanna learn ?

kindred ether
#

I have a project idea, it's a existing project done in wordpress that I am gonna redo in either flask or django.

#

Only requirement is discord oauth really

bleak bobcat
#

Ah

kindred ether
#

I used the pycharm option for django template

bleak bobcat
#

In both Django and Flask you'll probably use a third party library for that, so it's even

quick cargo
#

there's a lib called request_oauthlib which is what alot of people use

native tide
#

If you decide to use Django I absolutely recommend looking into cookiecutter to bootstrap your project

#

Actually I meant cookiecutter Django

kindred ether
#

Is Django still useful if I don't use their DB model at all?

#

And rather remote databases

#

thanksf or the cookiecutter thing

quick cargo
#

Is Django still useful if I don't use their DB model at all?
And rather remote databases
Wdym by that

#

you can and often do use remote Dbs with Django or any website

#

but yes it is still useable

#

altho its setout to very heavily rely off its orm

native tide
#

guys when do yous suggest I start django

#

im currently taking the basics

kindred ether
#

I downloaded django cookiecutter, and damn it is messy af

#

Probably not what I want so I be ditching it

#

It's just too much bloat for my use-case

marble carbon
#

well you can remove stuff you don't use

sacred crest
#

Hi all, would someone help me with this please? I'm trying to make an API request with Postman toward Telegram so that it sends an inline keyboard to a chat (I provide the id), but the problem is, the keyboard consists of an array of buttons, I don't know how to put all that in a request? Should I add it as a JSON to the body of my POST request?

limber laurel
#

I am making a flask application, and I created seperate blueprints for commands and also one for injects, is that a good practice? As my other solution had all of these things be in the main application file

#

Also what is the difference between app_context_processor and context_processor?

terse surge
#

hello

#

i have an error

#

ive described it well there

marble carbon
sacred crest
#

Thanks, I am using this module right now

#

and I've shown the inline keyboard, but I don't know how to realize whether the one who tapped on the button tapped on the "correct" button or on the "wrong" button.

#

I have this code which is working fine:

#
context.bot.send_message(update.effective_chat.id, "Let's test an inline keyboard",
                                reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Correct", callback_data="confirm")],
                                [InlineKeyboardButton("Wrong", callback_data="reject")]]))
#

then I have CallbackQueryHandlers like this:```
CallbackQueryHandler(confirm_new_member, pattern="confirm")

#

(I'm not sure if it's the correct thing to use though...)

#

and then I attach this to the dispatch object, and let's say the function confirm_new_member is something as simple as this:```
def confirm_new_member(update, context: CallbackContext):
print(f"confirm {context.user_data}")

#

but it's only showing an empty dictionary whenever I tap on a button.

marble carbon
#

let me see

#

pattern argument isnt for that purpose

quartz delta
#

How to make a simple social media using py

marble carbon
#

you might do that using Flask or django

quartz delta
#

Can I DM you ?

marble carbon
#

just ask it here

#

@sacred crest

#

you would do something like
data = update.callback_query.data inside the callback query function and compare it to see whether it says correct or wrong

#

and remove the pattern argument for now, it doesn't serve you any purpose

sacred crest
#

Sorry for the delay. Thank you! I'll test it in a moment.

#

It's working

#

@marble carbon 🌮💓

marble carbon
#

Ay np

dark hare
#

@limber laurel you should be apply to supply a default value for all previous entries for a new column, its straight forward in django but not sure how you apply in flask. Something for you to look up 👍

#

or you can just let all rows be nullable which would be your best bet

#

imo

formal island
#

hey guys! Am looking for django + react pdf crash courses. Anyone can help me ?

#

If you have good courses you can share it with me thanks

marble carbon
#

pdf courses?

#

@formal island would a youtube playlist work?

formal island
#

Yeah but if you have a good and complet youtube playlist i'll take

marble carbon
#

okay hold on

formal island
#

Okay thank you

formal island
#

Okay i'll check

marble carbon
#

but I have seen other tutorials from this guy, and they seem to be great

limber laurel
#

@dark hare I found something called server_default it seems like it could do the job, but I dont hnderstand how to apply it from the documentation, a case of a non nullable column would be for example a profile picture, if there would be some kind of an icon there would at least be a default something, but if there is nothing then it cannoth show the image

dark hare
limber laurel
#

That tutorial doesnt cover such thing from what I can see

dark hare
#

ahh ok, i dont think i can offer much more help, other than to say would be best to search online for how to implement a default value for new db column using flask

#

theres also a default there specifically

limber laurel
#

Yeah, I just dont quite understand how the value definiton works or can I just do ,server_default=somevalue)

dark hare
#

looks like you can just do default=

#

A scalar, Python callable, or ColumnElement expression representing the default value for this column, which will be invoked upon insert if this column is otherwise not specified in the VALUES clause of the insert. This is a shortcut to using ColumnDefault as a positional argument; see that class for full detail on the structure of the argument.

Contrast this argument to Column.server_default which creates a default generator on the database side.
limber laurel
#

Nope, I did dedault, for new object without anything in that field, it worked, but for old ones it just had None

dark hare
#

what did you set default to though?

limber laurel
#

To No information

#

Just a string

#

And old objects returned None when querying that, but new ines with that field empty returned No information

dark hare
#

hmm, maybe check these docs and check your code and try again

#

if not might be something else going on

#

but i would be confused if docs were wrong if you're doing it correctly

limber laurel
#

Maybe I need to change something in my configuration settings, gonna look into that with a fresh mind tomorrow, and if that wont work out I guess stackiverflow it is.

#

Thank you anyways

bright badge
#

i'm being dumb

#

so the standard way of keeping passwords is a table in a database with salted hashes, right?

#

and somehow a static salt is bad practice?

#

how would you recalculate hashes when salt changes if you don't know the original pw and never actually keep it anywhere past the hash extraction process

dark hare
#

@limber laurel thats a good idea, and no problem. Good luck
@bright badge you shouldnt really be messing with passwords. There are plenty of frameworks and libraries that take care of it for you. I dont see why you would be accessing user pws

limber laurel
#

Werkzeug both can generate the password and compare password hashes.

late stone
#

anyone familiar with django

limber laurel
#

A small bit, but a very samll bit

native tide
#

Hey everyone

limber laurel
#

Hi

native tide
#

I have a question, I am using flask, HTML + CSS to create a website

#

but

#

The navbar won't appear

#

HEre is the code + the directory tree:

#

main.py: ```python
from flask import Flask, render_template

app = Flask(name)

@app.route("/home")
@app.route("/")
def home():
return render_template("home.html")

if name == "main":
app.run(debug=True)```

#

base.htmlpython <!DOCTYPE html> <html> <head> <title>{% block title %} {% endblock %}</title> <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css')}}"> </head> <body> {% block content %} <header id="main-header"> <div class="container"> <h1>Mathoid</h1> </div> </header> <nav id="navbar"> <div class="container"> <ul> <li><a href="#">Addition</a></li> <li><a href="#">Subtraction</a></li> <li><a href="#">Multiplication</a></li> <li><a href="#">Division</a></li> </ul> </div> </nav> {% endblock %} </body> </html>

#

home.html python {% extends 'base.html'%} {% block title %} Home Page {% endblock %} <header id="main-header"> <div class="container"> <h1>Mathoid</h1> </div> </header> <nav id="navbar"> <div class="container"> <ul> <li><a href="#">Addition</a></li> <li><a href="#">Subtraction</a></li> <li><a href="#">Multiplication</a></li> <li><a href="#">Division</a></li> </ul> </div> </nav> {% block content %} {% endblock %}

#

style.css: ```css
body{
background: #e9e9e9;
color: #fff;
line-height: 1.6em;
font-size: 16px;
margin: 0;
font-family: 'Times New Roman', Times, serif;
}

.container{
width: 80%;
margin: auto;
overflow: hidden;
}

#main-header{
background-color: #fff;
color: #333;
}

#navbar{
background-color: #fff;
color: #333;
}
#navbar ul{
padding: none;
list-style: none;
}

#navbar{
display: inline;
}

#navbar a{
color: #fff;
text-decoration: none;
font-size: 18px;
padding-right: 30px;
}```

#

so yeah

#

IT's having trouble displaying things

#

on the webpage

#

Can anyone help?

native root
#

Yes

#

I suppose it is doing exactly what you told it to do here

#

The mistake is how you're using blocks

#

In your base.html you have defined a block "content"

#

and filled it with your header and content

#

in your home.html you have inserted code outside the blocks

#

this code will not render correctly

#

you have also provided an empty override for the "content" block

#

this means the code in base.html no longer shows

#

therefore, no output

#

if you wish to override the content block, place your home.html override code inside the same-named block

wild thunder
#

guys, quick question, what's the equivalent of {{}} (jinja) for jquery?for showing values?

#

i have :

var number = 1;


#

i want to do like

{{number}} and it's rendered

short marsh
#

Guys, where didi you learn django or flask?

icy wasp
#

Guys, where didi you learn django or flask?
@short marsh University of YouTube. Professor Corey Schafer is a good start and Brian Yu for CS50 (produced in 2018). This info is pertinent to Flask. I have not yet learned Django.

#

If anyone can help me understand why I cannot override naming the table in Flask through the class, see #help-pie please. Thank you!

short marsh
#

@icy wasp ok i will try it thank you

icy wasp
wind walrus
#

For Flask backend
The front end dev basically works with the HTML folders inside templates and css/js files inside the static folder?
Who’s in charge of writing the {% %} in the HTML?
Sorry idk about web dev at all I just started learning about flask (on Corey Schafer)

native tide
#

What do you mean who's in charge of writing {%%} in html

#

You're in charge..that's a web template engine that works along with your backend variables.

wind walrus
#

So when the frontend guy is working on the HTML, the backend can work on the {%%} too? But simultaneous == merge conflicts?

native tide
#

usually the backend guy should do that, otherwise, if the variables are not passed as arguments in the render_template() function, jinja2 will raise some errors.

#

The front-end guy could mimic the effect of sth happening, for example, hardcode 3 elements instead of looping through the real data

#

and then the backend guy should come and replace those rows by saying sth like ```
{% for item in item_list %}
{{ item.name }}
{% endfor %}

wind walrus
#

Ohh okay

#

But we should never work on the same file simultaneously right

#

So backend should only replace the hardcoded elements once the frontend guy finishes and pushes to the remote

native tide
#

yeah, that's how I see it. There may well be other solns, but this is my opinion.

wind walrus
#

Okay, thank you for your time!

native tide
#

nw, good luck

#

How do i know how many requests are allowed to an api per time frame ?

#

2 requests per 2 seconds or 10 requests per 1 min like this

native tide
#

I know Jinja2 doesn't render JS variables; this is my case (where item.id doesn't work) ```
<a href="{{ url_for('portfolio.post', post_id=${item.id}) }}">

#

Solved it, quite awkwardly tbh, but this is how (for the curious) <a href="{{ url_for('portfolio.post', post_id='')}}${item.id}">

unkempt zephyr
#

hey, does anyone know how to get a low-latency webserver network worldwide?

#

for example, I want to host a site which can be accessed in China/USA etc with low latency, so it needs to mirror the site to multiple servers, are there any hosting solutions for that?

thorny scaffold
#

Hi guys. I am having trouble loading a static css file. There are 3 of them for 3 separate pages 2 of them are working fine (home and signup) but the one for the signin page is loading an empty css file (when I see it through chrome dev console it's empty). I am not getting any errors so I am clueless why its happening. I am attesting the screenshots of necessary items below:

lavish prismBOT
#

failmail :ok_hand: applied mute to @thorny scaffold until 2020-07-03 12:39 (9 minutes and 59 seconds) (reason: duplicates rule: sent 4 duplicated messages in 10s).

tacit grove
#

!unmute 293915781211750400

lavish prismBOT
#

failmail :ok_hand: pardoned infraction mute for @thorny scaffold.

thorny scaffold
#

I will rename those files

tacit grove
#

try not to upload them too quick as well

thorny scaffold
#

Oh okay

tacit grove
#

the best way would be to paste the code here:

#

!paste

lavish prismBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

tacit grove
#

that link ^

thorny scaffold
#

Okay will paste settings.py's static section and both html and css files

#
STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
    '/var/www/static/',
]
#
{% load static %}
<html>
<head>
    <meta meta name="viewport" content="width=device-width, user-scalable=no"/>
    <title>JAEA - Create a new account</title>
    <link rel="stylesheet" href="{% static "css/signup.css" %}">
</head>
<body>some stuff</body>
</html>
#

signup.html above

#
/* Montserrat google fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {}

.light {
    --background-color: #f1f1f1;
    --text-display1: #f1f1f1;
    --text-display2: #2a2a2a;
    --primary-color: #5229e4;
}

.dark {
    --background-color: #383838;
    --text-display1: #f1f1f1;
    --text-display2: #f1f1f1;
    --primary-color: #5229e4;
}

html, body {
    margin: 0 !important;
    padding: 0 !important;
}

body {
    background: var(--background-color);
    color: var(--primary-color);
    font-family: "Montserrat", sans-serif;
}

a:active {
    color: var(--primary-color);
    -webkit-tap-highlight-color: rgba(82, 41, 228, 0.2);
}

.nav-link {
    text-decoration: none;
    color: var(--primary-color);
}

.brand {
    text-align: center;
    font-size: calc(0.05 * 100vh);
}

.brand-logo {
    font-weight: 700;
}

.brand-text {
    font-size: calc(0.04 * 100vh);
    font-weight: 400;
}

.form {
    text-align: center;
}
#

signup.css

#
{% load static %}
<html>
<head>
    <meta meta name="viewport" content="width=device-width, user-scalable=no"/>
    <title>JAEA - Sign in</title>
    <link rel="stylesheet" href="{% static "css/signin.css" %}">
</head>
<body class="light">
some stuff
</body>
</html>
#

signin.html

#
/* Montserrat google fonts */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {}

.light {
    --background-color: #f1f1f1;
    --text-display1: #f1f1f1;
    --text-display2: #2a2a2a;
    --primary-color: #5229e4;
}

.dark {
    --background-color: #383838;
    --text-display1: #f1f1f1;
    --text-display2: #f1f1f1;
    --primary-color: #5229e4;
}

html, body {
    margin: 0 !important;
    padding: 0 !important;
}

body {
    background: var(--background-color);
    color: var(--primary-color);
    font-family: "Montserrat", sans-serif;
}

a:active {
    color: var(--primary-color);
    -webkit-tap-highlight-color: rgba(82, 41, 228, 0.2);
}

.nav-link {
    text-decoration: none;
    color: var(--primary-color);
}

.brand {
    text-align: center;
    font-size: calc(0.05 * 100vh);
}

.brand-logo {
    font-weight: 700;
}

.brand-text {
    font-size: calc(0.04 * 100vh);
    font-weight: 400;
}

.form {
    text-align: center;
}
#

signin.css

#

Okay I fixed it by opening the css file in a separate tab

#

Seems like a Chrome problem

rigid laurel
#

I haven't read your problem at all. But if you're newish to web dev, always consider that the problem might be caused by cacheing somewhere. Simplest is the browser cacheing files locally, and that can be fixed with ctrl+f5 or ctrl+shift+r

ruby fjord
#

do I always have to create a django app if I want to make a site?

#

I want my site to be a one page site btw

#

ah wait, can I just set the path to / to make my app the first page that's loaded?

quick cargo
#

if its a one page site why use django?

#

Django would be almost pointless to use for a single page

rigid laurel
#

Django's ORM is pretty nifty, if you want the ORM+Auth, then I'd say Django is worth it for one page

quick cargo
#

Django would end up being bigger than the page itself lol

rigid laurel
#

I don't really know what that means

cold anchor
#

it just has a lot of overhead for a single html page

ruby fjord
#

trying to learn django that's why Im using it

rigid laurel
#

Well, anything with auth+database is a lot of overhead for a single page

ruby fjord
#

plus I wouldnt use flask for a one page website that lets people post anonymous messages on the front page in a sticky note layout

#

django's orm is nice for all of that stuff

rigid laurel
#

Yeah, that seems like a solid use of Django

#

the ORM is very nice compared to SQLA

scarlet breach
#

hey how do i get my text over image? im using pycharm

wooden path
#

Does anyone know if there's a free way to host a website (that's not static) other than hosting it off my computer?

bleak bobcat
#

Most clouders offer a free tier or some initial credits, but that won't last forever

wooden path
#

Ah I see

#

I think i have some free google cloud credits, so I should be able to make that work temporarily

bleak bobcat
#

Yea

#

Just use the cheap options and it should last a while

wooden path
#

If it's relatively basic, do you reckon $50 of credit could last me a year?

#

I know that wasn't super descriptive

#

but all I want to do is have the user upload some images

glad topaz
#

who can help me understand some oauth2 sutff?

winged island
#

hi i have a general question about flask forms

#

is wtf still the widely accepted way to do forms in flask?

#

@glad topaz what specifically do you need help with?

dark hare
#

@wooden path you should take a look at AWS, depending on your needs you can pretty much serve your website for pennies

#

they offer micro EC2 servers for free, s3 buckets for free up to a certain gb

#

you should be able to work out what you need

wooden path
#

@dark hare thanks, will check it out!

crude swan
#

anyone here can help with a django-security problem?

#

or is there a better place to type?

dark hare
#

i do

native tide
#

im not sure if this is classed as web developement:
I want to access my Nitrado Account via aioHttp. As I add the basic auth it only responds with the home page. Nothing else

#

@native tide thats HTML talk

#

add padding to them

#

ok

dark hare
#

sounds like a css styling issue

#

rather than django

crude swan
#

josh do you know about django-secure settings?

#

hmm?

dark hare
#

what is your problem exactly?

crude swan
#

i've got a dynamicly generating settings file based on an environment variable that i can swap from debug to production

#

when i'm in debug i can use an <a download tag>

#

in prod it fails

#

the difference is in django security settings i have on the prod settings file

#

SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
SECURE_HSTS_SECONDS = 3600
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_BROWSER_XSS_FILTER = True
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_FRAME_DENY = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True

#

i put them on because a friend said he had them on his

#

(not great i know)

#

not sure which one is the cause though

dark hare
#

im confused as to what your exact problem is, how do you know this is a security problem? as you're telling me its a tag

crude swan
#

<a href"path to file" download> --> works without above settings, fails with them

dark hare
#

thats very very strange, are you hardcoding the path?

crude swan
#

no

dark hare
#

im assuming your looking in static files and you have set your STATIC_ROOT in your prod settings?

#

and STATIC_URL

crude swan
#

nah these are coming from media

#

and yeah media is working

dark hare
#

what is your path, and where is the file stored

crude swan
#

it all works without these specific settings like i say

dark hare
#

so firstly

#

i would question as to why you are using all of these extra security settings when u dont know what they are doing

crude swan
#

oh and debug = true

#

yeah valid question

#

just a recommendation from a friend who i'm trying to get in touch with to ask

dark hare
#

does it work with debug = false and without those extra settings?

crude swan
#

haven't tested that one

dark hare
#

try it

crude swan
#

will do

#

cheers

#

ah debug setting is the problem

#

hmmm

dark hare
#

hmm

#

very strange imo

#

hard for me to help debug further without the code

crude swan
#

no problem, cheers for your help

dark hare
#

i would say theres a difference between your local settings and production settings

#

but I couldnt go further than that without look myself

#

👍

crude swan
#

yeah i just turn debug to false on my local settings and get the failure so its that

#

at least have the right aim now

dark hare
#

think this will help

crude swan
#

ah perfect

#

will give it a go

#

thanks!

crude swan
#
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)```
#

i already had that at the bottom of my urls.py

#

which i believe is the equivalent

#

using something like nginx was always a potential but didn't think it was a necessity

crude swan
#

yeah many times

#

it's not working on local with debug false anyway

dark hare
#

if you're code is the same as what the django docs are showing im very confused

crude swan
#

i'll have a better look and come back to you if i get it

dark hare
#

whats in your allowed_hosts?

#

Setting up Django media files for development is about understanding what MEDIA_URL is and MEDIA_ROOT.

MEDIA_URL is simply a URL prefix (or "slug") that tells Django what the URL should look like when accessing media files from the MEDIA_ROOT.

For example, if you wanted your...

▶ Play video
#

think you might need to check your allowed hosts aswell

patent cairn
#

Hello, I am very new to the web, I have an error 404 when I do with the flask.

#

I don't know why it will shows 404 when do flask run, but I do with the http-server, it will link to the page

scarlet wind
#
Cart['bag'][name] = {data}
        if "Cart" in session:
                session["Cart"]['bag'][name] = {data}           
        else:
            session["Cart"] = Cart


        print(session)
#

whenever I have more than two items in session['cart'] only the first item saves, not the other items inside it

#

This is Flask btw

somber wedge
#

hello all

#

so my frontend dev is sending an image file in multipart/form-data. but there is some sort of fakepath error. I am using flask for the backend. Now I was simply using file.save(dest) to save the image file. But seems like his only options are sending the image file as a base64 or blob. I don't know how to handle those types of data. Can you help me?

#

the code works fine when tested from Postman/Insomnia. I'd assume the fakepath error is a brower security thing.

#
f = request.files['image']
fname = secure_filename(f.filename)
f.save(fname)
#

this was my code ^

fickle fox
#

Guys i have one question

#

how can i pass value of js variable to python variable?

rigid laurel
#

you can't really

#

it depends a lot on the technology you're using

#

but the closest thing to that, at a high level, is AJAX

fickle fox
#

i thought to make bl;ack jack game

#

and in flask to get how many rounds he won

#

what u think how that could be solved?

winged island
#

gonna ask again lol since i didn't get an answer before:
what's the best way to make a form in flask? is it still using wtf?

fickle fox
#

I am using flask form for login system

#

but for registrating i am using normal input field

winged island
#

wym flask form?

marble carbon
#

probably WTFforms

winged island
#

oh ok

#

thanks

native tide
#

@somber wedge

so my frontend dev is sending an image file in multipart/form-data. but there is some sort of fakepath error. I am using flask for the backend. Now I was simply using file.save(dest) to save the image file. But seems like his only options are sending the image file as a base64 or blob. I don't know how to handle those types of data. Can you help me?
@somber wedge we need more info

#

You can save/compress the images in the filesystem, store the path in a database.

ruby fjord
#

a lot of the questions here can be solved with django lol, but @fickle fox If I were you, I would code the form in html

#

maybe flask has a form module

fickle fox
#

um i use it sometimes

#

but idk django xD

#

wtforms for flask

quick cargo
#

Flask does have a form section, tho html forms isnt very hard todo

fickle fox
#

tho i am just thinking of nice project to do in flask

#

something that will be nice to put in repo on github

#

if anyone in here have idea ping me xD

keen lily
#

does anyone know what's one of the best django tutorials on udemy?

#

all the youtube tutorials really suck imo

quick cargo
#

tbh

#

only YT tutorial i would really recommend is Corey's Schafer
https://www.youtube.com/watch?v=UmljXZIypDc&list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p#]

In this Python Django Tutorial, we will be learning how to get started using the Django framework. We will install the necessary packages and get a basic application running in our browser. Let's get started...

The code for this series can be found at:
https://github.com/Core...

▶ Play video
#

as for Udemy courses im not sure

#

if you want more of a blog style one or one which isnt a video check out Django's own written tutorial which walks you through making your own polls app

keen lily
#

Thanks alot

prisma tree
#

Hey All,

I have a flask app that I am developing and want to incorporate a custom data structure for each user that is unique and will constantly change based on the routes that are accessed. Without being to vague lets say I want to create a shopping list, you can add items to the list and delete items from the list depending on the route selected. How do I declare the shopping list while also making it unique to every user. I hope this makes sense I am not a web dev person and this is for my capstone so any help would be greatly appreciated.

Thanks

scarlet breach
#

I had a doubt, can I make a semi-decent webpage in pycharm using the html script?

native tide
#

@prisma tree so you basically have some state for each customer, and you have a class that you want to instantiate separately for each customer with their state?

#

Using your shopping list as an example;

#

You can either have the html document have an empty shopping list, and a separate api that returns the contents of the list for a specific user - and using JavaScript in the webpage u query that api to fill the shopping list on the client side

#

Or you can have a template you fill out server side

nova escarp
#

I’ve been making a web app with django and I’ve come across a road block. How can I make it so each user I have see only what they add to the home page? Or give any user their own home page that they could add to and not change anything for any other user

#

For example, one user can add reservations to their reservation home page to display them. Is it possible for me to make it so another user can be logged in and add reservations and only see theirs that were added/have their own home page? Thanks!

wise flint
#

@nova escarp You need an ACL system to do it properly (Access Control List). Do some research on Django ACL and you'll find some good tutorials.

nova escarp
#

ACL is for access right? How would I make a different “homepage” for each user? If I’m understanding correctly I give them their own homepage and I’ve ACL to only allow them to use it?

prisma tree
#

thanks for the reply @native tide

hollow current
#

I wanna do the following, but don't know a way to go about it;

Have a pyqt5 GUI, with a web browser (with a local html file loaded). And I'd like a button on the webpage to call a python function, which will then update some content on the html page.

I'm using QWebEngine & PyQt5 by the way

#

Feel free to @ me

plain zealot
#

Anyone know a good resource where I can learn to webscrape dynamic websites like amazon?

native tide
#

I'm getting "TooManyRedirects: Exceeded 30 redirects." from requests. anybody know how to find out what it redirecting to?

bitter wigeon
#

hi everyone, im currently learning how to create rest api with django, and i want to store a list of items. For example:
i have Model called user, his attributes are name,age, height, weight, and so on...
for name i use CharField, for age i use IntegerField and so on. but i want to have an attribute with a list type, but there is no ListField or anything similiar. How should I do it? Sorry for bad English and thanks for the help!

quick cargo
bitter wigeon
quick cargo
#

It should automatically serialise any Orm objects from Django onto relevant data

#

as part of its Serialize Classes

scenic vapor
#

hey anyone know why my godady domain cant be connected to heroku?

cold anchor
#

are you paying for your heroku dyno?

scenic vapor
#

yes i am

#

@cold anchor

cold anchor
#

what specific issue are you having?

cold anchor
#

ah, that's why

scenic vapor
cold anchor
scenic vapor
#

write

#

so what should be the host name

cold anchor
#

you can use www if you want, but you need to tell heroku that's what it'll be

#

or you can change the hostname in godaddy to @ instead of www

scenic vapor
#

okay i've added a new domain on heroku with www in it

#

hmm okay

#

how would i go about that

#

on the dns settings

#

or just added both domains

#

mate

#

you're a champ

#

cheers

cold anchor
#

you can't have one domain redirect to another from just the domain settings, you have to control that either in your python app code or with something like nginx

#

cheers 🍻

#

eh, I'll say you usually can't do it from domain settings, some domain providers do offer that functionality

late stone
#

im very new to web dev so please be patient with me, thanks in advance

quick cargo
#

ah yes

late stone
#

it seems like its related to the Database

#

idk

quick cargo
#

This is Django's most infamous issue

#

I would help with it but when ever that happens i end up remaking the entire project because migrations and everything get thrown out of wack

late stone
#

its really frustrating; i might end up doing the same. ive been stuck the whole morning on this one

quick cargo
#

honestly its quicker to just back the code up

#

and remake the project

#

the error altho rare if you get it you will be there for ages trying to fix it

#

the ORM isnt exactly very 'forgiving' when something goes wrong

late stone
#

ill do that, thanks a lot 😄

#

update: fixed!!, my silly self forgot to make the migrations.

worn aurora
#

i need some help too

#

i cant get the image to positioned at right

#

anyone ?

woeful fable
#

Try

<img src="yourimage.test" alt="What is your image about" align="right">
#

In your html

worn aurora
#

ok

#

but that is float type correct ?

vale reef
#

Hello Guys,
Is there any way to get the response code from selenium or do i really need to first get website with Request and the load the page with Selenium, That just seems like a lot of request in a crawler...

Any advice? 🙂
Kind regards

worn aurora
#

i dont think u can

#

get the response code from selenium

vale reef
#

i dont think u can
@worn aurora I think there is a way that whould be better than using both Request and Selenium, i dont whant to break website 🙂

worn aurora
#

what would that be ??
u can try to analyse the rendered html

vale reef
#

@worn aurora

I dont now i just think that if take a website like Ahrefs, Semrush i really dont think they whould do it like this, but at the same time i really dont now 🙂

Do u know if there are any Python channels on discord about crawling?

worn aurora
#

first off this not the correct channel to ask the question

#

go to python help

marble carbon
#

update: fixed!!, my silly self forgot to make the migrations.
lol, that would've been my first guess

wraith vale
#

How to get visitor's public ip address in flask?

buoyant rapids
#

hey could somebody help me here i dont understand

#

I'm trying to redirect to /register html <p><a href="{% url 'register' %}">Register account here</a></p>

#

but Django says register is not a valid url or function when it is

#

I have py path('register/', views.register, name='register'), in my urlpatterns

nova storm
#

<a, where is '>'

buoyant rapids
#

what

#

<a href="{% url 'register' %}">?

nova storm
#

I think u should change the register name

#

To something else

dark hare
#

@late stone yo, do you have model called hr_department_hruser?

#

models are blueprints for database tables. If you have created a new model in the code you need to makemigrations and make sure you have migrated to the database

#

i.e. creating a hruser model and then migrating and creating a table in the database called the same

#

so when django tries to look for a hruser it will find the corresponding user in the database

buoyant rapids
#

@nova storm Nothing changed when I did that

nova storm
#

Then check ur URL

#

It's mainly happen when u enter on wrong URL

buoyant rapids
#

from all of the answers that i can see you reference the name path('register/', views.register, name='register') and that's what I'm doing and it cannot be found. Please correct me if thats not the correct way to do it

#

i am just confused

dark hare
#

have you done the official django poll tutorial?

buoyant rapids
#

yeah i did ages ago

#

ohh i got it

#

i just looked back at that and saw they used app:name

#

so i just used html <p><a href="{% url 'main:register' %}">Register account here</a></p>

dark hare
#

👍

late stone
#

thank you josh, i totally forgot about migrating once you create model or change anything on a model. I was able to fix it

unkempt snow
#

hi guys, can anyone help me with CORS problem :/?

#

from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

quiet solstice
#

Did you set the CORS header server side?

unkempt snow
#

Yep

#

its in AWS Lambda

#

and it's enabled, returned in the response headers

quiet solstice
#

Ah, I have no AWS experience.

unkempt snow
#

well it's a problem when making a request using AJAX

#

I'm trying to make the user make the request with 0 success

quiet solstice
#

Does the request look okay?

unkempt snow
#

If I do it manually in the browser

#

or in CURL

#

it works perfect and I get a response

quiet solstice
#

The error seems to be related to loading a page as file:///

#

And permissions being very strict in browsers for the local filesystem.

#

What is the value of your 'Access-Control-Allow-Origin' btw?

unkempt snow
#

'*'

#

eh, yeh I just added it to the server

#

getting a different error meh

#

has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

cold anchor
#

are you calling lambda functions straight from javascript?

spare siren
#

any clue as to why a gradient wouldnt be showing up in django? all of my other styling is working just fine but my background ( which is set as a gradient) isnt working. It worked before when it was just a plain html doc

cold anchor
#

can you show the css? what's the page look like instead? a single color? which browser?

spare siren
#

chrome, the page is instead just white

#
body{
    margin: 0;
    padding: 0;
    background: linear-gradient(90deg, rgba(131,58,180,1) 0%, rgba(253,29,29,1) 50%, rgba(252,176,69,1) 100%);
    background-size: cover;
    background-position: center;
    font-family: sans-serif;
}

.loginbox{
    width: 320px;
    height: 360px;
    background: #000;
    color: #fff;
    top: 50%;
    left: 50%;
    position: absolute;
    transform: translate(-50%,-50%);
    box-sizing: border-box;
    padding: 70px 30px;
}



h1{
    margin: 0;
    padding: 0 0 20px;
    text-align: center;
    font-size: 22px;
}

.loginbox p{
    margin: 0;
    padding: 0;
    font-weight: bold;
}

.loginbox input{
    width: 100%;
    margin-bottom: 20px;
}

.loginbox input[type="text"], input[type="password"]
{
    border: none;
    border-bottom: 1px solid #fff;
    background: transparent;
    outline: none;
    height: 40px;
    color: #fff;
    font-size: 16px;
}

.loginbox input[type="submit"]
{
    border: none;
    outline: none;
    height: 40px;
    background-image: linear-gradient(to right, #e52d27 0%, #b31217 51%, #e52d27 100%);
    color: #fff;
    font-size: 18px;
    border-radius: 20px;
}
.loginbox input[type="submit"]:hover
{
    cursor: pointer;
    background-position: right center;
    color: #000;
}
.loginbox a{
    text-decoration: none;
    font-size: 12px;
    line-height: 20px;
    color: darkgrey;
}

.loginbox a:hover
{
    color: #ffc107;
}
#

the gradient was moved

#

into the html just to check if it would work

cold anchor
#

does it?

spare siren
#

no

#

i added the gradient back to the css

#

its edited to reflect that

cold anchor
spare siren
#

no, the button gradient works just fine, but the background does not

#

but yes that is the gradient

#

i was expecting

cold anchor
#

can you inspect the page and confirm the CSS rule is loaded on the page and the selector for the rule is correctly selecting the background?

spare siren
#

im relatively new to web development as a whole, but i assume you mean whether it shows up in the chrome inspect?

cold anchor
#

yes, if you chrome inspect the "body" element, which CSS rules are being applied to it?

spare siren
cold anchor
#

ok, and is the body definitely the thing in the background? as in, there's no element with a white background covering the entire page (behind the login box)?

spare siren
#

no there isnt

cold anchor
#

if you "hover" over the body element does it display blue over the entire page? when you do absolute or fixed positioning, it doesn't change the size of the parent

#

although the "top nav" is technically a child of the body, it's outside of it

#

so its background wouldn't show up

spare siren
#

for some reason my body is 801px by 0 ?

cold anchor
#

ah, you positioned the children with absolute positioning so the body has no content it needs to widen itself to support

spare siren
#

im just confused as this worked before

cold anchor
#

add width: 100vw; to body styles

spare siren
cold anchor
spare siren
#

for some reason it seems the user agent stylesheet is blocking my bodies css

#

also, if i didnt say this before, it will show any other color i set it too, except for gradient

#

s

#

well whatever, ill just have it set as white, not like it looks particurlarly bad. Thanks for trying to help me.

cobalt oyster
#
Objective: You need to create Test cases for trasaction management module.     
1. Create Unit testcases
2. Integration testing for flow test for success and failed scenario. Assumption: Consider any Payment gateway like Razorpay or paytm and mock their responses for Success or failure. 
Deploy your project on Heroku and give the demo by running the test cases. Process:     1. Create app with name "payment" .     
2. Create model TxnDetail inside app payment     3. Create service file for accessing the Razorpay.```
Can someone help me by listening topics  that I should learn to do this assignment. I've never usesed any payments gateway
weary arrow
#

Flask/Jinja2: Is it a bad idea to pass functions to render_template as args? (return render_template('compare.html', func1=func1, func2=func2)
I find it's making my life easier when displaying data from many templates into one.
I do end up with some logic in the html files (to decide what pages get included via {% include %} which am trying to minimize.

quick cargo
#

yes in general it is

#

you should look at extend block rather than that method

weary arrow
#

ok, I'll try that and see if it makes more sense. The main issue I had that led me toward this path was the number of variables needed in my main 'meta' page to include and re-use tons of chart.js graphs that are defined separately in other templates.

cobalt oyster
#

Can anyone help me with the above project. I can't understand what I have to do.

upbeat flax
#

how can i show only some images in my database on a page and automatically create links for pages with their continuation so that i can navigate through them using buttons
using django
im pretty new to web dev so dont know what doing this is called
so heres a example of what i am trying to do
https://imgur.com/xw2B2cp

scarlet wind
#

@upbeat flax so you want to be able to make images buttons?

upbeat flax
#

no like i want to change the images shown when button is clicked

#

add that functionality

#

to button

#

like if my db has 100

#

i want to show 20 on different pages

#

and navigate using buttons

scarlet wind
#

you would want to want to use want to use jinja2, which I think might come with django, but not totally sure

#

it lets you write code on the webpage

#

python code

#

then you would want to use for loops

#

to iterate through a certain amount of images you want displayed

#

for example, if you have images stored in a dictionary you could do:

{% for key, value in images.items() %}
<img src="{{ value[imgSrc] }}">
{% endfor %}
upbeat flax
#

oh shit i get get it . all i needed was using loop for certain amount of them. thanks a lot

scarlet wind
#

your welcome, glad I could help :)

ruby fjord
#

Django doesnt use jinja2 but it has its own template engine

#

both are pretty similar and neat

scarlet wind
#

How do I connect my python backend web app to the user's session or local storage?

lunar pumice
#

Hey guys, i'm new to Django and figured out that Django has it's own default ORM (DjangoORM) for interacting with databases. Now, i was wondering if Django allows us to use an other python ORM library in it like SQLalchemy?

ruby fjord
#

why would you want to use sqlalchemy though, djangos orm is so much easier to use imo

lunar pumice
#

why would you want to use sqlalchemy though, djangos orm is so much easier to use imo
@ruby fjord Yes, i'm aware of that but i was wondering if there are any pros/cons of learning DjangoORM over SQLalchemy or any other ORM

#

Basically, i want to start learning ORMs with something that doesn't feel like 'cheating'

ruby fjord
#

well DjangoOrm is appropriate for Django, if you want to make desktop applications with pyqt5 or something, I would go for Sqlalchemy

#

they each have their use though

#

plus nowhere in the django docs do I see anything about sqlalchemy just use Djangoorm for django projects, its super easy to use

lunar pumice
#

they each have their use though
alright, i see it'd be better to just start with it already. Just needed a push in this direction. Also, i hope that it won't be that difficult to shift to working with some other ORM in future?

ruby fjord
#

documentations are friendly

#

figured out how to use django orm in less than 5 minutes

#

ended up making an app that calculates how long you've been in quarantine, with no prior django knowledge

#

and was able to implement a web feed in an hour

lunar pumice
#

hahah, interesting!

verbal wyvern
#

Is there a way to make the text from a python console appear on an html webpage? I need it to be able to support system clear if possible

#

im pretty new to coding

#

I guess what im really asking is can django/flask just substitute the console?

terse viper
#

that's a weird way of putting it, but yes

#

though with flask and related, you're not outputting to console any more, and the console is really only used as a way to look at some logs. everything is happening between the program and the connected HTTP connection (from the browser)

verbal wyvern
#

that could be better than i expected thanks

#

Which is better for a simple program and a beginner?

brittle plinth
#

Hello I am stuck hopefully someone can give direction. Has anyone encountered the error belos

NoReverseMatch at /edit/Apple
Reverse for 'edit' with arguments '('',)' not found. 1 pattern(s) tried: ['edit/(?P<title>[^/]+)$']
terse viper
#

Alchemist, Flask is good, it's nice and simple

hollow glacier
#

(Django)
What's the best name for the authentication app
right now I've named it authentication. But should I change it?

ruby fjord
#

name it something like NeedleAuth

#

If that's not already taken

ruby fjord
#

got pinged

#

whatsup?

brittle plinth
#

how would Initialize form fields with data from a text file'

fast charm
inland pecan
#

Hello Everybody

#

Very nice to meet you.

ripe imp
#

Hey guys
So I have a web server with multisites hosted using Apache virtualhosts
If you go to sub1.tld.com you go to /var/www/sub1 and so on

when I go to the public IP of my server, why am I being particularly redirected to sub7? Any way to change this?
Kindly @ping me if responding, I dont get notifs otherwise

ruby fjord
#

@fast charm you don't have to really modify the admin

#

but like, if you want to be able to change things posted by the user models, you need to add those models to the admin file

whole oracle
#

As a complete noob to both frameworks, could anyone tell me how long it would take me to build a habit tracking app from scratch using flask/django?

scarlet wind
#

for some reason I am having a lot of trouble when I try to store python dictionaries in flask session, for session storage, which is a dictionary itself. I can do;

session = {dict1: {dictA: {dict1: {data}}, dictB: {data}}
bleak bobcat
#

It depends @whole oracle
What knowledge do you have in python ? How fast do you learn ? Do you know how "the web" works ?

late gale
#

Has someone worked with pythonanywhere before ? can someone help me here everything works fine but localization not working on the server but it works on the local host when i try to change from english to arabic the text doesn't translate can someone please help me

scarlet wind
#

but when I store more than one dict in the 2nd dict1 like this:

session = {dict1: {dictA: {dict1: {data}, dict2: {data}}, dictB: {data}}

When I print session in that function or url, it prints both, dict1 and dict2 inside it, but when I switch to a different url or function it doesnt save

whole oracle
#

@bleak bobcat I have quite a bit of experience with webscraping (if that counts as knowing how the web works), and I'd say I'm an intermediate level in python in general

#

I learn pretty quickly as well

bleak bobcat
#

Then it shouldn't take very long, a few hours/days

wind walrus
#

Does os.chdir and url_for not work together?

#

In my views.py, I need to access CSV files stored inside my static folder but it doesn’t work

scarlet wind
#

How do I add data to clients web browser's local or session storage, I am using flask if that helps, but Flask session is having problems with dictionaries, so I need another way.

night stirrup
#

I need help with this. I am using the ObservableAnalyzer class at various places, and importing it from parent directory. It's the same error at all places in the code. Directory tree:

script_analyzers/
  - observable_analyzers/ - I have like 30 files inside  which imports the `ObservableAnalyzer` class
  - classes.py - contains `ObservableAnalyzer` class
#

and codefactor is giving me this error:

swift sky
#

i just found out pycharm doesn't support CSS unless you upgrade the IDE to a paid plan.

#

that seems ridiculous and can't be accurate

#

is this true?

plush garden
#

try vscode @swift sky

swift sky
#

so it is true then, what kind of garbage is that

rigid laurel
#

Pycharm is for editing python not html/css. Kind of in the name. I don't think it's unreasonable of jb to want to make money

odd oar
#

Its a community edition, people are allowed to make stuff themselves

barren phoenix
#

is anyone familiar enough with django that they could help me with one of my problems?

terse surge
#

i could try'

#

tell me the problem

#

and tag me

ashen sparrow
#

same^

ruby fjord
#

same^

odd oar
#

Maim^

wind walrus
#

I have a question about flask

#

I want to redirect from one view to another but I can’t just use redirect(url_for()) because I need to pass a variable from the first page into render_template() in the second page

native tide
#

@barren phoenix feel free to hit me up as well, python/Django is my day job

vague mango
#

@native tide I'm struggling with coming up with ways to optimize my querying in Django - do you have some time to look at the 6 lines of code I have?

native tide
#

sure, toss it my way and i'll take a peek here soon

vague mango
#
            serialized_last_object = FarmDataSerializer(last_object).data
            last_timestamp = datetime.datetime.strptime(serialized_last_object['timestamp'], '%Y-%m-%dT%H:%M:%S.%fZ')
            # last timestamp - 24 hours
            time_24_hours_ago = last_timestamp - datetime.timedelta(days=1)

            # query farm data for the last 24 hours for farm_device_id 01 - 16
            farm_device = FarmData.objects.filter(farm_device_id__gte = 1, farm_device_id__lte = 16, timestamp__gte = time_24_hours_ago).order_by('-timestamp')
            serialized_farm_data = FarmDataSerializer(farm_device, many=True).data
#

My code works however even after going through the queryset documentation I am not sure if my code is efficient. I am first getting the latest timestamp, finding the timestamp that is 24 hours before and running a new query. I am using postgresql for my DB and the data is being updated every minute. This function is called when the page refreshes. So Since the latest data uploaded is what I need, would there be improvements I can do to this code, as the database grows the runtime would also increase with my current code?

#

I'm currently in the general voice chat feel free to hop in @native tide

glass blaze
#

FarmData.objects.filter(...)[:2000]

native tide
#

just trying to get a little more clear about what you're looking for before i dive in, but

query farm data for the last 24 hours for farm_device_id 01 - 16

is this actually what you want? because the code is getting the farm data from 24 hours before the last timestamp for whichever single device ID had the latest timestamp (not necessarily 24 hours worth from any other ID afaik)

vague mango
#

yes @native tide

glass blaze
#

time(db_index=True)

native tide
#

you may be able to annotate the max timestamp, then use an F query

#

but honestly i think i'd probably have done basically what you're doing

#

i wouldn't think you'd need all of the intermediary serialization though

glass blaze
#

values("timestamp")

#

.values_list(flat=True, "timestamp")

#

[0]

native tide
#

also agree with chimp, would be good to use values/values_list, db index if this is gonna be pretty core or really slow otherwise

vague mango
#

Got it, @native tide thank you so much

native tide
#

np!

dark agate
#

Hello, it's better to start with Flask than Django as a Python beginner?

terse viper
#

yes, Flask is a smaller library and relatively simple to work with

dark agate
#

thank you ;)

safe glen
#

anybody getting this error of "import error: cannot import 'secure_filename' from 'werkzeug' while using flask_uploads??

native tide
#

No

#

import it from werkzeug.utils import secure_filename

safe glen
#

@native tide yeah i did that but still had the issue

#

but no worries i already solved the issue. the bug was related to the current version of Werkzeug . so i downgrade to the prev version now everything is working 💥

fast sundial
native tide
#

@safe glen glad to hear that 😄

warped falcon
#

In multi-table inheritance, why the child class doesn't inherit Meta class from its parent Meta class?

native tide
#

How do you send multiple files using xhr/ajax and receive them as Image objects lets say in python?

native tide
#

Is Django related code questions ok to ask here?

bleak bobcat
native tide
#

Did not see that. Thanks.

#

I'm not able to display the profile picture of my users. I have followed the Django docs

#

In the project folder under settings.py I have

MEDIA_URL = "/media/"```

and in the urls.py 

```from django.conf.urls.static import static
from users import views as user_views

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)```
#

Not getting any errors when running the enviroment so i don't get the problem

bleak bobcat
#

What do you get when you inspect that image src ?

native tide
#

Unknown source

#

<img class="rounded-circle account-img" src="{{user.profile.img.url}}">

#

But src will show as unknown in chrome

bleak bobcat
#

And what's your model ?

native tide
#
from django.contrib.auth.models import User


class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    image = models.ImageField(default="default.jpg", upload_to="profile_pics")

    def __str__(self):
        return f"{self.user.username} Profile"
#

So if user doesn't upload his image of choice, it will resort to the default.jpg image

native tide
#

Any here have experience with fastapi? I'm looking to return multiple data obtained from another source within a JSON format. Am I better off creating a json object with the keys needed, populating within a for loop and returning this? Or is there a better way within fastapi? Example of how I want this structured when its returned:

  "users": [
    {
      "id": 1,
      "first_name": "Robert",
    },
    {
      "id": 2,
      "first_name": "Lucy",
    }
  ]
}```
zealous siren
#

So for loop it

#

Don’t put too much thought into it, application will spend more time in database then building.

fickle basin
#

Hello community , anyone got an error with email validation with flask > when I use an email with a dot “test.first@exemple.com” the registration form doesn’t work as it says to that it’s not a valid email ?

rigid laurel
#

Flask email is very janky. The most popular package for it hasn't been updated in a long time

quick cargo
#

best system is make a custom form in html with a regex expression to check

rigid laurel
#

Oh. I'm completely misunderstanding. I thought it was about email verification

ruby fjord
#

django forms tho

terse viper
#

there's a "standard" regex expression out there that checks for email format

fickle basin
#

Okey I ll check tonight

terse viper
#

although the Python one in there is the simplified one, it'll probably work for what you need, though the more complex one is more accurate, I'm not 100% sure it's formatted correctly for python. feel free to try it

#

this one:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

versus this one

^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$

one of the two probably

twilit zenith
#

hey is someone is familiar with Django signals, can you explain why do we need it at all?

bleak bobcat
#

You don't need it. In most common websites you're not gonna use them

fickle basin
#

@twilit zenith if it’s when you are creating a profile or notifying a set of receivers then think about it as a trigger

twilit zenith
#

im using Django rest framework and Vue JS cli

#

I learned how to create API and stuff but I'm a bit confused cuz some people used signals

#

some are using rest_framework router

#

idk what to do gotta do more research I suppose

#

I think router isn't needed, but I'll most likely use signals for post notifications

#

I can use Vue router plugin anyways

dapper tusk
#

can I simply run a django2 (not async) style app from the asgi entry point

faint abyss
#

Heya!
If I create a ForeignKey field in my model that points to the user(s) table, and I get every value from this model and render it with a html, what is the default value that I get if I try to access model.user, and why?
Oh, yes that's django.

odd swallow
#

hi guys a beginer question for my first fullstack app. Not sure if using express vs flask is better for a multipage app. The main drawback I see in flask is it's not asynchronous. So would that mean express is better?

terse viper
#

a little hard to compare. use whichever you are more comfortable with - python or javascript

vague apex
#

anyone have a tutorial on how to setup a venv for Django

#

I've been trying to do it for hours and I still somehow haven't done it lol

native tide
#

alright

#

im here

ruby fjord
#

you need to use <a href="The link for the video">https://roblox.com</a>

native tide
#

I do but if I copy the link and then paste it here, it shows the actual link

ruby fjord
#

when you copy the link of course it will post it as the youtube link on discord, because you're copying the source

native tide
#

oh

#

so how do I not copy the source?

ruby fjord
#

you can't

native tide
#

@ruby fjord

ruby fjord
#
ROBLOX

Roblox is ushering in the next generation of entertainment. Imagine, create, and play together with millions of players across an infinite variety of immersive, user-generated 3D worlds.

native tide
#

alright

#

<!DOCTYPE html>
<html>
<body>

<h1>The a href attribute</h1>
<a href="https://www.roblox.com/ ">https://youtube.com/</a>

</body>
</html>

ROBLOX

Roblox is ushering in the next generation of entertainment. Imagine, create, and play together with millions of players across an infinite variety of immersive, user-generated 3D worlds.

#

thats my current code

#

what do I do/

#

😓

ruby fjord
#

¯_(ツ)_/¯

#

scrap the relative url

native tide
#

relative path

#

relative path

#

uhhh

#

that?

#

@ruby fjord

ruby fjord
#

like, remove it I guess

#

I don't know what you want to do now

native tide
#

?

#

<!DOCTYPE html>
<html>
<body>

<h1>The a href attribute</h1>
<a href="https://www.roblox.com/ ">https://youtube.com/</a>

</body>
</html>

ROBLOX

Roblox is ushering in the next generation of entertainment. Imagine, create, and play together with millions of players across an infinite variety of immersive, user-generated 3D worlds.

#

so will that work?

ruby fjord
#

not for what you want to do