#web-development

2 messages · Page 130 of 1

native tide
#

I doubt you can re-create that speed with flask

quick cargo
#

i Mean you sorta can

#

Flask's eco system is vast enough to provide it

blazing jetty
#

@left kraken did some debugging

#

I can't execute it in the directory, but if I move the file somewhere else it works

#

no idea what could cause it

left kraken
#

You can use blueprints to speed up devel of a app, also equip yourself with extra schema validator

blazing jetty
#

XSD

#

and it interfered for some reason

left kraken
limber laurel
#

If I do this, the code works, if I make it so the interpreter doesnt shit itself it doesnt

#

oh, I had to mark the directory as source

#

cuz in django it creates a project in the project

#

and uses the second project file as the source file

teal rapids
#

Hello again, is there a way to show a pdf inline response inside an html template? Like inside a <div>

brisk spear
#

Hey

#

Does anyone know flask?

copper lagoon
#

ye hi

brisk spear
#

Bro u know flask?

copper lagoon
#

yes?

brisk spear
#

What things we should cover using flask?

#

Is JS highly required or little bit is okay for web development?

normal blade
#

hey guys, so I made a chatbot using tensorflow and tflearn in python.. it works but as a stand alone app. i wanted to make a django website and add the chatbot in it... could someone please list resources i can look at (it’s my first time doing this and I don’t know what to even search for)

#

p.s. I know django.. I just wanna know how to integrate the chatbot into the website

quick cargo
#

JS is useful to know if you wanna do certain interactions

#

but overall no its not massively needed

limber laurel
#

Could someone help me with me not being able to find my html template?

topaz widget
#

Probably more of a JS question, but here goes: does anyone know the best way to handle the soft keyboard on Android? The resize event triggered by focusing on input elements is messing up my contact form layout. The method of seeing if only the height changes I've seen on some blogs does not seem like a tenable solution. Any help is appreciated. Thanks in advance.

topaz widget
#

You can build a website without any JavaScript, but almost all modern web UIs use some JavaScript.

brisk spear
#

Ok

rustic pebble
#

Does anyone know how I can set environmental variables in nginx, the default export NAME=VALUE in Linux does not seem to be working and I am having an issue with flask as it is not reading them

topaz widget
# topaz widget Probably more of a JS question, but here goes: does anyone know the best way to...

For anyone curious, I figured out how to deal with the soft keyboard deployment on Android, which seems to work fine. Here is the code (JavaScript):

// Function to determine whether soft keyboard has been deployed
function isSoftKeyboardResize() {
    // Only applicable to touchscreen devices
    if ( 'ontouchstart' in document.documentElement ) {
        if ( window.innerHeight < preResizeWindowHeight && window.innerWidth == preResizeWindowWidth ) {
            isSoftKeyboard = true;
            return true;
        }
        else if ( window.innerHeight > preResizeWindowHeight && window.innerWidth == preResizeWindowWidth ) {
            isSoftKeyboard = false;
            return true;
        }
    }
    // Return false if not a touchscreen device or orientation change
    return false;
}
// Change formatting if soft keyboard resize
function softKeyboardReformat() {
    if ( isSoftKeyboard ) {
        body.style.height = preResizeWindowHeight + 'px';
    }
    else {
        body.style.height = null;
    }
}
// Functions to run on resize of window
window.addEventListener('resize', () => {
    if ( !isSoftKeyboardResize() ) {
        // Resize functions to run under normal resize circumstances
    }
    else {
        softKeyboardReformat();
    }
    preResizeWindowHeight = window.innerHeight;
    preResizeWindowWidth = window.innerWidth;
});
dapper obsidian
#

I imported pillow (PIL), but when I do “from PIL import image”, it doesn’t work, there is an error, why!

topaz widget
#

Does anyone know why transitioning position (left, top, etc... ) and transform for absolutely positioned elements in Safari might be proving to be such a problem for me? I have an animation which works very smoothly on everything but all iOS browsers and Safari on MacOS (Chrome on MacOS seems to work fine).

drifting anvil
#

What is the python3 equivalent of PHP's json_decode ?

topaz widget
drifting anvil
#

@topaz widget @native tide Thank you both.

topaz widget
#

Web pages are files.

#

But a functioning web page usually utilizes multiple files to run.

wicked elbow
#

How do you query from id > 1 and id < 10 for instance in django

trim gyro
#

Model.objects.filter(pk__in=[2..9])

spring wadi
#

may be alternate attribute and height and width of n image

violet zealot
#
#   importing necessary module
from flask import Flask
from flask import render_template
from flask import url_for

#   pass the webapp throug "app" variable
app = Flask(__name__)

#   default route
@app.route('/')
def index():
    return render_template('index.html')

if __name__ == "__main__":
    app.run(deubg=True)

I am trying to run this flask app but this error appear
flask.cli.NoAppException: Could not import "app".

frank shell
#

@violet zealot can you copy the full traceback in here? Not just the last line

violet zealot
#

alright @frank shell

#

@frank shell

frank shell
violet zealot
#

ow thanks man

#

i set set FLASK_APP=app.py

#

that's a silly mistake 😄

shy willow
#

how can I iterate through all django objects and change a value for them?

opaque vigil
#

I need help with React.

I have this component called ListGyms that renders two child components (one each time depending on the state). This component routes to the main react page, and stays rendered regardless if the child components (either of them), gets rendered.

These 2 components are rendered from a click on a button that is a part of a ListGyms component. Now, what I need to do is pass id as prop to these 2 components, because I need it to render some data from the backend. I am not exactly sure how to accomplish my task.

I am using react-router-dom for routing.

Here is github gist that shows you the code for all my components.

https://gist.github.com/eonbre/10a6932a5fe471cb1d7c4398a1ef9b8b

Thank you in advance for any help or guidance.

native tide
brisk spear
#

Which is best database to be used as a beginner in python?

stray quiver
#

sqlite

brisk spear
#

Bro can we use sqlite in flask

real hare
brisk spear
#

Ok

#

How can we do that

#

I was wondering how it can be done?

#

I was actually learning flask and in that got a thing called sqlalchemy which is used as a database

#

I couldn't understand and just messed it

alpine lintel
#

a small question from noob. why i need this dot before models when registering model in django?

wheat sorrel
#

Hi guys I'm hoping to start a new project soon which i will admit now is quite ambitious, i am planning to try and use chat logs combined with a machine learning algorithm to create a chatbot which will be able to sustain as good a conversation as I can get it to do. I want to use real chat so it learns true responses to questions. But i'm not sure if i should make it so right now it can only answers questions on one topic, like a specialist on python and i wondered if anyone had any experience and could offer me some advise on what's best to do as well as if anyone was able to give me some clips of chats i could use for this project? Thanks in advance guys!! 😁

real hare
#

Hey guys, I'm unable to use my db on my Django project...

django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'cpc76456-belc9-2-0-cust5.2-1.cable.virginm.net' (using password: YES)")

I'm seeing this here when trying to launch the app, I can log into the DB, I'm connected to it using mysqlworkbench

native tide
real hare
#

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'GorillaFitness',
        'USER': 'root',
        'PASSWORD': 'mypass',
        'HOST': 'dbendpoint.blah',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"
        }

    }
}

I've specified the db properly on my settings file as well, omitted the sensitive information

native tide
# brisk spear Which is best database to be used as a beginner in python?

The actual database doesn't really matter, if you are using python you are most likely communicating SQL within a pythonic way, via an ORM. If you are using Flask, use Flask-SQLAlchemy if you are using Django it has its own inbuilt ORM. These ORMs are used irrespective of the database (sqlite, postgres, etc.)

visual oracle
#

Hello. I use flask framework and I have one small issue. CSS does not update properties of input, but p works just fine.

Here is code as an example.

p{
color: red;
}

input#sbar{
border: 4px solid black;
}
real hare
#

change it to #sbar

visual oracle
#

I tried that. Did not work.

real hare
#

is it an id or class assigned to the html field?

visual oracle
#

ID.

#

It's like black magic to me. I tried without flask framework and it worked without any problem.

real hare
#

I dunno if you specify the colour in the border

visual oracle
#

I mean you can since it is working outside of flask.

pallid idol
#

