#web-development

2 messages · Page 81 of 1

acoustic oyster
#

@solar pecan an api is just a way to send data from one application to another. A common example here is creating an api with django that can send data to a front end application (like a react app).

I have an api that allows users to create blog posts with django, then those posts can be received by a React app via GET request.

It is also very common for people/companies to create apis that provide services.

You can also send data to an api. So in django you could also have a user create a new blog post, then send a POST request to create a new blog post in the database through django.

solar pecan
#

@acoustic oyster ohhhh, nice I get it now for sure, it makes sense, okay thanks

somber aurora
#

@somber aurora I see. I guess you have set your own field to primary key, instead of the default Auto Field in the User. And that's causing an error.
@tame onyx How to add Auto Field?

tame onyx
#

models.AutoField(). It's the default primary key type. I'm not sure how to revert back to that field once you've changed it. Whenever I faced errors like this in my code, I've deleted my database and migrations, and migrated again.

native tide
#

Hey! Kinda new here lol, I'm building a website for a neighbour and I need to implement a form like ordering system which has multiple forms which could be used more than once before submission but I'm not sure how to go about it. I'm thinking Flask or Django with maybe WTForms? which I've come across. anyone mind pointing me in the right direction?

tame onyx
#

If you're managing a git, you can just revert back to a previous commit.

models.AutoField(). It's the default primary key type. I'm not sure how to revert back to that field once you've changed it. Whenever I faced errors like this in my code, I've deleted my database and migrations, and migrated again.
@tame onyx

#

@native tide Can you elaborate the part about the forms? I didn't get that.

native tide
#

I’m no genius at this stuff so excuse me if I’m wrong lol

tame onyx
#

I don't know anything about WP. Right now the idea I have in my mind is: Keep the forms in a div. When someone selects some items and clicks on Add to Order, Show this Place Order or Add More. This Place Order and stuff will be in a div, the forms div can be hidden and this Place Order div can be shown. And when someone clicks the Add More button, show the forms div, and hide this Place Order one. Finally if someone clicks on Place Order button, take them to the checkout or something.

#

I'm just thinking out loud, so this approach can be wrong. If I find some better approach, I'll make sure to tell that to you @native tide .

native tide
#

@tame onyx Yeh, this is my first WP site and don't worry i appreciate your help. My Computer Sci teacher always said i overcomplicate things lmao. I just need three forms which the user can fill out and add to a "list" bearing in mind that could be the same form more than once hence the need for a temporary third party variable before being sent off elsewhere.

tame onyx
#

@native tide That's nice. We'll figure out some way. 😁

#

@keen gust you might wanna see this.

native tide
#

@tame onyx Yeh, I've been sat over this for two days now lol (I seriously don't have a life lmao) Ofc I've not been in school since March and my academic brain has left me lol

tame onyx
#

lol yeah. Feels like it's been ages.

native tide
#

Well I guess the first place to start would be build a page for it lol but then idk if I build a separate part of the website in bootstrap or with WP (I have an uncode license https://undsgn.com/uncode/)

keen gust
#

@native tide are you planning to use Wordpress or use Python. If Python we can think together and find a solution. I personally have no experience with WP and yes, WP and Python are way apart.😆

native tide
#

@keen gust The site which is live rn is built on WP but I'm open minded to the solution, being as I can't find a plugin which works python seems to be the next best option, if that's integrated directly into a form built with WP or a completely separate webpage hosted on the same domain idk

tranquil robin
#

I am creating a webapp using Flask , and I wanted to know if it is possible to add 2 entries to the standard "right click context menu"?
I don't want to create a custom menu, I just want to add 2 items to the existing one.
Is that possible?

native tide
#

Ofc anything possible with flasm

#

Flask*

#

Jinja, flask, html,CSS,js, bootstrap

#

Done o

tame onyx
#

@native tide ok we'll try to figure something out. If you don't mind joining our chat server for a casual discussion.

tranquil robin
#

@native tide and how do I go about doing that?

native tide
#

Hmm some a tag and list URL for

broken abyss
#

what can cause problem in django that it do not want collect all static files

#

?

acoustic oyster
#

alot of things

#

improperly configured settings, directories, whatever the error message says

broken abyss
#

collectstatic copy just some of static files and then later i just have "GET /static/js/demo/chart-pie-demo.js HTTP/1.1" 404 1701

acoustic oyster
#

so you ran python manage.py collectstatic and it completed without errors?

broken abyss
#

yes

acoustic oyster
#

The issue is likely with your settings then

broken abyss
#
STATICFILES_LOCATION = 'static'
STATIC_URL = '/static/'
STATIC_ROOT = 'static'
STATICFILES_DRIS = [
    os.path.join(BASE_DIR, 'TwoB/static')
]
acoustic oyster
#

yeah

#

so for static root I believe you want to use

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
#

and when I set static file dirs, I also use BASE_DIR, this is so the path points to the file relative to your project. Rather than something like /static which would be the root directory of linux /static, rather than your project/static

#
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "react_app/build/static"),
]
native tide
#

Hollup, you need an API for the backend to communicate with a React frontend?

#

Bruh

acoustic oyster
#

?

native tide
#

Honestly I don't know what I'm talking about, I need to first learn React. Ignore me 🙂

acoustic oyster
#

yeah, in this case I use DRF to serve the posts and images for a gallery to a react app

broken abyss
#

[22/Aug/2020 18:40:25] "GET /static/js/demo/chart-pie-demo.js HTTP/1.1" 404 1701

#

:/

acoustic oyster
#

so you probably need to reconfigure the settings, then collect static.

Manually check if the static folder exists where you expect it to and delete the other static folder you created somewhere xD

#

did you collectstatic in a dev environment?

broken abyss
#

0 static files copied to '/home/mbienias/django/TwoB/static', 132 unmodified.

#

I probably do not understand how this work

acoustic oyster
#

the purpose of collect static is to allow your static files to handled by your web server, such as apache. So I do not know how the dev server handles static

broken abyss
#

i just copied all static files to this folder by myself

acoustic oyster
#

that message just says that it tried to collectstatic, but there were no changes to any of the existing static files

broken abyss
#

i just collected /admin/

acoustic oyster
#

are you trying to deploy your site?

broken abyss
#

no, just localy via runserver

acoustic oyster
#

do not collectstatic for dev, give me one sec

#

and then your templates would you <link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}">

#

you will collectstatic when you go to deploy, this will allow your webserver to serve the static files

broken abyss
#

god...

#

i had typo in STATICFILES_DRIS

#

so collect statics was basically just running without path

acoustic oyster
#

lolol, nice, I did not see that xD

native tide
#

Why do i get this?
Uncaught TypeError: body.appendChild is not a function

acoustic oyster
#

because that is not a function xD

#

what is your actual code

native tide
#

fixed it by adding document

#

how can i add classes in jinja2?

acoustic oyster
#

nvm jangey is here

mellow tide
#

I'm doubtful that adding documentation is what fixed the non-function thing lol

#

But you wouldn't really add classes to jinja, but you can extend them in your own code by inheritance

native tide
#

Ok.

dawn heath
#

hello, I want to improve a little bit my process where people needs a paid account , but however in my get . I have to do the same over , and over with a changing the pk . however I want to change the workflow as the first block templateview , where I can make the use of my custom or something like that without doing the same over , and over. I basicalyl I want to re-use get and change only id , but how? https://dpaste.org/30Qo#

fair agate
#

Anyone who uses Djongo package and has a config file for db info care to share how you accomplished it? Trying to work it out and running into some roadblocks

somber aurora
#

@tame onyx What are the Parameter's I should pass in Auto Field?

#

nvm

exotic zodiac
#

Hello everyone, I'm trying to make a flask api and want to divide every route in a seperate file.
What I was trying to do was this:
- index.py:

from flask import Flask
from config import Config

app = Flask(__name__)

import routes

if __name__ == "__main__":
  app.run(debug=not Config.production)

and in the routes folder I have a this file:

from flask import Flask, make_response
from index import app

@app.route('/shop')
def hello():
    return 'Hello, World!'

But if I open http://localhost:5000/shop I get a 404 not found response
PS: I'm a total beginner to python but have decent knowledge in other programming languages

somber aurora
#

Why not put the Routes i the same file?

warm bobcat
#

But it should work. Maybe just rerun the server?:)

native tide
#

@exotic zodiac The file that runs is the one with app.run(), if you want the file to run in /routes you need to link it to the main file with a Flask blueprint

#

I think

exotic zodiac
#

@somber aurora because the code would be cluttered, if I write everything in the same file

#

@native tide ok thanks

native tide
#

np

somber aurora
#

How to use a Foreign Key to Identify who Posted a Blog?

atomic zinc
#

Hello all. I read Python Crash Course and watched some other courses and have a basic understanding of it. Recently I started learning web development (html and css).My question is do I study Python and web dev at the same time or study one thing for a week and so on.

native tide
#

@atomic zinc if u can multi-task like me then u can do both it same time but i don't prefer doing both at same time because we human won't completely learn what we studied so i prefer u to do one at a time so u can easily learn the fundamental function of the web development else u struggle alot ok.

atomic zinc
#

Ok. I was planning on for example learning web dev for 2 days and on the third refresh/learn Python.

#

I agree that the fundamentals of anything are very important

#

@native tide

native tide
#

@atomic zinc in Web development To understand the base of a internet in the perspective of a font-end developer and back-end , i highly recommend u watching this video
for fontend: https://www.youtube.com/watch?v=e4S8zfLdLgQ backend:https://www.youtube.com/watch?v=FTAPjr7vgxE after this i prefer u picking flask or django for backend and learn how cookies work session works and some http system like those things

How does the internet work? Most people really don't have to know, but web developers have to know more and more as they grow in their career. These 2 videos cover how the internet works from a web development perspective.

Also, check out part 2: How the internet works from ...

▶ Play video

View part 1 here! http://youtu.be/e4S8zfLdLgQ
How does the internet work? Most people really don't have to know, but web developers have to know more and more as they grow in their career. The information in these videos is a must-know if you're working on a complex javascrip...

▶ Play video
atomic zinc
#

@native tide Thanks for the recommendation. I will check it out . I am currently following TOP - The Odin Project.

timid frost
#

Hello there... I'm following along in ch3 of "Django for Beginners" by William S. Vincent. I'm to the point of 'deploying' the current app to Heroku. Got a free account set up there, went through the steps outlined in the book and everything looks good... but the web page shows an error message telling me to go back and look at the error logs.

When I run heroku logs --tail I found the following, which sure looks like for some reason that gunicorn didn't get loaded/installed when the app was created.

#

2020-08-22T21:24:48.288583+00:00 heroku[web.1]: Starting process with command gunicorn config.wsgi --log-file -
2020-08-22T21:24:50.419445+00:00 app[web.1]: bash: gunicorn: command not found
2020-08-22T21:24:50.467452+00:00 heroku[web.1]: Process exited with status 127
2020-08-22T21:24:50.501286+00:00 heroku[web.1]: State changed from starting to crashed

#

Not sure where I went wrong... the tutorial just had me install gunicorn using pipenv for this step, then I saved everything in git, pushed the updates to github, then to heroku.

native tide
#

You'll have to add gunicorn to requirements.txt

dawn heath
stark escarp
#

how would i make it so the index.html goes to another page i created called page2.html

warm igloo
#

@stark escarp An anchor tag? <a href="page2.html">go to page 2</a>

#

Or do you mean automatically?

stark escarp
#

@warm igloo I want to do it through a button

warm igloo
#

well, you can style that anchor like a button for instance, which is preferable actually for a lot of reasons (accessibility, semantics, seo).

Is there more to the form than the button you have?

stark escarp
#

yes

#

i assumed it would be something like domain.com/page2 but how would i make it appear @warm igloo

warm igloo
#

So, your form is on index.html

And on form submit, you want it to go to page2.html

But what do you intend to do with the data in the form? You need to process it server side unless you're doing something with it only in the client.

Because technically you can do <form action='page2.html'><button type='submit'></form> and on submit it'll go to page2.html

stark escarp
#

<button onclick=" window.open('page2.html','_blank')">Complete Now</button> something like this?

warm igloo
#

you can if you want, but the form isn't submitting, is that fine?

Also, that will open page2.html into a new tab, that what you want?

#

@dawn heath Been a minute since I used jQuery, but:

var small = $('#subscription-form small').first();
small.text(data['message']['from_email']);
small.css('display', 'inline-block');
stark escarp
#

yes but i tried the button click and it did not pop up the page2.html

warm igloo
candid dagger
#

anyone have experience with using splinter, beautiful soup and know how to not get a recaptcha?

acoustic oyster
#

yes, yes, good luck LOL

#

@candid dagger if you are trying to bypass a captcha, then you are probably violating their tos/robots.txt

#

!rule5 I think is a command?

#

or

#

!rule 5

lavish prismBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.

acoustic oyster
#

with that said, google has plenty of info

limber laurel
#

Could someone recommend ideas for an applicatiin that would be good for learning new things?

acoustic oyster
#

are you looking to get into web dev stuff?

#

a classic starter project would be the portfolio and blog combo. A website that works as a portfolio, but also has a blog to showcase your backend abilities

limber laurel
#

I already have experience with making web applications.

#

But I want to find an idea that would make me pesrn things that I have possibly missed or new things

acoustic oyster
#

oh I see

#

create a chatroom with django, asgi, websockets

#

combine a discord bot with a front end and database using a backend framework

#

these are just my projects haha

tame onyx
#

@tame onyx What are the Parameter's I should pass in Auto Field?
@somber aurora I'm not sure dude 😥

limber laurel
#

@acoustic oyster Alrighty :)

#

Thank you

acoustic oyster
#

Np

crisp pasture
#

How Do I Make A WebSocket Connection
Library discord.py

glass sandal
#

You need socket library as far as I know

tranquil robin
#

I have a deeply nested object that looks something like this

{
  "title": "something1",
  "id": 1,
  "children": [
    {
      "title": "something2",
      "id": 2,
      "children": [{ "title": "something3", "id": 3, "children": [] }]
    },
    { "title": "something4", "id": 4, "children": [] }
  ]
}

Is there anyway to be able to render this in Flask Jinja2 as a ul / li structure ?

late fjord
#

Vagabond

#

@tranquil robin

valid cypress
#

How to make Django app production-ready?

somber aurora
#

@somber aurora I'm not sure dude 😥
@tame onyx It's fine I got it working. Thanks for your help.

tame onyx
#

@somber aurora oh okay. 😄

keen aurora
#

Hey, I got a problem with Django, if anyone can help me please check out #help-lollipop

sacred oasis
fallen mango
#

Hello guys
I m new here
I m trying to make a project like MS sharepoint ,but i wish to use django
Can anyone tell me what all i need to learn and what libraries or framework to use to make an advanced project like sharepoint

Pls help ,i need assistance ASAP

mellow tide
#

@fallen mango are you new to python as well? A thing like SharePoint is going to be quite an on-taking

#

But regardless, Django probably includes everything you need

fallen mango
#

No i m not that new to python

#

Been doin it since January

quick cargo
#

thats still fairly new overall tbh

fallen mango
#

I just need some guidance on what libraries will be involved

mellow tide
#

Django 😎

fallen mango
#

thats still fairly new overall tbh
@quick cargo GWseremePeepoHappy

#

Kinda

dawn heath
#

how can I force directory_listing to call request.user or make operations like request.get_full_path ? https://dpaste.org/czGH

native tide
#
class Projects(models.Model):
    project_name= models.CharField(max_length=60)
class Pictures_project(models.Model):
    picture= models.ImageField(upload_to='pictures/', default='a/none.png', null=True, blank=True)
    project_id = models.ForeignKey(Projects, on_delete=models.CASCADE, null=True, blank=True)

hi,
i have a model named projects, and each projects has more pictures
my question is how do i parse the pictures of one project in a html page, provided that i send to that page the data from only one project?

bleak bobcat
#
  • You should rename project_id to just project. While it's true that at a database level an id will be stored, from the orm point of view "project_id" will be a project object.
  • Add a related_name="whatever" to your foreignkey, then from a project object you can call project_object.whatever.all() (which will be a queryset of Pictures_project)
native tide
#
def project(request, project_name):
    proiect = Proiecte.objects.get(project_name=project_name)
    return render(request, 'project.html', {'proiect': proiect})
#

my views function looks like this

#

i think im already sending all the data from that one project to the html page

#

im wondering how can i display those images on the page

#

with a for for example

bleak bobcat
#

I'm not gonna repeat myself

native tide
#

ok, but i didnt quite understand

bleak bobcat
#

Once you have done what I told you you can just do

{% for thing in prociet.whatever.all %}
{{ thing.picture.url }}
{% endfor %}
native tide
#

ok, will try

#

thanks

pliant notch
#

Whats a good start to web dev?
If i wanted to create a web dashboard for my discord bot

native tide
#

Dashcord is a good module

#

its being rewrote soon

simple sentinel
#

For web servers, which is more recommended, apache or nginx? or something else I'm not aware of?

wet shell
#

I'm currently working on a price tracker using Django, i'm at a point where id like to make my charts, what is a good way to go about this? ill need to update my database hourly with new results and have my logic done somewhere to scrape amazon for the data. Any help would be amazing

twilit zenith
#

use chart.js if you know JS

wet shell
#

thats what my research shoed but how do i have it be reactive and update every hour

marble carbon
#

every hour??

#

if you're using django

honest current
#

thats what my research shoed but how do i have it be reactive and update every hour
@wet shell ajax is a great way to make it update every hour/min/10secs etc..
Another way is to install django-q and schedule a task to run every hour or 30mins or something.. This might be more comfortable as you don't have to go out of python.

Edit: Coming to think, whenever you save the data in a database, the charts will automatically update.
Check out django-q if you want your scapper to run hourly or so.

marble carbon
#

you can just fetch data from database to create it

#

every time that page is opened?

marble carbon
#

ohh the scraping part

#

yeah you'll have to configure task scheduling

#

to scrape every hour

#

and save in database

#

so you don't need to update the chart it'll be updated itself when database is updated

#

and yeah you could either use Django-q

#

or celery beat

quiet rapids
#

Hi I want to learn django, any suggestions on tutorials

silent blade
#

how do I use eventlet with flask-socketio?

#

I put import eventlet eventlet.monkey_patch(socket=True)at the top of my script and the server doesn't start

#

just by the eventlet module being installed, the server won't start

acoustic oyster
#

@quiet rapids corey schafer. Youtube

native tide
#

anyone here mind a weird question?

balmy shard
#

Not at all

native tide
#

I am currently using flask for a toy application

#

there's a part of the application which would probably benefit with a faster path than python can handle

jaunty stream
native tide
#

is there a way to proxy a set of uris to another application server and bypass the python server on the response?

fiery coral
#

Hey I'm deploying flask and using waitress

#

how do I set it to where when you access the IP Address you don't need to route to port 8080