guys, how can i get json info to send with request.post? for example i need to log in insiede a website, how can i get the json (payload) to send?

Any advice?

real hare
#

I meant in Flask, it seems it's expecting differing syntax

#

shouldn't be though, I tested that quickly, and it does indeed work in that manner

#

Try using the dev tools on your browser

visual oracle
#

Yeah it works in dev tools.

#

It's like completely ignoring what I have inside the css #sbar.

west wren
#

I'm using Flask-Migrate to check for differences in my code. However, Alembic doesn't seem to detect anything after running python3 manage.py db upgrade after the following change is made:

username = db.Column(db.String())

⬇️

username = db.Column(db.String(), unique=True)

How can I get it to recognize a table with an updated column like this?
Thanks in advance!

native tide
visual oracle
#

Ok. I have found the problem. It's something to do with the browser cache. As soon as I deleted browser cache CSS started to work. I just hope that I don't have to do this every time I make changes.

visual oracle
real hare
#

ahh control shift r every so oftne caching can an annoyance

west wren
#

you can open the devtools and disable cache

visual oracle
#

Epic. Will try that.

#

I think that works. Thanks.

whole sierra
#

Quick question to anyone that has deployed a django server

#

I have variables, code and other scripts that execute when the website runs as well as things outside of "views"

#

will this not work properly if i were to deploy?

#

like if two people were trying to run the same script?

#

are all actions, scripts and data suppose to be initiated through post/get requests?

arctic thicket
#

Hii I have configured the django, gunicorn and nginx with the following tutorial of digital ocean using ubuntu os on digital ocean droplet. gunicorn and nginx both configuration are perfect but cant able to access the site on domain ip. Help is appreciated. https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

DigitalOcean

Django is a powerful web framework that can help you get your Python application or website off the ground. Django includes a simplified development server for testing your code locally, but for anything even slightly production related, a more secure

cunning jetty
#

Hey, this is related to my python project I am making: Does anyone know how to edit a json file within javascript not using the require function?

keen hatch
#

hey guys, I want to make a screen for my webpage that will show when the download is going on, can anybody help?

surreal horizon
#

Is there a way I can host my own flask website with a custom domain custom.com and a secure https:// and all that good stuff a normal website should have? I know I will have to pay for hosting and domain and more, but is there a way to do this?

brisk spear
#

Thnks @native tide

#

Why don't u use a local host

#

But it won't provide https: type thing

#

Use xampp which provides sql database and allows hosting websites

#

Check out on google

#

@surreal horizon

wicked flume
#

hello

#

does anyone know how to add a page on wordpress where people can leave messages

#

with the free version

#

i dont know if this is the right channel to ask but I would aprreciate the help

native tide
#

does anyone know how to make point and vector classes

surreal horizon
real hare
#

I'm unable to connect to my mySQL db on AWS on my Django site, but I get this error:


django.db.utils.OperationalError: (1045, "Access denied for user 'root'@'redacted info' (using password: YES)")

#

I can access this DB using MySQLWorkBench with no issues whatsoever

chilly remnant
#
~/dev/sdasys
├── instance
│   ├── dev.sqlite
│   └── prod.sqlite
├── LICENSE
├── Pipfile
├── Pipfile.lock
└── sdasysapp
    ├── app.py
    └── __init__.py

~/dev/sdasys$ flask run
<< flask.cli.NoAppException: Could not import "sdasysapp". >>
#

wh

#

y

#
__init__.py:

def create_app():
    app = Flask(__name__)

    return app
#

sry for the cryptic "why" but i think the other things speak for themselves

#

i have a factory function where its supposed to be, im in the right directory to run flask run, FLASK_APP is set to sdasysapp as it should, what am i doing wrong?

glass orchid
#

Hi Guys, good evening

peak meteor
#

Anyone knows how to load in .html files as a subpage?

#

Im using this for main page:

import http.server
import socketserver

class MyHttpRequestHandler(http.server.SimpleHTTPRequestHandler):
    def do_GET(self):
        if self.path == '/':
            self.path = '/index.html'
        return http.server.SimpleHTTPRequestHandler.do_GET(self)

handler_object = MyHttpRequestHandler

PORT = ***
my_server = socketserver.TCPServer(("", PORT), handler_object)

my_server.serve_forever()
glass orchid
#

Hi on Django project i've declare class from Generic.View and into my class I declare : uccess_url = reverse_lazy(home). home is a view in the same file view.py but it's not a class it's a def and juste return render : return render(request, 'planner/home.html') So that its ok it's working. but i don't need to return home page I need to return a List Page. My List page in view.py is not a def but is a class -> class ListPlanification(ListView): and if I write in ma first class view uccess_url = reverse_lazy(ListPlanification) don't working and return an error NoReverseMatch.

#

Someoen can give me track or idea for solve this issue ?

#

thx a lot per advance 😉

steep compass
#

Hello. I was wondering if there's a popular web dev stack that uses Flask, or what technologies can I combine Flask with

timid sigil
#

Hi everyone I'm deploying a Django Blog App on heroku, when I have the settings file with DEDUG = True all seems to work properly but when I turn it to DEBUG = True I get a SE

#

SERVER ERROR 500

timid sigil
#

I think that the error could have something related to media files, but I set the app to point the media files in a cloudinary account

vestal hound
#

can't tell what's wrong without logs

timid sigil
#

Give me a minute

#
2021-01-30T00:11:15.000000+00:00 app[api]: Build succeeded
2021-01-30T00:11:32.906071+00:00 app[web.1]: 10.41.153.135 - - [30/Jan/2021:00:11:32 +0000] "GET /blog/ HTTP/1.1" 500 145 "https://developerroad.herokuapp.com/projects/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
2021-01-30T00:11:32.906703+00:00 heroku[router]: at=info method=GET path="/blog/" host=developerroad.herokuapp.com request_id=289a75cc-8c81-4b15-b5b0-31046c58a7df fwd="181.53.13.106" dyno=web.1 connect=1ms service=602ms status=500 bytes=410 protocol=https
2021-01-30T00:11:33.549479+00:00 app[web.1]: 10.41.153.135 - - [30/Jan/2021:00:11:33 +0000] "GET /favicon.ico HTTP/1.1" 500 145 "https://developerroad.herokuapp.com/blog/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36"
2021-01-30T00:11:33.550239+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=developerroad.herokuapp.com request_id=dd5d5227-15e8-4398-abd2-65a741b862e5 fwd="181.53.13.106" dyno=web.1 connect=1ms service=28ms status=500 bytes=396 protocol=https

#

Here is the log of heroku

trim star
#

What free tool do people use to manage their python dependency vulnerabilities for their project? I already looked into Snyk

wheat olive
real hare
real hare
#

I've a flask app, and I have a template thrown together; can it be exported to a pure html file? I require to attach this html file as part of my application Is this possible?

rotund token
#

Does anyone want a FREE Portfolio made for them, as i am really bored atm

near bison
#

When Django Documents (like css/js) are sent to browser from the server , are they gzipped automatically ?

#

DO we have to setup a cache policy for the static files we are sending from the server side or is that done automatically
/

glad patrol
#

@rotund token DM

past cipher
#

what's the correct way to log errors? I have a big app, and everything works, but of course stuff could break in the future. I have a lot of eventhandlers if it unexpectedly returns any 404, 500 etc. The only way I can fix is wrapping everything in try:except

#

anyone know another way ?

native tide
#

what is the difference between django and flask?

solar spire
#

Hi, I need help with Flask-WTF. Specifically with special character escaping.
I as understand flask_wtf escapes all special charachters by default, but when I type special characters i my field and try to access them in my view it gives me unescaped data.
For example field:

class Form(FlaskForm):
    title = StringField('Task', validators=[Required()])

then later when I enter value <script>malicious code</script> in html form and send it, I call

form = Form()
print(form.title.data)

and get the same unescaped value
<script>malicious code</script>
but what interesting is when I just print field itself it shows that value attribute is properly escaped

print(form.title)

gives me

<input id="title" name="title" required type="text" value="&lt;script&gt;some&lt;/script&gt;">

how can I get escaped data?

brisk spear
#

Bro refer documentation of flask

#

It will be much helpful