#

0.0.0.0:8080 is what it is sending to

#

but I want it to where if I just access the ip for example 0.0.0.0 I will open the webpage

native tide
#

so, the objective is to change the port to 80

fiery coral
#

uhm I'm not familiar but that does sound right

#

if I just set that parameter in the waitress port setting, will it just work like that?

native tide
#

under linux and you start the application by a user with the right permissions, it would.

#

(I know enough to be dangerous)

fiery coral
#

So I have to allow that port in my firewall then?

#

I get permission denied when I try to run that port through waitress

#

😦

#

please help

native tide
#

what distro are you running?

fiery coral
#

ubuntu 20.04

mellow tide
#

@fiery coral you have to sudo to use 80, otherwise, you have to use something >= 1024

fiery coral
#

@mellow tide I'm using ufw and I sudo added port 80 but when I use waitress it gives me permission denied

native tide
#

use sudo to start waittress

fiery coral
#

I get command not found when I prefix sudo

#

am I doing it wrong?

mellow tide
#

The waitress is in your local path, not the system path

native tide
#

sudo -E

#

should be fine

mellow tide
#

Lol ... Yeah, I really only trust Apache or Nginx on that port, but good luck to you

native tide
#

yeah

fiery coral
#

So I should probably learn how to do this with nginx huh?

mellow tide
#

Yeah lol

native tide
#

digital ocean has two guides using other webservers

fiery coral
#

Tried -E didn't work, thanks for the help thooo

native tide
mellow tide
#

Because if that is exposed to the internet, you will immediately start getting hammered

native tide
#

and heres uWSGI

#

you can probably modify one of the guides to use waittress but not motivated enough to do it for you

fiery coral
#

Yeah, I'm just now getting into deployment so I'm learning security and all that

#

thanks for the links

mellow tide
#

But if -E didn't work, try bin=$(which waitress-serve) sudo ${bin} ...

#

E should have worked though

native tide
#

what is your preferred web framework?

fiery coral
#

Oh nice guys I got it

#

thanks

#

Are you asking me what my preferred web framework is? @native tide

native tide
#

general question

#

anyone who wants to respond, then do so

fiery coral
#

I think flask is a web framework. If it is, that one. It's the only one I've ever used.

warm igloo
#

Flask. But I haven’t given Django or others a fair shake yet.

#

Overseeing a FastApi project now. Look forward to the code review.

#

Will probably get Wagtail running soon so I’ll get to play with Django a bit then.

native tide
#

I started with flask... considering moving to fastapi with a separate frontend.... though it wouldn't solve my current issue so. 🤷‍♂️

mellow tide
#

FastAPI now, was Falcon, and flask before that (I only do APIs though lol)

#

But also, I do very little in the way of web with python anymore

warm igloo
#

My website warcache.com is built in flask. I’m actually taking the work I did on that and turning it into a cookiecutter template.

#

I should probably kill that site though. Hmm.

native tide
#

im considering moving to asp dot net core or rust... just to have the entire project uniform

mellow tide
#

@native tide well that question answered itself... Rust lol

native tide
#

rust would be a greater learning curve than f# or c#...

#

I guess

mellow tide
#

It's really not

#

If you aren't broken by the ways of writing bad c/c++, is not bad to learn

#

Hardest part coming from python will be static typing and the lack of classes

native tide
#

Memory ownership tripped me up and project layout though I didn’t follow the tutorial

mellow tide
#

The compiler is super helpful though, I bet it told you exactly what the problem was lol

#

And probably how to fix it

#

Admittedly though, I've no interest in C# or F#, so I'm very biased here lol

#

Although, for most web things, I write Go

#

Rust is my systems language, Go is my web language, Python my data/math language

native tide
#

Nice toolbox

mellow tide
#

Seems to be the most versatile for me these days

native tide
#

And the compiler probably did but I didn’t know enough to fix it

sturdy pike
#

Does anybody know what the difference is between null=True and blank=True

acoustic oyster
#

I believe in django fields, null=True is used to say that DB column can be == NULL, whereas blank=true is used to say that the field may be left blank when created (specifically with a form)

#

something like that

vestal hound
#

Does anybody know what the difference is between null=True and blank=True
@sturdy pike null is about the database and blank is about the form

#

so for example, if you had null=True and blank=False, you wouldn't be able to add a model instance with no value provided for that column through a form

#

but you would through, say, dbshell

junior stratus
#

Hey, ive created a simple flask server with flask migrate for the db schema. The tutorial i followed suggested to add the migration folder to the version control (im using git(hub)). Ive tried to setup my project on my laptop but i have no clue how to correctly setup the flask migrate. I tried with flask migrate init -> folder already exists, flask migrate upgrade -> runs but not using my schemas

lucid vine
#

Anyone have any idea why my function that gets a token from SQLite DB would return none when called with a URL parameter but when called with a parameter from the request body (in JSON format) it works fine

#

I heard it could have something to do with URL encoding, but I dont know anything about it

lapis spear
#

why is may ListView is not sorted by date_published

models: date_published = models.DateField(default=timezone.now)
post_list.html: {{ object.date_published|date:"F d, Y" }}
class based view: ordering = ['-date_published']

it is like its sorted by day but not by day and time

zinc hill
#

How would you go about to create a multiple type of user for example
company= username, name, establish
customer = firstname, lastname, age

#

on django

native tide
#

How do I move information from python to react?

lapis spear
#

How would you go about to create a multiple type of user for example
company= username, name, establish
customer = firstname, lastname, age
@zinc hill i think by creating model for each type or user sir
like
class Company(models.Model):
.......
class Customer(models.Model):
.......

zinc hill
#

thank you thank you

lapis spear
#

thank you thank you
@zinc hill im noob i don't know if there is a better solution about that sir maybe some pro may answer your question😅 👍

marble carbon
#

oh you mean django

#

Dw i gotchu

#

and this

#

@zinc hill here

lethal orbit
#

Hey! What would be the best/cleanest way to force child instances of a Django Abstract Base Class to implement a specific method? I know I can use @abc.abstractmethod decorators in ABCs, but I am not sure it's a good idea to add ABC as a parent class to my base. Should I just raise NotImplementedError in the base class?

#

Do @ me if you reply 🙂

flint breach
#

raise NotImplemented, seems foolproof

#

then again, you can't instantiate a child class if an abstract method isn't overloaded

#

so, that work aswell?

#

what do you mean by ABC as a parent class to my base

#

@lethal orbit

lethal orbit
#

Django Abstract Base Classes are not the same as Python ABCs.

#

(AFAIK)

modest scaffold
#

can someone help pls ive busted my database

#
django.db.utils.IntegrityError: The row in table 'website_test' with primary key '15' has an invalid foreign key: website_test.parent_id contains a 
value '5' that does not have a corresponding value in website_image.id.``` this the error message
#

ive tried deleting the models but no luck

flint breach
#

oh, you mean for a model

#

yea that's different, mybad

lethal orbit
#

ive tried deleting the models but no luck
@modest scaffold How important is the data? Can you nuke the DB and restart? Or delete the website_test entry with pk=15?

modest scaffold
#

i could nuke it

#

how to do that

lethal orbit
#

Are you using sqlite?

modest scaffold
#

it wont let me access the db at all so i couldnt delete website_test if i wanted too

#

Are you using sqlite?
yeah

#

the default one

lethal orbit
#

delete (or move) the .db file...

modest scaffold
#

anytime i try to access those models i get this django.db.utils.OperationalError

#

aight bet

flint breach
#

simply delete teh db and you should be gucci

modest scaffold
#

sweet

lethal orbit
#

I forget what it's called. sqlite3.db? in your project folder

modest scaffold
#

db.sqlite3 close enough

flint breach
#

i fidled a bit with proxy models but not abc with django

modest scaffold
#

yeah nuking it worked thx patryk

flint breach
#

it's more of a problem when you can't nuke it 😛

lethal orbit
#

perhaps this hxxps://gist.github.com/gavinwahl/7778717?
I have seen that, and it might work. Was curious if there is an easier way than adding two more parent classes (esp since that gist is 7 years old).

flint breach
#

oh, that's definitely a yikes

lethal orbit
#

Oh, some things haven't changed at all, and it may still be viable lol.

flint breach
#

im preety sure a better solution should exist by now though

#

have you tried regulat abstract methods directly?

lethal orbit
#

I think I'd probably rather raise NotImplementedError() in the base class, and just make sure the tests cover it.... I only expect to have like 2 child classes anyway.

#

have you tried regulat abstract methods directly?
How do you mean?

flint breach
#

Django ABC, then an abstract method from the abc module

lethal orbit
#

Using this decorator requires that the class’s metaclass is ABCMeta or is derived from it.

#

So I would be forced to add that ABCModel class or similar, as per your link.

flint breach
#

peculiar why the django docs don't mention a way

distant trout
#

what is the ideal cache timeout?

#

using flask-caching

#

some of my routes take 10-15 seconds to load

flint breach
#

depdens on what you're caching

#

some of my routes take 10-15 seconds to load
@distant trout but yea, that's not normal

distant trout
#

its a lot of api calls

#

and charts

#

getting scraped data

#

thats probably why its so slow

twilit dagger
#

Hello, in Django is there a Model Field for a drop-down list?

distant trout
#

@flint breach do u know if i need some form of cache storage/db when I deploy?

flint breach
#

well again, depends on your needs

#

if you have stateful app then you'll need a db

#

if you have no info, you don't really need a db

distant trout
#

ahh

flint breach
#

if it's scraping data, then it makes sense it takes time

distant trout
#

Okay awesome, I dont have a stateful app so I probably dont need a db

#

thanks

native tide
#

How do I install and use django,
Is it good to make an actual NICE web with it?
I use pycharm

lethal orbit
#

do u know if i need some form of cache storage/db when I deploy?
@distant trout you probably do want to schedule the scraping, and store stuff in a DB. If you don't have users and whatnot, at least redis would be nice and fast.

#

cron or celery can wait 15 seconds... your users shouldn't.

distant trout
#

ahh i see

#

is redis the best cache framework? or whatever it is

#

I heard of it before and ik its in flask-caching

lethal orbit
#

It's great for caching and very fast. Not ideal for a general purpose DB. If I just wanted to cache some scraping requests, that's probably what I'd use.

distant trout
#

okay awesome i'll use that, thanks

lethal orbit
#

There are other options, of course, including postgresql (relational dbms), and mongodb (nosql). Feel free to look at other options. if not now, knowing DBs is always a plus when working on different projects.

distant trout
#

Yeah I have postgres installed, havent used it yet

lethal orbit
#

Depending on the data you are scraping (e.g. if it is JSON), you can also use a postgres JSON field.

#

No need to install a separate DB if you are planning on using Postgres already...

distant trout
#

oh wait, i can save json data in postgres?

lethal orbit
#

And most SQL databases.

distant trout
#

oh wow, i didnt know that. I think that might help in my situation

native tide
#

cannot solve this error: ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environm
i installed django, pipenv, i created a new project, i wrote pipenv shell, python3 manage.py runserver and it s not working

vestal hound
#

its a lot of api calls
@distant trout Flask doesn't support async, right?

#

are you making, like, web API calls?

#

would async help

distant trout
#

yeah web api calls

#

but i dont think flask has async

vestal hound
#

I see

distant trout
vestal hound
#

are the routes all accessed in series?

distant trout
#

theres this

vestal hound
#

because if you can do it concurrently

#

you could save a fair bit of time, most likely

native tide
#

You could write your api calls using async

distant trout
#

oh

#

oh wait there is celery

lethal orbit
#

You could... then save them in a db anyway :p

distant trout
#

db is usually faster right?

vestal hound
#

faster than?

distant trout
#

api calls

vestal hound
#

well...

#

it...depends?

#

on what's happening

indigo moth
#

hi

distant trout
#

yeah it probably is faster in my situation

#

since im making calls for a lot of data to show on charts

indigo moth
#

i have an error comes out. FileNotFoundError no such file or directory 'schedule_of_teams.json'

#

there's a strange thing that when i run the python manage.py runserver it works fine

#

but when i push it to heroku it gives this error

#

so what's the problem here?

#

and the error comes from views.py file

def schedule(request):
  with open('schedule_of_teams.json', encoding='utf-8') as f:
    context = json.load(f)
  return render(request,'schedule_of_teams.html', context)
#

btw this is a django app

#

is .json files do not deploy to heroku 🤔

native tide
#

Django with pure jinja or js? I think's better with js since page doesn't refresh 4 some things

lethal orbit
#

yeah it probably is faster in my situation
@distant trout almost definitely. Your DB most probably lives on the same server as your flask server (or at least, same datacenter), so network delays are negligible, and you also get the benefit of having a local copy if the remote server goes down. Also, you have full control over caching.

distant trout
#

ah that makes sense, thanks

winter spindle
#

is selenium help offered here ?

#

basically selenium with python !

indigo moth
#

Is there anyone can answer why this is giving me a FileNotFoundError ?

#

Scroll up a little bit you'll see the question

uncut spire
#

any flask_restx users, when using a namespace i can successfully marshal_with('model_name', dict_of_stuff), but what's to be done about marshalling errors? i see there's flask_restx.errors.abort, but it seems simply calliing that instead of returning a 400, let's say, doesn't provide the model schema in the swagger docs. what's a common approach here?

fickle lark
#

I want to build a Python server which has an endpoint to which I can send an image file of a Sudoku board. The response would be a 2D array representation of the Sudoku.
Can anyone point me to libraries/frameworks I should learn in order to build this?

uncut spire
#

@fickle lark flask, snapsudoku (might want to take apart how they do it since i think they just solve it for you)

fickle lark
#

This is perfect, thank you for pointing me to snapsudoku. Can you maybe point me to a resource for creating a good Python project? Namely, I want to know how to organize my files and folders, using dependencies (like package.json if you've ever programmed in Node.js), using linters, and stuff like that.

uncut spire
#

you should have an app.py with something like app = Flask(__name__), along with your endpoints defined in there to start

native tide
#

The Flask tutorial is a good point to start

uncut spire
#

then you can run it from a manage.py that imports your app and does something with app.run, or you can use gunicorn to run it if you want to have it be sturdier/more permanent

fickle lark
#

Hmm, I'll definitely need to do a bit more research on what gunicorn is, but I was imagining the endpoint to be a GET endpoint, since I don't really post anything, I just send it a picture and get some data.

#

Tho now that I think about it, GET request probably can't have a picture...

uncut spire
#

yep

#

cleanest way is a POST endpoint, check out request.files

#

the difference between GET and POST gets more muddled when it's something as simple as like, an email, but for larger files you'll want POST

fickle lark
#

Yup, I can see why

#

So when you mentioned app.run, what would that function be? Like, would it start the Flask server, or something like that?

uncut spire
#

check out that link, it'll give you more complete info than I can. in short, you initialize an application with Flask(...), name it app, and the Flask object has a run method that defaults to running your app on 127.0.0.1:5000

fickle lark
#

Awesome, the resources and tips you gave me were just what I was looking for! Thanks for helping me out, I appreciate it a lot.

uncut spire
#

naturally! pay it forward, lift each other etc

native tide
#

hey guys, does a flask freezed page posted on github still can call functions?

#

i wanted to host on github a flask freezed page which can call a ML model to make predictions and returns it to the user

#

i don't know exactly if it's possible

cinder olive
#

hi

#

i would need a little help with my flask code

left jungle
#

i would need a little help with my flask code
@cinder olive Okey, tell what you have got

cinder olive
#

well first of all i think the problem is in the python code,not the HTML or CSS part

left jungle
#

Ok

cinder olive
#

TypeError: login1() missing 1 required positional argument: 'user'

#
app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html',content=["AVIVA","NIGHTCORE","BRN"])
@app.route('/enterNum',methods=['POST','GET'])
def number():
    if request.method == "POST":
       number = request.form["num"]
       return redirect(url_for("num_times_num", num=number))
    else:
        return render_template( "getNumTimesNum.html" )
@app.route('/num')
def num_times_num(num):
    return f"<h1>{int(num) * int(num)} is the answer</h1>"
@app.route('/login',methods=['POST','GET'])
def create_login():
    if request.method == "POST":
       username = request.form["user"]
       return redirect(url_for("login1", user=username))
    else:
        return render_template( "login.html" )
@app.route('/user')
def login1(user):
    return f"<h1>Hello omega ultra amazing {str(user)}!</h1>"
@app.route('/name<name>')
def user(name):
    return f"Hello {name}"
if __name__ == "__main__":
    app.run(debug=True)
pure shoal
#

Question:
Is there an easy way for selenium python to run as an android web?

cinder olive
#

also this is my first day so i barely know what im doing

left jungle
#

Well, I see the problem now

cinder olive
#

what is it?

#

how have i failed this time

left jungle
#

You have @app.route('/user') but in the def login1 (user): you are expecting variable. So you have to change the @app.route('/userstring:user')

#

Basicaly you have to do it the same as you have it on the last @app.route('/name<name>')

cinder olive
#

thanks a lot!

left jungle
#

Did it work?

cinder olive
#

i really wanna start learning some stuff fast and this made me not be stuck here forever

#

yes

#

it did

left jungle
#

If you want to start learning Flask, I recommend Flask blog from Corey Schafer.

cinder olive
#

also is flask worth learning as a first thingie for web development?

left jungle
#

Yes, because it is easy to learn. And if you will be familiar with Flask, you can step up to Django. It will be similar

cinder olive
#

yes my idea was to learn this and then Django actually

#

im still a begginer so i need to suck up a ton of information and the logic of programming

left jungle
#

Happy learning. If you will want to help with something. Pm

modest scaffold
#

can someone help me with this generic-relation thing

#

i have two objects that have a generic-relation in django

#

this to be precise GenericForeignKey but when i delete the parent objects the child object is not deleted

#

nvm found the answer just had to use the GenericRelation field on the parent

cinder olive
#

ummm @left jungle i think i might need a little more help

#
app = Flask(__name__)
app.secret_key = "i will not share this
"

@app.route('/')
def index():
    return render_template('index.html',content=["AVIVA","NIGHTCORE","BRN"])
@app.route('/enterNum',methods=['POST','GET'])
def number():
    if request.method == "POST":
       number = request.form["num"]
       return redirect(url_for("num_times_num", num=number))
    else:
        return render_template( "getNumTimesNum.html" )
@app.route('/num<num>')
def num_times_num(num):
    return f"<h1>{int(num) * int(num)} is the answer</h1>"
@app.route('/login',methods=['POST','GET'])
def create_login():
    if request.method == "POST":
       username = request.form["user"]
       session["user"] = username
       return redirect(url_for("login1"))
    else:
        return render_template( "login.html" )
@app.route('/user<user>')
def login1():
    if "user" in session:
        user = session["user"]
        return f"<h1>Hello omega ultra amazing {user}!</h1>"
    else:
        return redirect(url_for("create_login"))
@app.route('/name<name>')
def user(name):
    return f"Hello {name}"
if __name__ == "__main__":
    app.run(debug=True)
pulsar ivy
#

Is it possible for js to chane image based on day in week???

native tide
#

Just can’t make sense of it, how the url is being changed and how lang code is actually passed

left jungle
#

ummm @left jungle i think i might need a little more help
@cinder olive where is the problem?

#

What I see is, that you do not have to have @app.route('/user<user>') because you are not using that variable in the function. So just @app.route('/user')

weak lynx
#

Hi Good day, i hope you all are good, i have an issue and if someone can help me it would be great... i deployed a page into heroku and when i go to the url it says... internal server error... thats error 500 does someone know how to solve it?

lethal orbit
#

Error 500 is basically a catch-all for unhandled exceptions, so .... handle your exceptions? Impossible to say without seeing code, or even knowing what framework you are using.

native tide
#

In flask, does the file which contains app.run() have to be in the root directory? As soon as I move it into a folder I encounter issues

vestal hound
#

Hi Good day, i hope you all are good, i have an issue and if someone can help me it would be great... i deployed a page into heroku and when i go to the url it says... internal server error... thats error 500 does someone know how to solve it?
@weak lynx you can run heroku logs in terminal to see your server logs

#

that should include the Python error that caused the problem

#

500 generally means that your code hit an unhandled exception

wet robin
#

How do I download a file to a specific location like the client's Desktop, when they visit a page?

bleak bobcat
#

You don't. You can't.

ruby fjord
#

.topic

fallow cairnBOT
#

No topics found for this Python channel. You can suggest new ideas for topics here!

native tide
glass badger
#

What’s the best and easiest python package to implement plots on my website
, including playable interface and 3D graphs

dark dock
#

hey does flask automatically call the

#

main() function in a file?

#

it doesnt have a decorator or anything but it calls it for some reson

#

if i remove teh app.run() then it doesn call the main function

#

why is this?

#

btw it only does it if

#

debug is True

#

why do they do this sosad

#

lmk thru ping

cinder olive
#

umm i need a little help

#

{% block head %}

{% endblock %}

{% block body %}
{% for i in range(num) %}
    {for j in range(i) %}
        <p>{{i}}</p>
    {% endfor %}
<p>  </p>
{% endfor %}
{% endblock %}```
#