#

@rotund token how to make a bot using python?

#

Using ML/AI or something else

solar spire
#

@brisk spear Are you answering to my question or the one above?

plush kernel
#

Is there anyone knows if there's a request.form.getlist() or equal method in Quart?

weak mesa
#

Hello ! Question : I have 2 classes in my django.models : Products and Clients, I have my views and forms all set to add/edit/delete my entries. When I create a new client, I am able to SelectMultiple products ordered by him (M2M Field in Clients), however, I would like to do the same when I create a new product item, I would like to choose which client can order it via SelectMultiple as well. I am not sure how to call two Models in my views/forms, anyone?

native tide
plucky edge
#

Hello, I need help with Scrapy, I want to explain my problem via Video and screen sharing. Is anyone here can help me by any chance ? thanks in advance

silk brook
#

Hey so I don't know if this goes in #web-development , but ;-;. So basically, is there a way to tell how many users are returning to your website using Cloudflare analytics? Because I only see Unique Visitors but not Returning Visitors in the Overview tab. Thank you in advance!

brisk spear
#

@solar spire I was giving up a suggestion so that something can work out

#

To your problem

glass badger
#

Do you store Refresh Tokens in the clients browser?

mortal raven
#

I would like a couple people advice me in the following: I'm thinking in starting a new business and I need a e-commerce website, I have two options in mind: first keep it simple and use shopify and second: create the website myself cloning a actual system that works and making some modifications if needed according to the business.

mint folio
strong flint
steady owl
#

yo

#
<section class="home" style = "background: url({{ url_for('static', filename='/Thank You/{% background %}.png') }});">
#

will something like this work?

#

flask btw

shut flax
#

can someone tell me why my fixed header is making my page unscrollable

glass orchid
shut flax
#

what

#

oh my fucking god im going to kill myself

#

youre right

#

jesus christ

#

thanks

steady owl
#

nvm ill just use php

#

🙂

glass orchid
#

i don't know the word in english sorry but what i means it was : your html basile which fix the header is only inside the header and not into the body too

shut flax
#

at some point i changed my header from div to header tag but i didnt change the closing tag

#

thats why it broke

glass orchid
#

ok so the good word will be tag, cool i know a new translation word 😉 and happy to help you

swift sky
#

how would you handle this situation

#

the user receives an email daily with updates about random work responsibilities

#

currently that data is being copy and pasted into a text area field in a form, and being stored in the db

#

and when rendered in the html its not keeping the format

#

it returns the data as just one large block of text

past cipher
#

or just regular text

swift sky
#

im trying to make it so that the data is returned with font size and and whitespace

swift sky
past cipher
#

what do you mean by not keeping its format?

#

got an example?

#

font-size is done via css

#

maybe try variable|safe

#

if whitespace isn't being kept

#

try printing the variable in the back-end and see if it keeps the whitespace

swift sky
#

one sec

swift sky
swift sky
past cipher
#

insert it as HTML into the database if you want to have headers etc

swift sky
#

and will the db actually store the html by default?

past cipher
#

no

#

you have to send the html to the db

#

if its a basic textarea, its not gonna be html by default

dusty belfry
#

is flaskwebgui the best/easiest way for a simple UI to call my script ?

past cipher
#

maybe use a WYSIWYG editor

swift sky
#

but this editor

#

how would that work

past cipher
#

it replaces the text editor with its own text editor, and it retuns pure HTML that you can store in the db

#

checkout tinymce

swift sky
#

so the idea is the user uses this editor to write some stuff, and when they click update post it gets submitted to the db as html

past cipher
#

yeah i think its best you use an editor like one above

#

I pushed my repo to github when i created mine, lemme try find for you

swift sky
#

you made your own editor?

past cipher
#

no, I used tinymce

#

basically you want to include the tinymce cdn
init tinemce
when the user clicks submit, grab the content of tinymce and assign the value to a hidden input field
in the backend get the value of input field
insert into database

swift sky
#

im looking at your stuff now

#

and tinymce

#

uhhh

#

i dont use any of those webframeworks

#

how do you init tinemce

past cipher
#

look at the github.

#

its at the bottom

swift sky
#

yeah i saw thanks, just embedding it now into my app

#

@past cipher is this free?

past cipher
#

yah its the community edition

swift sky
#

having some issues embedding into my current html file

past cipher
#

what issue ?

#

just copy paste the code inside your script tag

#

and then change ID of your textarea

swift sky
#

i was embedding it incorrectly because there was html already present

#

expose api key though?

#

what is all this in your github

#
          selector: 'textarea',
          block_formats: 'Paragraph=p; Header 1=h1; Header 2=h2; Header 3=h3',
          plugins: 'advlist autolink lists link image charmap print preview hr anchor pagebreak codesample code spellchecker code',
          toolbar_mode: 'floating',
          codesample_languages: [
            {text: 'HTML/XML', value: 'markup'},
            {text: 'JavaScript', value: 'javascript'},
            {text: 'CSS', value: 'css'},
            {text: 'PHP', value: 'php'},
            {text: 'Ruby', value: 'ruby'},
            {text: 'Python', value: 'python'},
            {text: 'Java', value: 'java'},
            {text: 'C', value: 'c'},
            {text: 'C#', value: 'csharp'},
            {text: 'C++', value: 'cpp'}
        ],
          toolbar: 'advlist codesample autolink lists link image charmap hr anchor preview pagebreak h1 h2 h3 p a code spellchecker blockquote'
       });```
past cipher
#

its a free api key anyway, so doesn't matter

#

and plugins I need for my code editor

mint palm
#

can anyone recommend me where to learn django?

#

for free*

swift sky
#

@mint palm youtube and documentation. Corey schafer has a good series

mint palm
#

Ooh thnx, does he cover the entire topic?

shell hollow
#

hi guys, sorry i'm trying to search from older message about this issue but i cant understand the answer.
i'm trying to run django-admin runserver and got this error msg:
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

#

I already had this in manage.py:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mySite.settings')

#

am I doin it right?
however if running using python manage.py runserver its working.
i'm just curious why django-admin not working.

toxic flame
#

Is it possible for django to set for example:

127.0.0.1:8000/example

To normal html without using any of the django properties?

twilit needle
toxic flame
#

Seo wise everything is client side rendered

twilit needle
#

no I didnt mean that django cannot render

#

you dont have the tools to do AJAX and stuff

#

thats the catch
browsers cannot run python

toxic flame
#

For SEO django is not the best choice imo

#

Because it loads and creates the HTML when is requested

#

so my solution is put everything Django on a subdirectory

twilit needle
#

? I didnt get you

brisk spear
#

Hey all

#

I have a doubt whether should we install flask again while creating a new project again ?

#

Also suppose I am using python3 so what happen if I install virtualenv? Will it work properly?

brisk spear
zenith flume
brisk spear
#

Bro are u beginner

zenith flume
#

in what

brisk spear
#

In html and python

zenith flume
#

well i have been coding python for 5 months now but in html and flask only a month now

brisk spear
#

Ok

#

Try to learn css and bootstrap

#

It will make your website attractive

#

Well then, good work

zenith flume
#

il try it

#

thanks

brisk spear
#

Bro listen

#

For every new project in flask do we need to install flask

#

Again?

zenith flume
#

im not sure

brisk spear
#

And how did you trigger the action event?

#

Is it with flask?

zenith flume
#

<form action="/cats/" class="inline">
<button style="background-color: saddlebrown" class="float-left submit-button" >go to my cats</button>
</form>

#

no html

brisk spear
#

Ok thnks

zenith flume
#

no problem :D,

brisk spear
#

Bro how much you know python?

#

Listen u used python 3 or python

zenith flume
#

python

brisk spear
#

Then you might have used virtualenv

#

Right?

zenith flume
#

i know the syntax learned pygames,tkinter,flask,pyautogui,ursina,panda3d

#

yeah i use it for everything

brisk spear
#

Bro one advice

#

Why don't u use python 3 it has built in environment

#

venv

#

It might be easier right?

zenith flume
#

il try it does it have a big diffrence

#

?

brisk spear
#

I guess venv is good

#

U don't have to install virtual environment if using venv

zenith flume
#

as said il try it out

brisk spear
#

Well ok

#

Had u tried 3.9.1

#

Has it got some difference

#

Or same

zenith flume
#

too which version?

#

exactly

brisk spear
#

Like other version

zenith flume
#

not much

#

not a lot

brisk spear
#

Ok

#

Bro are u on github l?

zenith flume
#

yeah my code for my website is on it

brisk spear
#

Bro have u got github Student developer pack?

zenith flume
#

no

brisk spear
#

Bro apply for it

zenith flume
#

what does that give i have a school email so i could apply for it

brisk spear
#

Are u in school

zenith flume
#

now? or in general

#

yeas

#

yes

brisk spear
#

Which class?

zenith flume
#

8th

brisk spear
#

Ohh

#

Then u take it lager on

#

Later*

zenith flume
#

but i was able to get the jetbrains ide licenses

brisk spear
#

Bro what u use?

#

Linux, mac etc...

zenith flume
#

windows

brisk spear
#

Ohk

#

Vscode right?

zenith flume
#

no pycharm

brisk spear
#

Ohk

#

Good bro

#

Html also in that?

zenith flume
#

yes

#

and css

#

and javascript

#

bro u still there?

brisk spear
#

Yes

twilit needle
#

can someone please help me here?

chrome juniper
#

So I have made my own API using, Flask, FastAPI and I want to host it under api.domain.com, I have created an a record in the dns poitning to my unbuntu vps. But I'm quite unsure on what to do next

marble gate
#

which u can do with ftp

#

and u need to install python on the vps

#

then you would go to the api directory and run pip install on the requirments file

#

Then u can use a process manager and run the api

mental beacon
#

Hi all, does anyone know of a Python library that outputs Javascript? Similar to how yattag outputs HTML?
I realize this is kind of an odd use case.
I have a Python script that synchronizes some data on the backend of my server hourly with a third party API, and I'd like to add functionality to this script to output some of the data as a file with a Javascript object.

gaunt marlin
tulip beacon
#

guys how can I keep the left side options, the logo and the search bar in place and make the chatbox scroll up and down?

#

what should I do?

native tide
#

Hello who know very well DJANGO ?

steady sonnet
#

anyone have any experience with file upload via webapp into flask ?

quick cargo
#

To make it so shit stays aligned properly i would also consider using a flex box to properly position the static stuff

#

otherwise it'll go a bit mental

#

flex + flex-column

thin dome
#

wow what a frontend

#

design i mean

timber quarry
#

hi i have a problem with my tcp chat room it works fine on a local network but i cant get it to run outside my network
can you help me

native tide
#

plss help in this... I am a begginer and new here... so cant access the voice ... plsss help me in this... and have to give a voice message coz... the problem was long to write

weak mesa
twilit needle
#

any help will mean a lot,
this issue is with me for a week now... 😢

teal rapids
#

[DJANGO] Is there a specific reason for a form to be put multiple times inside an HTML template?

#

I pass a ModelForm to the html template, but the template "prints" it like 6 times 😩

swift sky
#

hello how would i remove these artifacts ?

#
testing

\r\n
 

\r\n
testing```
#