it says i need to end block but...i ended it

bleak bobcat
#

{for j in range(i) %}

#

missing a %

cinder olive
#

oh shoot im dumb

#

now umm another problem

#

how do i make it not do new lines for each number

#

cause when i enter 3 i want 1 and 22 on the next row

bleak bobcat
#

You used a <p></p>

#

Paragraph = new line

cinder olive
#

sorry im dumb this is my second day

#

soo what do i use?

bleak bobcat
#

Nothing, or a span

flint breach
#

google html tags that don't cause a new line 😛

cinder olive
#

ayyy thanks

lapis spear
#

yo 🖐️ 😅 why are my statics files not working on my web this is development
app/settings.py:
STATIC_ROOT = ''

STATIC_URL = '/static/'

STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
# os.path.join('static'),
)
app/urls.py:
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

normal blade
#

hey guys

#

i have a conda env up by default, and i created a bash profile which im pretty sure went to conda as well

#

i wanna access the secret key in django, but i cant using SECRET_KEY=os.environ.get('SECRET_KEY') .. i think its conda being shitty but not sure

#

can someone help? im also very knew so sorry if this was a dumb question lol

indigo moth
#

i wanna access the secret key in django, but i cant using SECRET_KEY=os.environ.get('SECRET_KEY') .. i think its conda being shitty but not sure
@normal blade why you can't use os.environ.get('SECRET_KEY')?

#

just restart your terminal if you just added environment variable

lethal orbit
#

just restart your terminal if you just added environment variable
On Linux, you should be able to just do export SECRET_KEY=secret

jaunty plover
#

hey
is there an easy way to use discord oauth2 as a login option on django ?

covert kernel
#

how can give a python output (stored in a var) to a css file?

cinder olive
#

i need help,again

left jungle
#

i need help,again
@cinder olive what's the problem

#

Again

cinder olive
#

i have multiple buttons on a page and want weach one to send me to a diffrent link

#

and do not know how

#

{% block head %}

{% endblock %}

{% block body %}
<h1>Welcome to the stupid page!</h1>
<p3>This will become an actual page one day...</p3>
{% for i in content %}
    <p>HEY HEY</p>
    <p>{{i}}</p>
{% endfor %}
 <p><input type="submit" value="enterNum" /></p>
 <p><input type="submit" value="login" /></p>
 <p><input type="submit" value="logout" /></p>
<p><input type="submit" value="numTriangle" /></p>
{% endblock %}```
#

the thml part

#

html*

#

how do i make something happen for each value in particular?

#

ok i changed this a little

#
{% extends 'base.html' %}

{% block head %}

{% endblock %}

{% block body %}
<h1>Welcome to the stupid page!</h1>
<p3>This will become an actual page one day...</p3>
{% for i in content %}
    <p>HEY HEY</p>
    <p>{{i}}</p>
{% endfor %}
<form action="#" method="post">
 <span><input type="" value="enterNum" /></span> <span><input type="" value="login" /></span>
 <span><input type="" value="logout" /></span> <span><input type="" value="numTriangle" /></span>

</form>
{% endblock %}```
#

what type do i need?

lethal orbit
cinder olive
#

so that request.form gets the value

lethal orbit
#

how can give a python output (stored in a var) to a css file?
@covert kernel probably dumb way: Have CSS served by a Django view. Probably better way: use JS to set it on DOM Ready or something.

covert kernel
#

this is the repo

#

when i get the output from the python file

#

it should be given to css file

lethal orbit
#

so that request.form gets the value
@cinder olive easiest: probably have different forms with different actions. Less easy, use JS and override the click/submit...

cinder olive
#

soo how could i do the easy way exactly?

#

sorry im a begginer

lethal orbit
#

this is the repo
@covert kernel add Thumbs.db to .gitignore, then git add .gitignore, git rm Thumbs.db, and git commit. Don't pollute your repos with garbage 🙂

covert kernel
#

so basically i just delete the Thumbs.db?

lethal orbit
#
<form action="/enter_num/" method="post"><span><input type="submit" value="enterNum" /></span></form>
<form action="/login/" method="post"><span><input type="submit" value="login" /></span></form>
<form action="/logout/" method="post"><span><input type="submit" value="logout" /></span></form>
<form action="/num_triangle/" method="post"><span><input type="submit" value="numTriangle" /></span></form>
cinder olive
#

thanks for helping everyone @lethal orbit !

lethal orbit
#

If you're using Django, I think it also has login/logout views you can use...

cinder olive
#

i use flask\

lethal orbit
#

so basically i just delete the Thumbs.db?
That won't solve your problem, but it's a good habit to keep repos clean.

cinder olive
#

aand i make the type submit or button?

covert kernel
#

is it okay now @lethal orbit ?

left jungle
#

If you want to submit the form. Use type submit

lethal orbit
#

yeah, type="submit". Sorry, didn't add that.

#

is it okay now @lethal orbit ?
no... .gitignore should be a text file.

#

Where you list all the things you don't want to commit.

#

this is the repo
@covert kernel how do you serve your files? I just see one python file. Sounds like you need a web framework (e.g. flask) to do what you want to do.

cinder olive
#
def index():
    if request.method == "POST":
        if request.form == "enterNum":
            return redirect(url_for("number"))
        elif request.form == "login":
            return redirect(url_for("login1"))
        elif request.form == "logout":
            return redirect(url_for("logout"))
        elif request.form == "numTriangle":
            return redirect(url_for("numTriangleInput"))
    else:
        return render_template('index.html',content=["AVIVA","NIGHTCORE","BRN"])
#

that is not really sending me to the functions i need

lethal orbit
#

I see one static HTML file, and one .py that does nothing HTML-related.

#

@cinder olive: add different routes.

#

@app.route("/enter_num/") ...

#

And handle the forms there.

covert kernel
#

@covert kernel how do you serve your files? I just see one python file. Sounds like you need a web framework (e.g. flask) to do what you want to do.
@lethal orbit that is in a private repo, i just need help to change the bg color to the py output now

cinder olive
#

hmmm

lethal orbit
#

Much cleaner than having one route handle 4 (or more) form submissions....

lavish prismBOT
#

Hey @cinder olive!

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

cinder olive
#

how do i do what u saidf

#

said*

lethal orbit
#

@app.route('/login',methods=['POST','GET'])
Just make your <form action="/login"> in your html templates match those routes in your flask file.

#

and remove the if/else on lines 8-17.

#

using a redirect on forms/post is generally not a good idea.

cinder olive
#

it...gives me an error on every button

#

sooo how do i fix that

covert kernel
#

ok, so you can make a version of style.css with a placeholder for the background color. then you read the file and replace that placeholder with the color you want as you write the final style.css

#

how should i do this @lethal orbit ?

dapper tusk
#

in django, I am changing a model field type from int within 0-100(opinion) into a Like Indifferent Dislike enum, what would be the proper way to compute the enum from the old value for all existing entries?

grim cedar
#

r u trying to categorize the numbers between 0 to 100, to enum types of like ind and dis ??

jaunty plover
#

@lethal orbit sorry to bother you, but, is the key is just a random string of characters that I should generate myself ?

dapper tusk
#

yes

#

I need to figure you a nice way to migrate that

grim cedar
#

cant u just do it with ordered dict ?

#

nvm

#

im probably not getting what u want here lulk

dapper tusk
#

the logic of converting the number to the enum is easy, the problem is how do I do that automatically on every database entry as part of the migration

grim cedar
#

if ur using sql then just write a function in sql that does it for u ?

dapper tusk
#

I want to stick to the django ORM if at all possible.

lethal orbit
#

@lethal orbit sorry to bother you, but, is the key is just a random string of characters that I should generate myself ?
When you create a new django project, it generates one for you, and you can just move that to an env setting if you want. Otherwise, you can use any key. The default one is 50 chars long, so I wouldn't go much less than that...

#

If you want to store it in your repo's variables, you should make sure you can mask it - e.g. on gitlab, you can 't use special chars (!@#$%^&*()";:,.) or so, else it breaks the regex @jaunty plover

grim cedar
#

afaik i think u can still chuck in sql code in django query set to get what u want

#

but i havent tried it

dapper tusk
#

ye, I may have to modify the generated migration

#

which I guess is fine

jaunty plover
#

So, I don't need to do anything ?

dapper tusk
#

there is apparently also a concept of data migrations

jaunty plover
#

If the code is not public

lethal orbit
#

I want to stick to the django ORM if at all possible.
@dapper tusk why use an enum? Just store the int, and make the enum a property.

grim cedar
#

oh well. i thinks its for the old data

#

he wants to migrate

dapper tusk
#

because the requirements changed and I see no real reason to keep the numbers when only those 3 values are
used throughout the entire application

lethal orbit
#

So, I don't need to do anything ?
@jaunty plover if it's not public, and no one can see your key, then you can keep it in settings.py. Best practice is still to keep it in an env var, but it's not strictly necessary.

jaunty plover
#

Ok, thanks

lethal orbit
#

Then I would do it in two steps....

dapper tusk
#

I guess that is an option.

lethal orbit
#

Add the enum, in one migration, set it all to a default value....

cinder olive
#

ummmm i have another little problem

dapper tusk
#

having a migration step that leaves the application in an invalid state does put a sour taste in my mouth

cinder olive
#

the calculator thingie does not work

lethal orbit
#

Then write a script to get the int and update the like state.

cinder olive
#

also line 35 gives error

lethal orbit
#

Hard to say without seeing your code, but it's probably not that big a deal. Fix it manually by running the script, update your deploys, then squash migrations and that step shouldn't exist anymore.

#
  • add field B with a default value (e.g. neutral)
  • manually/scripted update field B
  • remove field A
  • squash migrations
dapper tusk
#

sounds good

#

thanks

#

would have really thought there was a magical thing I could just insert my function into though

grim cedar
#

u can still with sql function lul

lethal orbit
#

I think you can write your own migrations....

#

And take care of it in a single step...

#

But it is probably more complex.

cinder olive
#

if my function has 2 or more arguments how do i use the url_for to redirect them?

lethal orbit
#

You can also update models.py, makemigrations, then edit the file before you migrate, maybe.

#

Not things I've ever done, and for a one-off, I'd go the more manual route... but I am by no means an expert.

cinder olive
#

ok new problemo

#

def calculator gets stuck in a loop

#

forever

#

line 38

weak lynx
#

Hi Good day... I have a page in heroku with a atabase in it... how can i make changes to the page without touching the daabase... or how can i download the db from the server... does anyone knows?

worn mural
#

@cinder olive if both variables are connected in a single string how will the programm distinct if the number is part of the first variable or the second one? Imagine this scenario: your make a request to the endpoint "/calculator5123"

#

is num1 supose to bee 5? 51? or 512?

#

and num2 1? 12 or 123?

#

So what, you should do is: /calculator/<num1>/<num2>

cinder olive
#

still does not work

#

it like does not register second num

worn mural
#

could you send me the snippet so I can take a look ?

cinder olive
#

a snippet of what exactly?

worn mural
#

the code

#

how currently is

cinder olive
worn mural
#

Could you make a print(f"num1:{num1} num2:{num2}")

#

?

#

in the first line of the function

cinder olive
#

of what function exactly

worn mural
#

calculator

#

isnt the one

#

with problem?

cinder olive
#

i think that is the problem at least

worn mural
#

okk

#

make it print

#

so we can see with its beeing passed

cinder olive
#

i think the problem might be deeper

#

sorry i suck this is i think my 3rd day with flask

native tide
#

Are u making a calculator?

#

using flask?

cinder olive
#

yeah

#

yeah

native tide
#

did u* create a route?

cinder olive
#

yes

#

i made more things,only the calculator does not work

worn mural
#

I won't lie

native tide
#

@cinder olive Are u using math module?

worn mural
#

ur code doesnt look beautiful

#

Does any errors promp in the flaks debug console ?

cinder olive
#

i know i suck at this

#

no error

native tide
#

yo create a separe python for the calculator and import the stuff to the flask app

worn mural
#

what is the endpoint u are reaching to ?

#

/calculator/1/2?thing=+ ?

#

something like that?

cinder olive
#

yeah

native tide
#

He just need to create a another python file where is all the calculator and import that file to the flask app

worn mural
#

This is definely a good practice

#

but I'm not sure

#

if its going to solve

#

hes problem

#

@cinder olive is anything beeing hendered ?

#

rendered*

#

or the server is giving u any reponse?

cinder olive
#

of course it is,everything works outside of the calculator but i do not know where the calculator gets into a loop of asking me for a thing to input

broken linden
#

Hey everyone! How would I setup multiple workers for the flask app?

mellow tide
#

... -w <number of workers> ...

#

assuming you are using gunicorn lol

normal blade
#

Can someone help me with secret variables in django (using heroku and aws)

mint dawn
#

Is Visual Studio Code a good platform for web development?

normal blade
#

Yes I like it

#

@snow dragon bro thanks for helping me with aws vs heroku :)
Do you also have some django experience?

#

Like with secret key and stuff?

mint dawn
#

Thanks.

lethal orbit
#

VSCode is great

#

Especially for Django

mellow tide
#

generally what is your question @normal blade

lethal orbit
#

re: secret key, stick that in an env var, and use os.environ.get("SECRET_KEY")

#

But don't ask me how Heroku works...

mellow tide
#

on AWS, i prefer SSM to environment variables, but generally, yes 😄

normal blade
#

So my friend is using aws and heroku for deployment (we are a team of 3).. the thing is that you need secret key and debug and stuff (which he has setup) and we are adding that to our bash profile so that we can just call it
The problem is that I’m running a conda env (idk anything about it, one of my seniors installed it for me when I was learning python) and the bash profile is created there instead of /Users.. so I can’t access the bash profile and the secret key in it using SECRET_KEY = os.environ(‘SECRET_KEY’)

#

Like the conda env is (base) whenever I open terminal

mellow tide
#

so how is it defined in the profile? if you aren't exporting it, I'm not sure how that works lol

normal blade
#

@lethal orbit can’t access it from terminal, pretty sure it’s conda messing up

#

Sorry I’m bad at explaining cause idk anything tbh lol

#

Wait lemme send pics

#

And technically it should like call bash profile and get the key from there

#

And i export secret_key in my bash profile

#

And the aws keys as well

mellow tide
#

i mean, generally in your shell profile, you will have a like that looks like this: export SECRET_KEY=<my key data> which makes it available to anything that needs to call it on your system

normal blade
#

That (base) is conda, and it opens everytime I open terminal

mellow tide
#

so i don't think conda is messing up, i think you don't have your key anywhere on your deployed system

#

cat ~/.bashrc

normal blade
#

Shell as in bash profile or python shell?

#

Should I run cat thingy?

#

Again sorry for asking stupid shit

mellow tide
#

the "python shell" is actually called an interpreter, not a shell lol ... but yeah, bash, zsh, doesn't matter

normal blade
#

Oh well thanks

#

Can I dm? I don’t wanna show my bash profile here

#

Also cat bashrc says no such file or directory

mellow tide
#

lol don't blame you there ... but there is no need. If you need the key data to put into an ENVVAR in aws or whatever, you can just do echo $SECRET_KEY

normal blade
#

What’s does that do?

mellow tide
#

it would show you your key

#

i'm not sure what we are trying to get at any more lol

normal blade
#

Can I send a voice note?

#

Wait nvm no voice notes here lol

#

Also echo doesn’t show my secret key

#

Just prints a link without anything in it

mellow tide
#

prints a link?

normal blade
#

Line***

mellow tide
#

where is your Sr? I have no idea how you have that set up then lol

normal blade
#

So basically I created a bash profile using touch

#

I created it at the same place (the one I’m using currently)

#

Then I added the export aws stuff and the export secret key

#

That’s it

#

Ukw, I hardcoded everything.. just put the shit in the app and it works.. but still wondering why couldn’t I call it

mellow tide
#

well ... it seems like it's because it doesn't exist on the system anywhere to pull it from 😄

lethal orbit
#

Yeah, I'd help more, but I never used Heroku 🙃

distant trout
#

jinja2 is interfering with javascript code

#

is there any way I can fix?

#

python list (jinja2) is interfering with javascript arrays i think

lethal orbit
#

Do you use a JS framework? Does it have the same syntax?

uncut parcel
#

Ukw, I hardcoded everything.. just put the shit in the app and it works.. but still wondering why couldn’t I call it
@normal blade If its a lambda thing check the environment variables from the AWS console you can init python vars from lambda console or simply go into the .aws directory this should be inside your home hidden and check if there is a hidden directory str it should have the keys or the simplest thing to do is speak to your aws infra team