for example it's pulling the headers and stuff [{'content_id': 2042, 'the_date': '02-01-2021', 'content': '

#

and the line breaks

#
 

\r\n```
#

this is my view

#

sql_query2 = "SELECT content_id, date_format(load_date, '%m-%d-%Y') as the_date, content from roll_call order by content_id desc limit 5"

#

and

#

data2 = cursor.fetchall()

#

fragment2 = data2

native tide
#

The one thing I see that may be an issue is the indentation of the for loops here.

heady cipher
#

how do you create or make a website

native tide
#

Hello who know very well DJANGO ?

toxic flame
#

Show me your models

#

Your looping 3 things

native tide
wanton ridge
#

how can i check if the email adress and name already exists in the database. This codekeeps redirection me to the login

brisk spear
#

Bro u are using what database?

thin dome
#

have you writen it in django?

native tide
past cipher
wanton ridge
#

@brisk spear mysql

wanton ridge
brisk spear
#

Isn't it a sort of difficult to use

#

Bro where did u learn using database?

wanton ridge
#

lesson

#

and did tutorials

native tide
# wanton ridge not sure, should it be a problem

You tell me. When you make a request see if both views are working for that URL. Personally, I think your error here is because you have assigned two views to the same URL. I'd try to put print statement in both views, visit the URL, and see which one runs.

native tide
brisk spear
#

Ok

brisk spear
#

@wanton ridge can u suggest some channel/website where it is well explained

wanton ridge
#

codeacademy@brisk spear

brisk spear
#

Ohk thnks

wanton ridge
#

no problem

toxic flame
#

itachi with a non itachi pfp

#

Epic

toxic flame
#

Loop through the usernames in the database checking if there are matching

#

if match return a message and blah blah blah etc

#

That's the only method I can think of

heady cipher
#

how do you create a URL?

wanton ridge
native tide
wanton ridge
native tide
# wanton ridge how can i check if the email adress and name already exists in the database. Thi...

well in this case, when the user signs up they will always be redirected to login when the Password == Confirm...

You need to add another if/else statement checking if the email is available. If it is, sign them up, if not, show them an error message.

It would help to keep it within one function. Also, why don't you use Flask-SQLAlchemy? They should have a method for checking whether an entry exists or not.

wanton ridge
#

and i know mariadb and mysql

#

so i wanna go with them first before i go sqlalchemy

toxic flame
#

And with the entries of the database you for loop it checking if the username exists already or not

#
for a in query:
  if str(email) == str(a.email):
    if str(username) == str(a.username):
      pass
  else:
     return (something)```
native tide
toxic flame
#

django is alot easier kek

native tide
#

^^

toxic flame
#

alot of people says its monolithical

#

But like, you don't have to 100% use it's default settings, or it's built in admin / auth system, it's purely up to you.

toxic flame
wanton ridge
#

@toxic flame i mean i just began learning frontend and backend for 2month

toxic flame
#

I began 4 months ago

#

as a hobby

wanton ridge
#

i am kinda new lol not new but not that good either

#

same here

toxic flame
#

Well I learned django in like a week

#

python in 2 days

wanton ridge
#

i guess you programmed before so

toxic flame
#

nope

wanton ridge
#

i didn't

#

ohh

toxic flame
#

complete beginner 4 months ago

wanton ridge
#

ohh

toxic flame
#

ohh

wanton ridge
#

give me the site

toxic flame
#

for wut

#

r u talking about where i learn stuff?

wanton ridge
#

yeah

toxic flame
#

the official documentations

#

but what i do is just dive right in and whatever problem I encounter I just google it

wanton ridge
#

the python original website?@toxic flame

toxic flame
#

For python?

wanton ridge
#

yeah

toxic flame
#

Yea

wanton ridge
#

i am learning python in school

#

i think we are wrong here to chat or?

toxic flame
#

idrk lol

#

I wish school taught me languages

#

django has a very nice documentation btw

wanton ridge
#

wanna dm me?

toxic flame
#

Sure

olive tiger
quick cargo
#

well django admin will just run the same thing as manage.py in terms of running the dev server

proud spire
#

Hello
First time using Flask as webserver (on a Raspberry Pi), it seems like I can't link/connect my javascript.
I did make a static and templates folder , and somehow my css-file does work.
Anyone can help me?
Thanks

wanton ridge
#

refer not defer

#

i dont know defer

#

@proud spire

#

not sure but i think thats it

sweet field
#

same

#

i dont use defer anyway

wanton ridge
#

yeah same

halcyon lion
#

any jaBascript pros who use webstorm

#

need help setting up mocha and chai

sweet field
#

huh

#

JaBascript?

#

javascript?

proud spire
#

It's for JS loading, but I just tested it to make sure and it's still not working

sweet field
#

hmm so ur directory is wrong then mb

halcyon lion
#

yeah javascript 😄

sweet field
#

ur using two ways to use the script

halcyon lion
#

i just like to call it jaBascript because its dumb 😄

sweet field
#

the url for (jinja 2)and the default in html

#

hmm they might interact strangely and f*** it up or something as ive said i dont use defer

native tide
#

instace of sqlalchemy has no column

#

how do i fix this?