honest gust
#

In Django WebApp, I am using static/img folder to access the images... but when I try to create an object of class Product in admin... I am getting the above error. I have added static_root,static_url,static_dirs in settings.py.

#

Please help me out.

honest gust
normal blade
#

@uncut parcel its not lambda, but thanks for the info.. might help me in the future lol

#

and it is working fine for my teammates

quasi cave
#

Hello I want a requirement
As soon as I open my page I should see a popup window which contains some contact details..
Can anyone help me out?

uncut spire
#

greetings. are there any flask_restx users out there? gondor calls for aid, if so

lethal orbit
#

Hello I want a requirement
As soon as I open my page I should see a popup window which contains some contact details..
Can anyone help me out?
@quasi cave popup windows are lame and horrible. Use a nice front-end framework and use its modal component.

#

Lame and horrible, and blocked by most modern browsers.

#

But you gotta do that client-side, and it's not really python related.

quasi cave
#

Ohh

#

Okay thanks for suggestions

quiet comet
#

In django does anyone know how to block access to a view unless you fill a form and then redirect to the intended view?

Example: Im in page x and want to go to y but first i need to fill a form. The problem is that form should redirect to diferent views depending where it was click before. So from x to y i need to fill a form first and then from a to b i need to fill the same form.

Should the form url be like this form/str:option/ and then depending on the option i would redirect to diferent things?

marble carbon
#

well you can maintain sessions

#

and if the session key exists redirect to that view

quiet comet
#

hm so im on view x , set session , go to the form and then check the session and if it is there redirect to the intended view?

marble carbon
#

yeah

quiet comet
#

but if i need the form in a lot of views does that mean i will have a wall of ifs?

native tide
#

Anyone know how to integrate react on localhost:5000?

mellow tide
#

Lol @native tide - not really sure what you are asking.

native tide
#

All good. I found how.

By default the react app runs on port 3000 but you need to edit json file for it to run on port 5000

native tide
#

I miss using flask

#

Anyone looking for a good simple python web framework, try flask

brittle basin
#

Hi

#

I'm trying to create a container of a flask app I wrote

#

But I'm having trouble while building, with the requirements.txt

#

Before that I had pywin32==228 in the requirements.txt but I read that I should change it to pypiwin32==223

#

Any ideas how to fix that?

mellow tide
#

@brittle basin first, you should stop using pip v8

brittle basin
#

How can I add to the Dockerfile to install latest?

mellow tide
#

do you HAVE to use ubuntu:16.04?

brittle basin
#

No lol

#

What about:
FROM python:3.8-alpine

#

?

mellow tide
#

ok, then instead of FROM ubuntu:16.04, use FROM python:latest, then you don't have the do the python3, python3-pip etc.... in your dockerfile

brittle basin
#

Nice

mellow tide
#

but also, you CAN use alpine, but it has it's own problems

#

i'm not a huge fan of MUSL

brittle basin
#

I don't mind, I just want my simple flask container to run

#

i'm not a huge fan of MUSL
@mellow tide What's MUSL?

mellow tide
#

alpine uses MUSL instead of glibc

#

it's mostly compatible, until it isn't lol

brittle basin
#

Ok thanks mate

#

I need to clean my venv from garbage lol

#

When I tried locally it worked fine

#

Any ideas what I missed?

mellow tide
#

preferably you would be running the code with gunicorn or something

quick cargo
#

unless you want to get abused by the outside world

mellow tide
#
FROM python:latest

WORKDIR /srv

COPY . .

RUN apt-get update -y \
 && apt-get upgrade -y \
 && pip install gunicorn \
 && pip install -r requirements.txt

EXPOSE 8080

ENTRYPOINT [ "/usr/local/bin/gunicorn", "-w 4", "-b 0.0.0.0:8080", "app:webapp" ]
quick cargo
#

pretty sure just gunicorn would work because its in bin

mellow tide
#

yeah i'm sure, but i like to be verbose on those things lol

quick cargo
#

fairs

brittle basin
#

Thank you, I'll try that now

mellow tide
#

now granted, this is not production ready ... you should read up on running things NOT as root lol

quick cargo
#

Im very guilty of running my webserver as root

mellow tide
#

i use to, until i lost a k8s node because of it

brittle basin
#

I saw lots of examples using uwsgi instead of gunicorn, does it matter?

quick cargo
#

uwsgi is alright

#

a bit outdated i would say

#

has some lovely features on it tho compared to gunicorn

mellow tide
#

i like that gunicorn doesn't have a lot of bells and whistles

#

but i'm a minimalist as well lol

quick cargo
#

uwsgi is also very heavy on the processes side of things

#

last time i remember it would have a new process per IP until it hit a limit

brittle basin
#

It has init.py

mellow tide
#

is app/ the root?

brittle basin
#

How can I know?

mellow tide
#

did you just use my dockerfile from above?

brittle basin
#

Yep

mellow tide
#

without modifications?

#

lol

quick cargo
#

the old docker C+P mistake

mellow tide
#

if so ... you copied all the things into a directory called srv/ ... not app/

#

so python is correct, no module named app exists

brittle basin
#

Oh I see the WORKDIR

quick cargo
#

speaking of WSGI servers

#

does Gunicorn actually support http2?

mellow tide
#

good question ... i've only ever used Go with http2

quick cargo
#

seems it doesnt 🤔 aha! another advantage of my server :P

#

Tho atm i cant support http2 either because i went with fasthttp

#

considering switching back to hyper rs

mellow tide
#

OSS?

#

i would love to contribute to some rustiness

quick cargo
#

Ngl i have switched between Go and Rust atleast 8 times now

brittle basin
#

I changed to:
WORKDIR /app
But it still gives same result

quick cargo
#

I love rust but damn Go's channels just make it so much easier to make it performant

mellow tide
#

😄

marble carbon
#

nginx can do http2 tho

quick cargo
#

you wont get the benifit of it overall tho

#

HTTP/2 is only good if you can use concurrency with it

mellow tide
#

channels are nice for sure, but then again, so is MPSC and crossbeam

quick cargo
#

Im gonna hate myself if i switch now

#

Ill finish most of it in Go then probably add more to it with Rust

#

tho idk

#

ahhhh god i hate my inability to choose between the two

mellow tide
#

yeah, there are obvious reasons to use both, but the line is heavily blurred in that webserver area

#

i think i'm going to rewrite NGINX in Rust just for the lulz

#

but i'm going to use YAML for the configs lol

quick cargo
#

Like:

rust - Hyper

  • HTTP 2
  • Tokio rs (Instant multi threading usage with easy IPC)
  • Fairly slow to write
  • Really fun to write
  • Manually writing the websocket upgrade 😩

go lang - Fasthttp

  • No http2
  • amazing use of object recycling
  • amazing use of os threads
  • probably gonna limit some things
#

tho

#

i wonder if i could switch to Http2 between the worker coms

#

🤔 I wonder if that would boost the performance

#

atm its doing well sync, but concurrent. Seems like an idea

manic frost
#

I'm using aiohtttp to make a web app, and I want to use SCSS or SaSS. What's the best way to compile SCSS to CSS on file change?

warm igloo
#

Huh, never even occurred to me to use something python to transpile my SCSS. I just use npm and a package.json file to run SASS/SCSS, minifying, and other such front end things.

#

Or webpack if you need to get fancier

native tide
#

Why want to scass when u Have bootstrap and CSS and web design

ashen sparrow
#

I am trying to request same URL with different payloads, is it anyway I can do it in parallel? I am doing this on flask

native tide
#

hey guys, everyone makes a virtual environment and then they install djanjo etc why do they create a virtual envm?

acoustic oyster
#

@native tide 1. You dont want to have like 100 modules from random projects installed on your system, especially if they are old projects you do not work on.

  1. It makes it much easier for the project to be installed on another system. This is good for collaboration, but also having a dev and deployment environment
jagged lark
#

Also, two projects might need two different versions of the same module, and you can't have two inside the same environment

tranquil robin
#

Is it possible to have a flask WTForms widget that allows the user to select an item from a tree structure?
I have a folder like hierarchy (in a JSON like object), and I want to let the user select where they want to insert the item they are creating.

frozen relic
#

hi someone can help me with django issues?

frozen relic
#

hi there is a way of pass another atributeee beside request after render a template in django?

lethal orbit
#

If I understand your question correctly, you want to pass data from your view to your template using a context

frozen relic
#

mmm not so accurrate

lethal orbit
#

What attribute then?

frozen relic
#

like the 'form' of a view

#

i explain

#

i have a FormView and inside the method form_valid(self, form), i return

#

return codeview(self.request, form)

#

that way codeview can obtain all the methods of the formview

#

but if i render a template inside codeview i dont know how to pass the form atributte

#

i dont know if i explain it well

lethal orbit
#

i dont know if i explain it well
I don't quite understand 😅 ... But then again, probably not the best person to ask; I usually only use Django for APIs.

fallen mango
#

Can someone recomend best way to make an advanced login/signup page via django
Using crispy form or any other better library to implement email verification ,sign in via different social services and phone no. Verification etc..

lethal orbit
fallen mango
opaque sail
#

Hi, everyone. Can someone give ma hand to understan block content on my page because it does not seem to work like intended and I can't figure out why. It's django time

lethal orbit
#

Post the code, and maybe we can.

twilit dagger
#

Hello, I have an issue with Django models

I have a model Movie -

    title = models.CharField(max_length = 200)
    director = models.CharField(max_length = 200)
    cast = models.CharField(max_length = 200)
    description = models.TextField(default="")
    image = models.ImageField(upload_to = 'movies_pics')
    
    
    def __str__(self):
        return self.title```

And a model Listed - 
```class Listed(models.Model):
    Choices = ((1,'1'),(2,'2'),(3,'3'),(4,'4'),(5,'5'),(6,'6'),(7,'7'),(8,'8'),(9,'9'),(10,'10'))
    user =  models.ForeignKey(User, on_delete=models.CASCADE, default = "")
    movie = models.OneToOneField(Movie, on_delete=models.CASCADE)
    review = models.TextField(default="")
    rating = models.IntegerField(choices = Choices)

    def __str__(self):
        return f'{self.movie.title} Listed'```

I have made it so that a user can add a movie onto his list and then add a review and rating and create a Listed Model. I have a CreateView to make a new Listed model - 
```class MovieAddView(CreateView):
    model = Listed
    fields = ['review','rating']
    template_name = 'movie/movie_add.html'

    def form_valid(self, form):
        self.object = form.save()
        return HttpResponseRedirect(reverse('user-movies'))```

 The problem is that whenever a new Listed Model is made I need a way to pass in the current Movie model as well for the OneToOneField. Otherwise it raises an error of  - "NOT NULL constraint failed movie_listed.movie_id", because there is no Movie model being passed in. Can anyone help? Do I need to use a signal?
wet robin
#

Can I use the RESTful API to send a request from the server to the client, instead of the other way around, or do I have to repeatedly get requests on a while loop from the client, to the server?

weak lynx
#

Hi good day... I f i want to keep my site.db from going with the commit i will have to make a .gitignore with site.db/ inside?

#

or how would i make it?

#

thanks for all...

zealous siren
#

@wet robin you are looking for Websocket

wet robin
#

@zealous siren How can I achieve this?

#

with Django

lethal orbit
#

Hi good day... I f i want to keep my site.db from going with the commit i will have to make a .gitignore with site.db/ inside?
@weak lynx just create a text file called .gitignore with the following content:

site.db
zealous siren
#

No clue, don’t use Django

weak lynx
#

ok thanks

lethal orbit
#

@wet robin I think you can do that with django-channels

twilit dagger
#

I will shorten my question, how do I pass in a model into a OneToOneField in Django?

twilit dagger
#

What I'm trying to do is that there is as if there is an already existing Model1, and you click on it to enter a DetailView of that Model1, where you can create a new Model2 with the info of Model1

native tide
#

Can anyone recommend something for a beginner to learn Html and how to use Django?

marsh canyon
#

youtube is your best friend

limber laurel
#

To make a web based game is there a library I could suggest or should I make a game without extra packages?

lethal orbit
#

Depends on the type of game. There's webgl, some js libraries, js frameworks, etc.

patent shore
#

@native tide Colt Steele has a "bootcamp" for html and css. Look up netninja or any one of the other youtubers out there for django

undone fiber
#

Is pygame dead?

dapper tusk
#

no

#

also, probably wrong channel

delicate root
#

@native tide Corey Schafer has the best tutorials on YouTube.

#

@native tide CS50 with David Mallan

#

from Harvard

native tide
#

Thanks.

marble carbon
#

@delicate root more like brian tbh

delicate root
#

Yeah

#

This is awesome series on web development.

native tide
#

@delicate root What are u learning flask?

outer marten
#

My team and I want to make a web application that involves managing databases of grades.

Would Django or Web2py be the better choice? Those seem like the two best options

lethal orbit
#

Don't know about web2py (never used it), but Django is always a great choice.

outer marten
#

The reason I was considering Web2py was it's apparently specialized for databases

dapper tusk
#

for some reason, I am getting django CSRF errors on my webhost, but not on my local test, both are in debug mode. I think it is something with one going through WSGI and the other going through runserver

quick cargo
#

@dapper tusk when using the WSGI server it will go with the ALLOWED_HOSTS config in settings.py

#

if i remember runserver omits this

dapper tusk
#

I set that to the wildcard

quick cargo
#

oh Hmm

dapper tusk
#

I am testing it on the admin form, so it is probably some more elaborate error

#

turns out enabling https fixes that

quick cargo
#

oh lmao

left jungle
#

Hi everyone, some of you have seen the tutorial from free code camp, fcc, flask in 1 hour. there was this taskmaster project. I am making overkill version of it. That doesn't matter. But I wanted to know. What are the pros and cons of using flask wtforms and if I should use them.

#

If anyone wants source code to this working "family-system" pm me. Github repository soon

native tide
#

@left jungle flask-wtform is just forms

left jungle
#

I know, but is there anything better about them, then normal html forms?

native tide
#

they allow u to create a user profile pic

#

and they have function like if username is already in the database then u have to pick different username

#

flask-wtform works with databases really well

#

U can create a blog post using flask-wtform and flask-sqlalchemy

vague bison
#

Hi guys, I'm here because I'm planning to start learning Python and I can't find a good website I've used maybe 5 years ago? It was an interactive website with achievements and points and little projects... Could anyone help me?

mellow tide
#

!resources @vague bison

lavish prismBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

mellow tide
#

But to answer your question, there are a lot of sites like that, but I probably like excersism the best

#
sturdy pike
#

I had a question about inserting into sql tables. Sometimes I get a warning about duplicates. I was just wondering if that was an actual issue? It doesnt' seem to be duplicated.

zealous siren
#

duplicates is generally a sign of database schema mistakes

wicked tide
mellow tide
#

They look right aligned, center maybe ¯_(ツ)_/¯

native tide
#

Is it just the icon?

wicked tide
#

Nah bro the padding is messed up for some reason.

native tide
#

You could shift it using margins or padding manually

wicked tide
#

Check the link and inspect no idea what's doing it. I've been checking doc examples over and over looking for a difference

native tide
#

Nah is the icon

#

It’s perfectly aligned

#

That icon is just slightly bigger

mellow tide
#

What icon pack is that?

wicked tide
#

Material Design

mellow tide
#

Ah, even with material, I still use font awesome

#

Viewport is screwy on mobile fyi lol

wicked tide
#

I'm thinking of straightup not even supporting mobile for this thing, honestly. I'm just trying to get drawers working.

mellow tide
#

Lol, I get it

rain crow
#

!resources

lavish prismBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

mellow tide
#

?

rain crow
#

Looking at teeosices

#

Resources*

#

Sorry

wicked tide
#

shouldn't you do that in #bot-commands ?.....

mellow tide
#

Lol, does it really matter right now, 🍋 broke discord for a bit lol

wicked tide
#

fixed it

icy arrow
#

Hope I'm not changing the subject, but does anyone have any experience/thoughts on Firefox Developer Edition? I'm trying to avoid Chrome given poor privacy

wicked tide
#

I've been using it for a couple weeks. Not really noticing a difference, except for the minor mileage I get out of the custom extensions and scripts I run.

#

I think the dev menu got dark menu, but other than that I really haven't been noticing a huge difference. It's just Firefox with a different logo.

icy arrow
#

Interesting

zealous siren
#

I mean, you will have to look at your site in Chrome at some point

icy arrow
#

I know, but I've wanted to move my primary dev work away from it... maybe that's a lost cause, though

wicked tide
#

Then do it. What's stopping you? Choose the browser you want.

#

The ideal browser has shifted in recent years. It used to be Firefox, now Chrome, Opera, Edge and a couple other niche browsers are being looked at by modern programmers of the most niche archetypes.

icy arrow
#

Fair point! Thanks for your help

latent vessel
#

Chrome devtools are sometimes superior

#

But sometimes Firefox is better (css grid, for example)

heady ore
#

does anyone know the possible bottleneck of cosmos db (mongodb)? i have used Locust (100 user with 20 hatch rate) to test the loading of my site. the first one is "/" which is returning a "hello", and the response time looks fine. then I moved on to send the database connection test with collections.stats, the result looks fine as well. however when I testing the querying for simply getting all the 13 data(they're all small), the response become 13 seconds or even higher. do you have any suggestion for dealing with this situation?

#

will the RU setting become one of the issue for this. i set the RU with 400. not sure whether this is the main reason

zealous siren
#

Outlier are you exceeding your CosmosDB RU?

#

I use CosmosDB in SQL API for Discord bot and my average latency is 1MS

heady ore
#

i don't think i've exceeded the limitation. i checked the avg throughput(in the metrics tab) while running the loading test and the result was under 50, still far away from the setting I have which is 400

lethal orbit
#

I had a question about inserting into sql tables. Sometimes I get a warning about duplicates. I was just wondering if that was an actual issue? It doesnt' seem to be duplicated.
@sturdy pike this probably belongs in #databases and it's hard to know without seeing the actual schema/data, but maybe you have some DB constraints that prevent duplicates. https://www.postgresql.org/docs/12/ddl-constraints.html

covert kernel
#

how do i give the input got from a search page to a python file?

#

i am using flask

native tide
#

@covert kernel use flask request

dense slate
#

If I have a tuple with value:
('AM', _('Armenia')),

And my Django template is return 'AM', how can I make it return 'Armenia' instead?

dapper tusk
#

.label

#

IIRC

dense slate
#

Hmm, no dice.

bleak bobcat
#

It's a function get_something on the attribute, I don't remember the name exactly though

dense slate
#

In the template?

bleak bobcat
#

object.get_the-attribute-name_display()

dense slate
#

for example: {{record.get_state_display}} ? Because that doesn't do it.

#

adding the () throws an error

#

I thought I would access it like a tuple, like {{record.state.1}} or something.

#

but that just gives me the first letter