#

i use vsc

sweet field
#

uh that should be fine btw

native tide
#

well it stops my code from executing

sweet field
#

its an error that i dont think u can fix

#

uh

#

wait

#

ss it

native tide
sweet field
#

ya mine runs fine with that error it might be something to do with pylint

#

ye

#

search on google theres a fix but i dont have time to search it up for u

native tide
#

btw this

#

isnt it correct

sweet field
#

Integer

#

not integer

native tide
#

i had it integer

#

but i switched

#

same error

sweet field
#

mine runs perfectly fine

native tide
#

man idk

#

k nvm fixed it

sweet field
#

what was wrong?

native tide
#

i had another one like this

#

db.integer

#

so how do i create the db now?

#

i run db.create_all()?

sweet field
#

run

#

then import from ur file the class

#

then db.create_all() pretty sure

#

or from ur file import db then db.create_all()

#

i think

native tide
#
from server import db

db.create_all()
#

C:\Users\Apoel\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_sqlalchemy_init_.py:833: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the
future. Set it to True or False to suppress this warning.
warnings.warn(FSADeprecationWarning(

#

this is the error

coral raven
#

Add SQLALCHEMY_TRACK_MODIFICATIONS = False in your config file

grizzled sand
#

Hey guys, i'm looking best solution to store meta data for index page ( title, description etc). What best practice to do that?
For example i have this data for view-detail, but for list-view not sure how to implement that correct

formal gull
#

i need to tie in a web scraping application from an external source that can take in information given on a web page. how would this be accomplished? example: web page gets a user input number. application takes that number, inputs it to a search in another website, gets information on that site and returns it on the web page.

i have this application made using selenium and tkinter for a UI but work is not allowing this anymore so i want to just throw it in a web page some how.

#

how would i accomplish this?

zinc hill
#

How I did mine was using django, but mine is very simple idk if that would be any use.
it literally scrape covid data from the govt website and pass the info to HTML/CSS, I didnt use database cos I dont see the point.

edgy isle
thin dome
#

How to learn advance things of Django

lucid eagle
#

go through docs

#

and there is also stack overflow

still jay
still jay
#

request.form["whatever"]

still jay
#

its mostly because its disabled

#

since u already know a inital value u can do something like ```python
name = 'value'
form_name = request.form.get('name', name)
print(form_name)

lucid eagle
#

django?

gaunt marlin
#

You don't learn advance things, when you encounter a problem, you find the documents for that part. Hardly people remember all features of Django

native tide
#

Hello guys who know very well django please

brisk spear
#

I guess u have to import it

wanton ridge
#

when i open my database i can't see any data. Can someone help me

native tide
#

C:\Users\Apoel\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_sqlalchemy__init__.py:833: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the
future. Set it to True or False to suppress this warning.
warnings.warn(FSADeprecationWarning(

#

flask wont let me create database

#

flask sql alchemy

edgy isle
west wren
#

I'm not sure how to differentiate between a guest and a user when the frontend (Vue) and backend (Python/Flask) are completely separate. I want to show a landing page with separate navbar to guests, and one with the tools to the authenticated users.

There's an API route that checks whether a user is authenticated using flask-login.

@bp.route("/isLoggedIn", methods=["GET"])
def check_if_logged_in():
    return jsonify(user=current_user.is_authenticated), 200

And I thought of simply checking this, and if it returns true set a Session Cookie that essentially goes: isUser: true and building the navbar based on that. But, users can simply modify this and it doesn't feel correct.

As I'm using Vue, requesting the route each time wouldn't be a good solution, as I'd have to rerender the navbar. Some searching on Stack Overflow and Google didn't help.

So... what's the best session, one-time approach to telling the difference between users and guests?

uncut spade
#

Hi, is there a way in django to add a filefield to a model class ? I know that you do the opposite way , but the other i'm not sure, this is what I want to do:

#
    user=models.OneToOneField(User, on_delete=models.CASCADE)
    class Meta:
        form=FileFieldForm```
#
class FileFieldForm(forms.Form):
    file_field = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True}))
    class Meta:
        model=User```
native tide
#

I'm having issues with flask_socketio, and can't get it to run. I have installed the correct versions as per the flask_socketio wiki, however get errors out the ass when trying to connect. (traceback here: https://haste.warsawpakt.xyz/wegifuv.sql)
Here is the python code and the index.html file, respectively:
https://haste.warsawpakt.xyz/isitume.py
https://haste.warsawpakt.xyz/afutave.erb
Here is the output of pip freeze:

bidict==0.21.2
click==7.1.2
dnspython==1.16.0
eventlet==0.30.1
Flask==1.1.2
Flask-SocketIO==5.0.0
greenlet==1.0.0
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe==1.1.1
python-engineio==4.0.0
python-socketio==5.0.4
six==1.15.0
Werkzeug==1.0.1```
barren moth
#

how does one parse html to get a description out of it?

#

at least, I think its html

#
async with ctx.http.get('https://www.explainxkcd.com/wiki/index.php/2419') as resp:
  text = await resp.text()
  print(text)
native tide
#

beautifulsoup

barren moth
#

that's an aiohttp context

#

okay

barren moth
native tide
#

np

barren moth
#

I got pretty far so far

#

Just trying to get the thing right below a thing

#

from h2

#

I think I can get it

#

@native tide I just found there's an api for the website

native tide
#

use that then

barren moth
#

lol

barren moth
#

nope

#

the api returns html

near pendant
#

hello

#

can anyone suggest me any tutorial on how to a make live counter-like django app(i.e. when you press upvote on reddit, it updates immediately, in both front and back end)

past cipher
#

is it possible to automatically set enviromentals when running app.py?

#

instead of manually typing export key=value

native tide
native tide
native tide
native tide
native tide
wanton ridge
near pendant
#

hello

#

in the picture I am making a webpage where I want the logo in navbar to be in middle. Now I did it using margin left which is not a very good thing cause when I resize windows it gets messy

#

is there any other way?

west wren
native tide
#

@west wren well, I dont know how else you will differentiate one user from another :D

magic fern
#

I need to make some web backend for a constrained environment, i.e. router. I'd rather use python because it's easier to write in and lets me reuse code from other projects, but the target environment is too small for full python + libraries. What are my best options?

wanton ridge
#

@near pendant try bootstrap

#

it fits the page on every device

split steeple
#

The CSS for my admin page in Django isn’t working and shows only the base html, any advice?

near pendant
#

or you are running it on local machine ?
usually it's a case of loading static files (i think)

#

try 'python manage.py collectstatic' and then change your static directory (from settings) to that directory

near pendant
split steeple
near pendant
#

have you added '{% load static %}' on top of the html file ?

split steeple
#

Ah ok I think I see, for some reason when I set debug to false it messes things up, setting it back to true has it all working correctly

near pendant
#

weird cause debug serves a totally different purpose

wanton ridge
#

ohh ok

split steeple
#

Weirder still, turning it off and on again fixed everything

#

But thanks Don, I do appreciate the help

knotty mortar
#

Hey Guyz, I am facing a problem in Google Developer Console that I am unable to create my billing account as my transaction keeps getting error even after the successful OTP submission..thus I am not able to get API credentials.Has anyone gone through the same problem before?

prisma pendant
#

Hey guy's

#

My webbrowser package does not work, what can I do about it?

edgy isle
past cipher
#

is the value set when you inspect element ?

#

@edgy isle

edgy isle
#

Yes

past cipher
#

can I see more code

#

because it should work fine

#

also maybe removed disabled on this one input called name and see if you can get the value

#

also check the post data in chrome debugger tools

uneven wren
#

Hello, i have a question. I am coding food ordering website (django) and right now i have done orders for nonregistered users (via cookies), but now i need to create orders for registered user. How should i do that ? i need cart (stored in cookie for nonregister) to vanish when user logs in and load his saved cart (dunno where to save this cart) and when we logs out load the cookie as he is nonregisted one. Is there a way how to do this somehow ? Thanks

past cipher
#

remove the cookies when he logs in ?

uneven wren
edgy isle
past cipher
past cipher
edgy isle
past cipher
#

@uneven wren just post to the db in the background so you don't have to refresh the page everytime they do it

uneven wren
edgy isle
#

okay ima make a paste nvm thats way to large

past cipher
#

!pypaste - nvm forgot what its called

edgy isle
#

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

past cipher
#

I think you'll have to query the db when they click add to cart, I may be wrong but I don't know another way

uneven wren
past cipher
#

depends if the cookie has an expiry

uneven wren
#

i was thinking about second cookie but that is not possible right ?

past cipher
#

look into onDisconnect

#

maybe you could try use that

uneven wren
edgy isle
#

Also the API responds with

[SQL: UPDATE ban SET username=?, userid=?, images=?, reasons=?, banstart=?, banend=?, notes=?, appealable=?, bannedby=? WHERE ban.username IS NULL]
past cipher
#

why are you using a third party to do the request ?

#

the request is done when the user clicks submit - nvm i see this is another request after you get the data, i think?

edgy isle
#

And the return from update/ban does

http://127.0.0.1:5000/edit/ban?name=None

As the URL instead of

http://127.0.0.1:5000/edit/ban?name=test
edgy isle
#

Idk WHY I DID THAT WAY

#

But I think its because of something I encountered with the actual adding and not editing

past cipher
#

can you open console in chrome, go to network, submit the form and check the data is actually being submitted correctly

#

instead of using request module, you could create a function somewhere, call the function, and then send the data

edgy isle
#

I just prefer using request module

#

SOMEHOW IT WAS THE DISABLED???

#

I swear I tested it without it

#

already

#

I just

#

Thanks for your help anyways @past cipher

#

wait

#

nvm the API is still having issues

#

its still saying

[SQL: UPDATE ban SET username=?, userid=?, images=?, reasons=?, banstart=?, banend=?, notes=?, appealable=?, bannedby=? WHERE ban.username = ?]
#

give me a second

#

ok fixed it

#

I am

#

whatever thanks @past cipher

marsh frigate
#

Who can recommend a good Django course?

haughty turtle
#

@native tide Do you want to work on a project together? I got 4 down, looking to do one more maybe a bit bigger, take a look at my portfolio, www.christianlfonts.com

toxic flame
#

Hello, so on django it's really specific on the url addresses, for instance if you put login/ the address has to have a / on the end for it to work, is there a way to support both? without a / and with a /

haughty turtle
#

@toxic flame the reason it's like this is because when you use a web deployment software such as Apache or Ngingx you will notice that the / at the end means that it's a directory. When you have something without a / it means that its looking for a file.

toxic flame
#

So, is there no way?

vestal hound
#

@toxic flame the reason it's like this is because when you use a web deployment software such as Apache or Ngingx you will notice that the / at the end means that it's a directory. When you have something without a / it means that its looking for a file.
@haughty turtle TIL

toxic flame
#

What's TIL

old halo
#

today I learned I think

native tide
weak mesa
eternal blade
#

If I am hosting my django site on heroku do I need to change the data base from sqlite to postgress or something?

native tide
#

Hello who know django very good ?

near pendant
#

sqlite is good for websites with smaller number of users

eternal blade
near pendant
#

Do you know how to migrate to Postgre ?

#

if you know then you can keep it however you like, if you don't then you should learn cause, most web apps would use something other than sqlite

eternal blade
west wren
native tide
gaunt marlin
#

that look like a suspicious link...

#

better not click on it

native tide
#

Hello

#

I want to learn Web Devloping

#

Can you all just tell me a few answers?

#

Q.1 Which sources should I use for learning Web Development

#

Q.2 Is Web Development good or Python?

#

Q.3 Any books to use to learn Web?

#

Q4 Any app on PlayStore that I can use?

#

Anyone who knows please tell me

#

PLEASE

eternal blade
#

How can I make the django admin panel only available for 1 ip address if another ip address tries to access it they'll get a 404 error

eternal blade
glad patrol
#

hi i want to update the row when update button is pressed

#

when i click on update a pop up apper's here i need all the fields against row and update it in database.

#

i am using flask

visual trail
#

Hello i used a script to scrape instagram comments from a post but it's only scraping 25 and the post has 600
Help please ?

gaunt marlin
#

@glad patrol set the modal as a form, when you click update on the list use jquery to update the form with hidden input type contain the id of it, after that just send the POST request to update with ajax

glad patrol
#

@gaunt marlin can you share any resource link or video

native tide
#

Sure, how are you going to know how to route some people's request to the guest API and other people's request to the user API?

gaunt marlin
#

your update button on the list should have attribute with the id of the object row id, on button click pass that id value to the modal

glad patrol
#

thats the problem

#

i cant get id of the row

gaunt marlin
#

i passed the data-id attribute from button to the modal

glad patrol
#

pls come to dm

gaunt marlin
#

sorry can't right now i'm in the call at work right now

#

but i hope that example help you

glad patrol
#

your example you get id ?

gaunt marlin
#

wait

#

i posted the wrong thing let me repost

glad patrol
#

lol

#

ok

frigid fiber
#

Hey guys! I want to build a real-time candle stick chart. My backend will be Python and Django, but I know Django is not good at styling. And I am a beginner for front-end language and web-development, so I get struggled for choosing the JS framework. I want to ask which framework is better for combining with Django. Vue, React or Angular?

gaunt marlin
#
$('.btn-rating').click(function (event) {
        event.preventDefault();
        $("#rating-form").attr('data-class-id', $(this).attr('data-id'));
    })
#

there this is more simple @glad patrol

glad patrol
#

ok this will only get the id form each row

gaunt marlin
#

yes but it pass the value in the form/modal i have

#

!codes

#

i forgot the link to post the long code one...

#

it's the html for the form in modal

twilit needle
#

any solutions will really help me

gaunt marlin
twilit needle
#

please anyone?

#
        cleaned = [obj for obj in data if not hasattr(obj, 'is_default') or not obj.is_default]
        self.model.objects.bulk_update(cleaned, ['position'])
        for instance in cleaned:
            # we trigger signals manually because django doesn't do
            # the same for us during bulk_update
            post_save.send(sender=self.model, instance=instance)

this is what I am doing.
For every instance in the for loop a trip is taken to the db for post_save.send

#

why? Can I reduce this?

glad patrol
#

@gaunt marlin thank you i will try

weak mesa
gaunt marlin
native tide
#

@glad patrol is django ?

glad patrol
#

@native tide flask

native tide
glad patrol
#

can you pls tell the logic

#

to perfrom what i want

#

how do i achive this

native tide
#

!code

lavish prismBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

tribal tapir
#

Hello

#

oooooh it has to be templates manwatafk lol

#

wierd

#

its not rendering the h1 text tho

#

idk im following a tutorial

winged axle
quick cargo
#

what are you trying todo?

winged axle
# tribal tapir

and of course make sure that your file is at same path as index.html

past cipher
#

Can anyone see whats wrong with my code. I am trying to login a user, and allowing persisting session across multiple subdomains
init

app = Flask(__name__, subdomain_matching=True)
app.secret_key = 'dsfsdfdfgsfsdsdgfdsf'
app.config['SERVER_NAME'] = "local.test:5000"
app.config['REMEMBER_COOKIE_DOMAIN'] = '.local.test:5000'
app.config['REMEMBER_COOKIE_SECURE'] = None
eternal blade
#

Can I use django and a react native together?

tribal tapir
#

i think you can

#

for full stack?

eternal blade
native tide
#

hey guys, I used Flask, now I'm ready to move on

#

what's the best way to learn django

dreamy anvil
#

Does anyone know what's the best way to inspect the value of variables while a flask app is running in development mode using PyCharm?

past cipher
#

@dreamy anvil

#

what do you mean

#

why not just print the variable

dreamy anvil
#

I mean a flask app that's actively running

past cipher
#

i don't think you can inspect the element of a backend variable while its running, unless you stop it, add in print statements on the routes where the variable is, based off what you're sayng anyway

dreamy anvil
#

Shame

past cipher
#

what is it you want to do exactly

dreamy anvil
#

it's a quite complex API and it would be impractical to have a verbose mode because it would have to print so much

#

I want to be able to inspect variables in an ad hoc fashion

#

similar to how if you have a console open in pycharm you have the menu which shows all the variables

#

like that but for a script that's actively running basically

fickle rivet
#

Hey, guys I've been trying to host my Django app on an Apache server for almost a month and I can't figure out why my application doesn't get hosted corretly

#

Can I get some help ?

#

[Wed Feb 03 19:30:55.769191 2021] [wsgi:info] [pid 8622:tid 140359668412480] mod_wsgi (pid=8622): Shutdown requested 'gbot2.alf.net'.
[Wed Feb 03 19:30:55.769532 2021] [wsgi:info] [pid 8622:tid 140359668412480] mod_wsgi (pid=8622): Stopping process 'gbot2.alf.net'.
[Wed Feb 03 19:30:55.769553 2021] [wsgi:info] [pid 8622:tid 140359668412480] mod_wsgi (pid=8622): Destroying interpreters.
[Wed Feb 03 19:30:55.769565 2021] [wsgi:info] [pid 8622:tid 140359668412480] mod_wsgi (pid=8622): Cleanup interpreter ''.
[Wed Feb 03 19:30:55.780961 2021] [wsgi:info] [pid 8622:tid 140359668412480] mod_wsgi (pid=8622): Terminating Python.
[Wed Feb 03 19:30:55.805720 2021] [wsgi:info] [pid 8622:tid 140359668412480] mod_wsgi (pid=8622): Python has shutdown.
[Wed Feb 03 19:30:55.805809 2021] [wsgi:info] [pid 8622:tid 140359668412480] mod_wsgi (pid=8622): Exiting process 'gbot2.alf.net'.
[Wed Feb 03 19:30:58.064814 2021] [wsgi:info] [pid 9310:tid 140688627171392] mod_wsgi (pid=9310): Attach interpreter ''.
[Wed Feb 03 19:30:58.068810 2021] [wsgi:info] [pid 9310:tid 140688627171392] mod_wsgi (pid=9310): Adding '/home/adp_py/apps/gbot2/mysite' to path.
[Wed Feb 03 19:30:58.069126 2021] [wsgi:info] [pid 9310:tid 140688627171392] mod_wsgi (pid=9310): Adding '/home/adp_py/.virtualenvs/gbot2/lib/python3.5/site-packages' to path.

#

That's the apache_errors.log

native tide
#

So how do i get django on pycharm

#

ik im dumb

#

@fickle rivet are you using modwsgi?

#

Never heard of it

#

nevermind figured it out

olive tiger
native tide
#

ik

#

I prefer pycharm over vs

#

and others

#

Also pc shit and cpu cooler laoud af when using vs

neon isle
#

hello how can i get the ip adress of an user with flask ? I tried request.remote_addr but it's give the wrong ip ... sorry for my english

native tide
#

Are you using a reverse proxy?

#

You might need to read the IP from X-FORWARDED-FOR

neon isle
#

cloudfare

native tide
#

X-FORWARDED-FOR is the right header to use

neon isle
#

ok thx

neon isle
native tide
#

In the examples above, 203.0.113.1 is the original visitor IP address and 198.51.100.101 and 198.51.100.102 are proxy server IP addresses provided to Cloudflare via the X-Forwarded-For header.```
#

So the first IP address is the visitor and second is the proxy server.

#

What you using the IP address for?

native tide
#

Also remember, that with IPv6, you could end up with a situation where you only have the proxy server for X-FORWARD-FOR and then you will find the IPv6 in Cf-Connecting-IPv6

naive oar
#

Hi All! I have a Django question that I haven't found a solution for, how can I make css background image url dynamic with the Django template tags? I've tried this approach and it's not working <div class="user-image-div" style="background-image: url({% user.userprofile.image.url %};)">

grim pond
#

Anyone know how I can find this elemnt in selenium? find_elements_by_class_name doesn't seem to work

noble spoke
#

with flask, is there a way to have a route with the same name for a different request method like it is with expressjs?
eg what i want is

app.get(() -> {});
app.post(() -> {});

instead of

@app.route("/route", methods=["GET", "POST"])
def route_func():
  if method == "POST":
    # do X
  elif method == "GET":
    #d Y
native tide
#

Does flask support Class based views.. then you could have methods for get and post.

#

I know Django has that ..

noble spoke
#

ah thats what theyre called?

#

i'll look it up

fickle rivet
# native tide https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/modwsgi/

Yes, <VirtualHost *:80>

ServerName gbot2.alf.com

LogLevel info
ErrorLog /home/adp_py/apps/gbot2/apache_errors.log
CustomLog /home/adp_py/apps/gbot2/apache_custom.log combined

ServerName gbot2.alf.net
ServerAlias gbot2.alf.net

Alias /static /home/adp_py/apps/gbot2/mysite/staticfiles
<Directory /home/adp_py/apps/gbot2/mysite/staticfiles>
Require all granted
</Directory>


<Directory /home/adp_py/apps/gbot2/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>

</Directory>

WSGIDaemonProcess gbot2.alf.net python-path=/home/adp_py/apps/gbot2/mysite:/home/adp_py/.virtualenvs/gbot2/lib/python3.5/site-packages
WSGIScriptAlias / /home/adp_py/apps/gbot2/mysite/mysite/wsgi.py application-group=%{GLOBAL}
WSGIProcessGroup gbot2.alf.net

</VirtualHost>

fickle rivet
fair ginkgo
#

h

surreal thicket
#

can someone help me name something? i have a list of 50 categories, and each user in my application can choose to subscribe to one or more categories. i need a name for "the list of all categories, with a true/false flag on each category, identifying whether the user has subscribed to that category".

so this would be a resource like /users/{user_id}/categories-with-selections , i just need a good name for categories-with-selections

#

trying to balance verbosity with clarity

native tide
#

Subscriptions?

#

You could also call it Notifications, if you put a bit of text just saying that the notification will be a push or marketing message for the category 🙂

surreal thicket
#

these aren't notifications specifically

#

it's more like a "selection"

#

something to show on the user's home page

rustic pebble
#

Subscriptions seems fitting @surreal thicket

surreal thicket
#

heh, maybe i didnt explain clearly

#

i will have one resource that returns a list of category IDs

#

and another that returns this list of all categories, annotated with whether the user has selected it

#

so i have

/users/{user_id}/preferences/tags
    User's list of selected tag IDs
/users/{user_id}/preferences/???
    All tags, with {..., "selected": true} if the user selected it
#

you all still think "subscriptions" is the way to go?

rustic pebble
#

no

#

you should have this

#
/users/{user-id}/preferences/tags/ids
/users/{user-id}/preferences/tags/selected

So no need for adding the extra {"selected": true"}

#

@surreal thicket

surreal thicket
#

ah

#

well... this is a specific request from the frontend 😦

#

they want it all in 1 request, i know it kinda breaks the REST model but it's a performance consideration

rustic pebble
#

well i would still go with that, just add the {"selected": true} part

surreal thicket
#

ah

#

noted

#

i like that

rustic pebble
#

well it makes the most sense tbh

surreal thicket
#

would you have /users/{user-id}/preferences/tags return anything as well?

rustic pebble
#

hmm, it depends, it could return all tags, selected and unselected

surreal thicket
#

even though it's on the user resource?

#

we will definitely already have top-level /tags for that

rustic pebble
#

well then /users/{user-id}/preferences/tags should not return anything

surreal thicket
#

this is actually one issue i've had with the rest model as i start to learn it on a professional level, seems like you could have multiple endpoints all doing the same thing

rustic pebble
#

what framework are u using?

surreal thicket
#

as a hobbyist who cares? but designing apis for longevity is hard stuff

#

my team is using tornado

rustic pebble
#

Hmm

#

Well here is the thing

surreal thicket
#

nothing specifically rest-oriented, the rest part is somewhat of an organically growing layer on top of the tornado stuff

rustic pebble
#

I am guessing this is a big project, correct?

surreal thicket
#

yes

#

and i come from the data science world so professional web dev is somewhat unfamiliar territory to me

native tide
#

Hi

#

😭

rustic pebble
#

I am working on a huuuuuugeee project with some other devs, mainly frontend ones, the frontend is based in react

#

and I am using a microservice structure for the backend along with another dev

#

If you are multiple backend devs then building something under a monolith can result to things like this seems like you could have multiple endpoints all doing the same thing

#

Also really hard to scale properly as it scales linearly

#

Just my input ofc

surreal thicket
#

this is actually for one of our microservices 😛 or is rest for microservices is considered an anti-pattern?

rustic pebble
#

No its correct

#

Alright, then you probably have multiple endpoints in different services that give the same or similar responses

#

right?

surreal thicket
#

right now, no. we don't have a standalone tags service yet, and users only come from 1 place

#

so all of these endpoints i described, for now, would be under my purview in this one service

rustic pebble
#

Hmm, that is not correct

#

You should have everything user related under one microservice

surreal thicket
#

tags are applied to content, and users can select their list of tags for filtering content by default on their homepage

#

so tags aren't just for users

rustic pebble
#

Because if what you are building contains routes for other things, and they are used all the time then the route u mentioned earlier will get delays for no reason

#

Oh i see what you mean

#

Still, you should have different endpoints for these

#

If this is for a social network then this is our approach on a similar thing:

Everything user related stays within the user related microservices
Everything home page or content display stays within their respective microservices, even if that means that some endpoints are pretty much the same

#

They serve a different purpose thus they are listed accordingly

surreal thicket
#

right, that much i understand

rustic pebble
#

Question: Are you using a message broker to talk internally?

#

like redis

surreal thicket
#

what about something like this? /tags?user={user_id}

#

heh, that's a separate issue...

rustic pebble
surreal thicket
#

that was what i was thinking, yes

#

what do you mean by "clot"?

#

as for how our backend is set up:

  • tags are stored in our CMS, which has its own API
  • users are stored in a database hosted by a cloud provider
  • the microservices are running in hosted kubernetes with istio
rustic pebble
#

Basically both user specific and general calls would be made to the same endpoint

surreal thicket
#

ah, yeah

#

is /tags/by-user/{user-id} not rest enough?

rustic pebble
#

I am hoping this

#

:

#

You are not loading the tags each time from the db

#

Cause, if you are then that will be heavy asf once that route starts getting attention

surreal thicket
#

😅 yes, we can cache the list of tags

rustic pebble
#

I wouldn't cache them

#

well i would

#

but in redis

#

and load them with a background task from the cms api

#

That way you can access them globally

surreal thicket
#

the list of tags will change very rarely and the cache can be invalidated manually. but unfortunately i don't have the ability to run a message broker, unless i run it inside the container which seems to be somewhat pointless

rustic pebble
#

since u are using k8s, it still hasn't dropped docker in its public version i think, you can run redis as a service

surreal thicket
#

oh, is it going to drop docker at some point in the future?

rustic pebble
#

Yes, they have announced it

surreal thicket
#

it's all cloud hosted/managed anyway so i assume we will still have docker access

rustic pebble
#

Not sure, but you should think of your microservices architecture more

#

The need for a message broker is big

surreal thicket
#

trust me, i want to. i just joined this team and they've been working on this all somewhat independently from each other

#

dev A works on service 1 and dev B works on service 2, and they sometimes meet to discuss things

rustic pebble
#

well that's how it should be, but isn't there a general plan of how things talk to each other

surreal thicket
#

right. ive been trying to get more broad architectural discussions going and avoid snowballing cruft & tech debt, but features must be delivered in the meantime

rustic pebble
#

Before we started our project we spent weeks discussing it

surreal thicket
#

i will float the message broker idea, the team is pretty open to new ideas but short on time to "experiment"

rustic pebble
#

I mean, it is really easy to use

#

And it will help you solve a lot of problems

#

mainly cause its blazing fast and can you can load pretty much everything on it

#

then just have background services updating the db through redis

surreal thicket
#

noted, i have worked with applications that use redis but never used it myself

#

a year ago i was doing machine learning, and now here i am in the web dev trenches

rustic pebble
#

Haha nice, I have only done web dev

#

mainly backend

#

I got some really good frontend devs in my team

#

so i handle most of the backend myself

surreal thicket
#

its nice to be doing something that i dont know much about and am constantly learning, and i appreciate the advice

rustic pebble
#

well web dev is easy to learn hard to master

surreal thicket
#

also its funny, so many people try to go from dev to ml, i did the opposite, although mostly out of a sequence of coincidences and weird life choices

#

so i see, there is quite a lot to keep track of in order to do things right

rustic pebble
#

Haha, in a production environment it is entirely different than dev

#

But yea ML is on my to-learn list

#

i have it in the 4th semester of my uni as well

#

I learnt web dev completely by myself

surreal thicket
#

i've actively avoided going into #data-science-and-ml or any of my usual stats/datasci/ml chatrooms because i was getting burned out. but one day im sure ill be able to help advise you on it 🙂

rustic pebble
#

I asked some questions here in my early steps but i haven't gotten much help since then, i mostly reply to questions and not ask hah

rustic pebble
#

Also, I got one more question for you

#

Since you are building a microservice why are you using tornado?

#

Is this what you know best or are you forced?

surreal thicket
#

forced 🙂

#

the microservice architecture was already set up when i arrived

#

and tornado was already chosen for the web framework within each backend python service

#

i should also note that we are trying to transition to graphql, which at least solves the data modeling problem, if not the query performance/bottleneck problem

#

we already have a graphql service running on top of everything but not everything is exposed through it, so we have lots of frontend stuff hitting the rest APIs and not graphql... its a bit of a mess

rustic pebble
#

GraphQL is insanely good if u get it right

#

I am still trying to learn it but we will transition to it soon

surreal thicket
#
{
  user(id:1234) {
    tags {
      id
      display_text
      selected
    }
  }
}

this would be the ideal world for me

#

well... actually no

#

same problem

#

inversion of whether "tags" or "user" is the top-level thing

#
{
  tags(user_id:1234) {
    id
    display_text
    selected
  }
}
#

hm

rustic pebble
surreal thicket
#

👍

#

would it be better to do tags/{user_id} or tags?user_id={user_id}?

#

since for now i have to just do it in rest and worry about graphql later

rustic pebble
#

Go with tags?user_id={user_id}

surreal thicket
#

will do

#

i just realized that we need to have /tags/{tag_id} anyway 🙂

#

this has been extremely helpful, thank you

rustic pebble
#

No problem

#

Good luck!

visual wolf
#

Hello , I am thinking of learning Django framework, what all should I know before starting to learn Django?

surreal thicket
rough umbra
#

I need help in heroku hosting

visual wolf
surreal thicket
visual wolf
#

Okays 👍

native tide
#

Hello what is the best way for display pdf page on a html page ?

native tide
#

container?

distant charm
#

Hello guye i am new to web development. I have some experience in HTML and CSS

#

which lib should i use for python web dev? Flask?

native tide
#

Depends - how hectic is your project.

#

Django is great for when you need an admin and storing data

#

Flask is great for, I feel and some may disagree, more pure play API endpoints 🙂

native tide
#

Hello

alpine lintel
#

How can i set cooldown on submitting form in django?

wraith cypress
#

hey, anyone have a good source to learn web sockets or socket.io stuff?

native tide
#

@wraith cypress learn for fun or learn to integrate into your current software?

wraith cypress
#

to integrate to django specifically

#

but I could use anything helpful on the topic in general

native tide
#

Super easy, I did it in like 3 days for a real time barcode printer

#

because you can make normal REST API requests to Pusher - which sends the WS messages

wraith cypress
#

will check it out, thanks!

native tide
#

The problem with websockets at scale, is actually loadbalancing cause you can;'t move sessions between normal LBs - so over time, some LB's might get super hot and others super cold

#

Hence get Pusher to do that hard work of managing the actual Websockets

wraith cypress
#

so you think it's worth it since you pay for getting rid of the headaches of websockets and have to think less about them

wraith cypress
native tide
#

Well, I was EU - EU - so about 1.5x slower than what I would expect a REST call

#

but the nice thing - you deliver to Pusher, you can kind of stop having to send that data.

#

So if it's a big message, and the client has a slow connection - not your issue

wraith cypress
#

nice, thanks for letting me know about it

native tide
#

Also, they got SDK for iOS, Android and React 🙂 Sweet

#

How in gods name do import Django to PyCharm without these

lavish prismBOT
#

Hey @native tide!

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