#web-development

2 messages · Page 113 of 1

native tide
#

my question is how do you mix django and python in a way to create the back end?

severe venture
#

django is python

#

that's like asking how do you water plants to get food. it all depends, but its hard to describe an abstract concept with specific details. if you just follow along on YouTube or find a code-along guide you should come to understand it.

#

unless you are asking about the specifics of how django works, because it might as well be magic

coral raven
#

Any flask users here?

cold haven
#

hello, not me

cold haven
#

Django?

broken abyss
#

Hi! How can i plug in Django {{form.as_p}} to styled input box that i have

#

nvm my question is stupid... {{form.as_p}} render form 🤦‍♂️

solid karma
#

does anyone know how to load scss using Flask and jinja

pulsar hinge
#

Hey, I'm creating 'custom' (i think) login and register form. The problem is that u can either login or register using the same page, they are separeted by js/css slide animation, so there is no option for antoher url. In views as it's one site, I had to make one function which is 'login', i put two forms in there, named differently, I'm making my register algorithm but after craeting user, it doesnt clear the form, and after F5 it sends the form again what is followed by message "Username already taken". The question is: Is it possible to make these two at one site without this form problem and making another algorithm for login in the same function?
Views.py
https://paste.pythondiscord.com/ekodigopaz.py

urlpatterns = [
    path('login/', views.login, name='login'),
]```

template 
https://paste.pythondiscord.com/qiseretolu.xml
spiral smelt
#

If I understand your question correctly, return a HTTPResponseRedirect to the same url should solve your "not clearing the form" problem

#

It's kinda like a reload of the login page

#

Also I guess your views.login has to distinguish whether the user is registering or logging in

topaz finch
#

I basically want to determine how much time it is taking for a request to be sent from one server to another. To do this, I am using the datetime module, and sending the current time of server 1, having server 2 give its current time as it receives the request, and sending it back so that I get the results. Problem is, the websevers are not corradiated in time (difference is around half a second). How can I either synchronize them, or go about this differently?

@ me when responding, please.

pine yew
#

@topaz finch Don't rely on the server you don't control. Time the function call using the timeit library or similar.

native tide
#

what do i do when i get a pylint(import-error)

pine yew
#

you fix the import error

native tide
#

yes

#

how do it do that

#

i'm using the wsl ubuntu terminal

worthy haven
#

pip install django ...

pine yew
#

wrong.

#

you're not using

#

the WSL image

topaz finch
#

I am trying to set up auto reconnection to my websocket server, so as a test, I intentionally disconnected from internet to see what would happen. I got this text in red:

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f42209bc880>
```How can I detect when the websocket is disconnected, if im connected from aiohttp? It seems to auto handle it, which isnt really helpful in this case..

@ me when responding, please.
pine yew
#

@topaz finch go to a help channel if you need help.

grim cedar
#

why use wasm ??

topaz finch
#

@topaz finch go to a help channel if you need help.
@pine yew I assumed that since this channel is in a category called Topical Chat/Help, and that the channel description says Help with web technologies, that this would be the best place to go for a web dev specific question.

vestal hound
#

@topaz finch go to a help channel if you need help.
@pine yew don't think there's anything wrong with asking here.

next rock
#

how can I get the parameters of a request in an aiohttp webserver? eg example.com/test/?paramA=1&paramB=2 when looking at example.com/test/ and the params are paramA and paramB

plucky tapir
#

What do you guys suggest for a Calendar type of visualization? to input bills for the month for instance. On django

vestal hound
#

What do you guys suggest for a Calendar type of visualization? to input bills for the month for instance. On django
@plucky tapir you mean like in terms of design?

#

or like how to code it

frozen python
#

Can I add Django Rest Framework to any Django project???

vestal hound
#

Can I add Django Rest Framework to any Django project???
@frozen python yes...?

frozen python
#

@vestal hound ok, so it’s not a certain Django project by itself?

vestal hound
#

no, it's an app

frozen python
#

@vestal hound so I can add it to my project i currently have?

vestal hound
#

yes

plucky tapir
#

@vestal hound design/which route to take.
Right now I have a bills table and CRUD with class based views and I’d like to just input the data into a calendar since I have a ‘due date’. But I’m not sure which calendar module or which is the best way to go about it.

vestal hound
#

@vestal hound design/which route to take.
Right now I have a bills table and CRUD with class based views and I’d like to just input the data into a calendar since I have a ‘due date’. But I’m not sure which calendar module or which is the best way to go about it.
@plucky tapir feels like a job for JS

plucky tapir
#

@vestal hound I need a rest framework api? Would you suggest JavaScript to a complete JS newbie

vestal hound
#

well

#

I mean

#

I learnt it just earlier this year 🤷‍♂️

#

and I'm generally of the opinion that more learning > less

devout coral
#

Anyone here have some testing knowledge with Django. I am running into an issue when running a test and it has force_login for the user.

rare zinc
#
import requests
from bs4 import BeautifulSoup

page = requests.get("https://api.hypixel.net/skyblock/bazaar?key=44ea43f3-662b-4fc5-bfb2-5314af99b1c4")

choice = str(input("What Minion do you wish to view the price of?   >>>   "))

if choice == "wheat":
    a = page.json()['products']['WHEAT']['buy_summary']['pricePerUnit']

why isnt this working it says

Traceback (most recent call last):
  File "c:/Users/Areeb Hossain/OneDrive/MS Files/Skool/TEJ200 - A/isu.py", line 27, in <module>
    a = page.json()['products']['WHEAT']['buy_summary']['pricePerUnit']
TypeError: list indices must be integers or slices, not str
cold latch
#

Hi y'all. I'm Alex, nine and I think django is cool! Ive been into python for more than a year and just finished the django tutorial. Can I get any recommendations on what to use to learn next. Thanks!

native tide
#

https://github.com/Abhinaba006/catdog
I have made a cat dog classifier model and it is implemented using flask, it is successfully running locally but crashing when pushed to heroku, please help me, all the codes are provided in the repo

devout coral
#

@cold latch I’d suggest you pick some web application you want to build and start building it. You will learn the most when there is no tutorial and problems come up. Good Luck.

orchid hill
#

guys can u give me suggestion on choosing backend?
should i choose django or nodejs?
I know python and js.

spiral oriole
#

@orchid hill Django is more secured by default and support basic MVP and useable stuffs. Node js is not secured by default as Django but it's more customizable what you want. It's up to you.
in my opinion, I like to use nodejs than Django.

broken abyss
#

Do django have any custom tag like {% csrf_token %} but only for error messages?

#

for example when my reset password form report that password is to common

#

or when i put wrong password during logging

nova nacelle
#

Do django have any custom tag like {% csrf_token %} but only for error messages?
@broken abyss You can prolly use a for loop in the template to display errors

orchid hill
#

@spiral oriole should i learn both nodejs and django?

broken abyss
#

@nova nacelle Thank you

vernal furnace
#

I'm wondering

#

Not sure if this is the right place tho

native tide
#

I am thinking of creating a chat applicaton in Django

#

what frontend should i use

#

angular vs react note I want to turn this into android app

vernal furnace
#

but how can I integrate google map with my django web?

silk girder
#
            print(element.text())```
#

is this correct

vernal furnace
#

anyone knows how to make it possible to send messages to certain users?

tardy heron
#

why doesn't this work? ```py
from flask_cors import CORS
app = Flask(name)
CORS(app, resources={r"/": {"origins": ""}})

native tide
#

I am hosting my discord bot on heroku with git, and ive never used git before so can someone tell me how to make 2 branches and test the bot on one specific branch before publishing to master, on heroku ?

#

@broken abyss You can do {{formfield.errors}}, is that what you're looking for?

#

or if it is even possible

#

@orchid hill you can have Django backend and JS (react) frontend and they can communicate via APIs

#

Pretty sure express and django are round the same popularity.

broken abyss
#

@native tide I did it like this

                    {% if form.errors %}
                      {% for field in form %}
                          {% for error in field.errors %}
                              <div class="alert alert-danger">
                                  <strong>{{ error|escape }}</strong>
                              </div>
                          {% endfor %}
                      {% endfor %}
                      {% for error in form.non_field_errors %}
                        <div class="alert alert-danger">
                          <strong>{{ error|escape }}</strong>
                        </div>
                      {% endfor %}
                    {% endif %}

I'm not happy with this but it work and look quite nice, I will gladly try your approach later as I just nuked my Postgres docker backedn

#

and I'm strugling to set it up again T_T

native tide
#

Yeah that's essentially the same thing but a loop, looks good 👌

umbral meadow
#

I want to create a simple SQL query with Django ORM missing catch.

In nutshell what i want is

SELECT COUNT(CASE WHEN mycondition THEN 1 ELSE NULL END)
FROM mytable

i tried writing that with annotations but django also creates a GROUP BY id in the query giving wrong data.

Details are here: https://stackoverflow.com/questions/63391064/django-orm-remove-unwanted-group-by-when-using-count

#

I want to create a simple SQL query with Django ORM missing catch.

In nutshell what i want is

SELECT COUNT(CASE WHEN mycondition THEN 1 ELSE NULL END)
FROM mytable

i tried writing that with annotations but django also creates a GROUP BY id in the query giving wrong data.

Details are here: https://stackoverflow.com/questions/63391064/django-orm-remove-unwanted-group-by-when-using-count
@umbral meadow I dont want exact code. Just want to know am i doing good with using annotations or m i missing something? As far as i have read its the default behavior of django to append a group by clause with a aggregated query but i want to get rid of that group by

pine yew
#

@vestal hound The reason for my response was they kept sending a vague question to the channel with a prompt to @ them

#

This channel is for discussion, not to throw your problems into the wind and have them solved for you

#

@orchid hill Asking to learn nodejs is like asking to learn Python. I think you mean express, or any of a number of frameworks built off of that versus Django. I'd say stick to learning one thing until you know it well enough to be proficient

#

You're trying to learn two competing technologies when you don't know one yet

native tide
#

guys which is the best place to learn django?

native tide
#

probably run through a realpython tutorial

#

then just start building something

#

@orchid hill Asking to learn nodejs is like asking to learn Python. I think you mean express, or any of a number of frameworks built off of that versus Django. I'd say stick to learning one thing until you know it well enough to be proficient
@pine yew
this but honestly, if you want to learn web you might want to just start with node not python. i love python as much as the rest of yall but lets be real learn one language not two. its literally what you said. thing is, front end has to be js. so just stick to js only until you know it then learn the python backend half

viral bear
#

guys which is the best place to learn django?
@native tide Corey Schafer's YouTube series

native tide
#

ok

#

thank you @viral bear

#

@umbral meadow use objects.filter

umbral meadow
#

@native tide i dont want to filter the objects.....i want to group them and find count. Its a totally diff thing

native tide
#

wdym by find count?

#

If you want to count the length of it... you can do len(objects.filter(arguement)) or you can set objects.filter(arguement) equal to a variable, then loop through the objects and do objects.count (if count is a field of your model)

umbral meadow
#

@native tide that's just a simple version of my query.

My main motive is to find out how many records are there which are added in the last 7 days, last 30 days and last 365 days. And I don't want to hit the database thrice for that.
That's why I asked just how to remove that group by clause.

#

I will be going to add other columns in my select statement but for the sake of simplicity I have just shown 1 column here

native tide
#

You can make one database query for that... and then loop through the objects depending on when they were added...

umbral meadow
#

Frankly speaking i just want to write a simple query to count diff things without a group by since there are all aggregate columns in my original query

#

You can make one database query for that... and then loop through the objects depending on when they were added...
@native tide

That's will be a bad approach. Why should I loop through each record. Its better to have a single query to get me all the different counts in a single go

native tide
#

Ok, so how else do you want to do it?

umbral meadow
#

Don't get into all those things.

I have worked with databases a lot. It will be much better to write a single query to fetch all the counts. This is the best way to do it.

I know how to do it in Raw SQL. But I want to write the same with Django ORM.

#

Why the heck it gives a group by clause. I don't want that. And it's jusy freaking my mind out.

#

Please go through my question on Stackoverflow. You will get a better idea of what I am saying.

native tide
#

I'm making a web app using reactJS and using backend as flask, and when I run my react APP, I get this error:
Access to XMLHttpRequest at (some random flask url) from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
even tho I have
CORS(app) in my flask script
how do I fix this ?

umbral meadow
#

@native tide i got this issue with my django application. Its becoz of the localhost. Its django has a library called django_cors_headers. Try if you can get something useful from its documentation

native tide
#

what do you mean by the localhost? Can you elaborate ?

#

If I use a ngrok server and hardcode the url in my react script, will it work ?

#

okay, this is embarrassing I solved the issue,
the thing is while using flask_socketio CORS(app) wouldn't work
instead, you have to do something like socketio = SocketIO(app, cors_allowed_origins="*")
and that fixed the issue.
A bit of intelligent search might have helped. Thanks @umbral meadow . The problem is indeed similar

limpid basin
#

Hey guys, wanted to ask if you like javascript as a language, and if anyone should learn it?

native tide
#

It depends on what kind of project/work you have to do. Suppose you wanna make a website or a wbapp, JS would be useful there

#

but sure, if you are interested then do learn

pine yew
#

@limpid basin If you're touching the browser in any form, JavaScript is useful knowledge to have.

limpid basin
#

Sure, and one more thing… is there any other webapp kind language that has kind of the same abilities?

pine yew
#

No, JavaScript is the only code that can execute in the browser.

native tide
#

yeah

#

There are some Fronted things like React, Vue, Angular which uses JS, but it's like what i'd say as enhanced JS

limpid basin
#

Ok

#

Thanks

native tide
#

@limpid basin yeah, JS is cool. Especially if you want to do it w/ web dev. React is v good

#

yeah

pine yew
#

@native tide Those are called frameworks. They're still JS.

#

Just fancy cascades of packages that run in your browser

native tide
#

yeah, yeah that's what I meant. Didn't get the correct word

#

but indeed

pine yew
#

when we code our language with magic, it makes things harder to understand, especially for newcomers

native tide
#

React > Vue > Angular

pine yew
#

lol no.

#

they each have their place

limpid basin
#

I quite know Python, html and css so i am thinking learning another language

#

So

native tide
#

you'll learn JS

#

well... do you know django/flask?

#

I know flask a bit

limpid basin
#

Noo, that is What i am thinking about too

native tide
#

oh

#

|| learn c/c++ ||

#

nooo 😭

#

I like them

#

any particular reason why?

#

many, I'll say a cuple

#
  1. Speed
  2. OpenGL
#

why speed you ask?

limpid basin
#

So should I continue with python and go with flask for instance

pine yew
#

Learn Rust

limpid basin
#

And then try JavaScript?

native tide
#

it's up to you

#

you wanna build a website

limpid basin
#

Just wanna know it

native tide
#

using flask or django, youll eventually have to learn JS

limpid basin
#

Ok

#

Thank you guys

native tide
#

👍

#

Just get good at one language without hopping to one another

#

Then look at others

#

They all do mostly the same thing anyway

pine yew
#

@native tide No you won't.

#

If you want your web page to be reactive, you'll need JS. But you can get by just fine using Jinja templating

native tide
#

yeah I mean

#

Jinja is great

#

but learning JS might be helpful

#

also while making a flask app, I use react as my frontend

#

which I like it

limpid basin
#

Ok

storm roost
#

hey guys, I'm about to get a project in which I'll have to develop a web-app and that web-app will have multiple sub apps (if that makes sense). I'm kinda confused about the backend because this app will scale massively. Is Django the way to go or should I develop this in .NET Core? (I know this is a python server but wanted your guys's opinion). And how should I handle this app in production? Break it down into docker containers?. Thanks in advance and do tag me 🙂

#

P.S the reason I was asking about .NET core is because my senior engineer is encouraging me to go with .NET on this one but it's still my call to pick the backend technology

native tide
#
data = {
                "notebook": Notebook.objects.get(slug=notebook_slug).pk
            }```
#

I'm making an API request with that data. I'm confused, how is my dict value a str and not a pk value?

#

nvm my JS was interfering with it

pine yew
#

@storm roost If it needs to scale to a large codebase, go .NET no doubt. Python becomes unmaintainable

storm roost
#

@storm roost If it needs to scale to a large codebase, go .NET no doubt. Python becomes unmaintainable
@pine yew hmmmm, thanks 🙂

pine yew
#

For reference, I build both .NET Core and Python/Flask webapps and the .NET ones are so much easier to come back to

storm roost
#

I'd have to learn .NET now lmao

#

For reference, I build both .NET Core and Python/Flask webapps and the .NET ones are so much easier to come back to
@pine yew hmmmmm, what do you mean "are much easier to come back to"

pine yew
storm roost
#

I mean you could do that with django too no?

pine yew
#

you can, but Python's ecosystem is duck-typed with annotations being optional so it's up to "good practice" instead of "enforced by the language" whether you know what a piece of code does

storm roost
#

hmmmmm

#

thanks for the input man

pine yew
#

no problem. FastAPI is a new framework I'm pretty excited about because it does enforce using the type system and automatically generates API docs for you

#

but I'm not sure I'd build some massive thing out of it, just REST APIs where I need them right now. The documentation is still lacking

storm roost
#

Is it a good idea to make APIs for that app and the front-end completely separate?

pine yew
#

Like most answers in webdev, it depends

storm roost
#

or not just for that app but rather apps like that

#

yeah that's true too

pine yew
#

when you host your frontend on a different domain than your backend, you end up with more complicated auth flows

#

but you can take advantage of static builds and whatnot

storm roost
#

Thanks for the input man, really appreciate it

pine yew
#

np

native tide
#

guys what should i learn if i want to manage servers and databases for my website

dark robin
#

HTML

#

JS

#

NOT python

#

CSS

#

SQL

midnight lava
#

So i'm making a rest api with flask, and i want to return all rows from a sqlite3 file in a json array. But I just get the error: "dictionary update sequence element #0 has length 4; 2 is required. " on the webpage. ```python
from flask import Flask
import sqlite3
from flask.json import jsonify

app = Flask(name)

@app.route('/todo/api/v1.0/tasks', methods=['GET'])
def get_tasks():
conn = sqlite3.connect('database.db')
c = conn.cursor()
result = c.execute('SELECT * FROM todos')
result = c.fetchall()
c.close()
return str(jsonify( [dict(ix) for ix in result] ))

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

quick cargo
#

@pine yew what you'll find with FastAPI is that all the internal frameworky stuff docs can be found at starlette's area

#

fastapi pretty much just document the stuff they've added not the framework underneath which is starlette

wanton tulip
#

Hello #web-development , has someone ever builded a front-end w/ Vue.js and a back-end w/ FastAPI? And what are your thoughts about it? Or have you worked with other frameworks in this type of structure? Thanks in advance.

quick cargo
#

yes

#

its pretty nice overall

wanton tulip
#

Thats what I was thinking too!, thanks for your answer.

#

@quick cargo Although there aren't any examples or documentation(s) relating to Vue.js + FastAPI, do you have any resources?

bright spindle
#

is it possible for a listview to return an argument to the html

#

in this codeblock, i want to somehow get the user.username value in get_queryset bundled with the return value, so i can use that to display what posts from username X is currently being browsed

class UserPostListView(ListView):
    model = Post
    template_name = 'board/user_posts.html'
    context_object_name = 'posts'
    paginate_by = 5

    def get_queryset(self):
        user = get_object_or_404(User, id=self.kwargs.get('id'))
        return Post.objects.filter(author=user).order_by('-date_posted')
swift sky
#

any good resources on integrating slack chatrooms into a flask app

#

?

halcyon lion
#

eyo boys can someone explain how do i pass multiple choices to a django model

#

models.CharField(choices=[])

#

not working 😄

quick cargo
#

@wanton tulip not really

#

its pretty sure vue doing the front end like any normal setup

#

and then fastapi handling the api data fetching etc...

smoky glacier
#

Hi, I am developing a site under Flask, I have a small aesthetic problem, when my pages load, the CSS loads a fraction of a second later, for a while we can see the site without CSS, someone knows where this to come? Thanks ❤️

pine yew
#

@quick cargo good pointer, thanks

#

I'm working on building a fastapi/vue project in my freetime, but I haven't figured out why poetry won't pack my build artifact into the fastapi public folders yet

quick cargo
#

never used poety tbh

pine yew
#

@smoky glacier Make sure you're loading your css in the head

halcyon lion
#

@smoky glacier yeah what @pine yew said 😄

quick cargo
pine yew
quick cargo
#

i litterally cannot tell weather its my pc causing the issue or the server itself 😩

pine yew
#

no connections?

#

what are you testing?

quick cargo
#

webserver ive been building for some reason it tops out at 1.6k req a sec and every request is a socket error

#

which doesnt make much sense because its a connection: close type response being tested

pine yew
#

why build your own? just to say you can?

quick cargo
#

pretty much

pine yew
#

are you sure your socket initialization is correct?

quick cargo
#

and to push Rust extensions

#

sockets n that are all fine from what i can tell

pine yew
#

well if your connection is always closed.....

#

sockets aren't fine

quick cargo
#

its not but that was refering to the HTTP response header

#

its gotta be docker i think

pine yew
#

so FastAPI is just built on starlette, aye? what does it provide? ergonomics and pydantic integration?

quick cargo
#

because HyperCorn's impl is definitely HTTP compliant and gets 17 req a sec

#

FastAPI basically is a wrapper for starlette yeah

#

it adds all the auto docs

#

all the validation

#

all the useful api stuff

pine yew
#

gotcha. I'm building a product at work on it because I'm tired of writing swagger docs

quick cargo
#

starlette is a lil too blank for me which is why i normally use Sanic over it

pine yew
#

and swagger docs are mandatory for APIs

#

also swagger api generation for python sucks. Connexion is abandonware

quick cargo
#

personally i prefer the reDoc system

pine yew
#

fastapi provides both

quick cargo
#

yeah

pine yew
#

my point is they're built on openapi, though

quick cargo
#

yeah, makes life easier

pine yew
#

I wish fastapi supported discriminators

quick cargo
#

biggest issue with FastAPI though is lack of class based views

pine yew
#

I can't find any resources on that topic yet

#

hm, I don't have enough state that needs to live with my views to necessitate class-based views

#

most of what I build are ergonomics wrappers around vendor products

smoky glacier
#

@halcyon lion @pine yew My custom CSS is in the head but it was not positioned first among my links. I just modified, the problem persists. It occurs during the first 5-6 page loads and then disappears, then returns after several minutes of inactivity. Do you think this is from my server which is slow to retrieve the CSS file? However the server has a good configuration. I'm a little lost, I don't know if it's my code or the connection latencies. (sorry for my english, google translate... haha)

pine yew
#

no, if you have a plain-jane style tag, it should be synchronous

quick cargo
#

probably browser caching it after the 6th attempt or so

#
class AnimeEndpoints(router.Blueprint):
    def __init__(self, app):
        self.app = app
        self.db: AsyncPgConnector = app.db

    @router.endpoint(
        "/api/anime/details",
        endpoint_name="Anime Details",
        description="The general endpoint for accessing any Anime details "
                    "from both the legacy and current branch of our database.",
        response_model=t.Union[DetailsOutCurrent, DetailsOutLegacy],
        methods=["POST"]
    )
    async def details(
            self,
            search: AnimeDetailsSearch,
    ) -> t.Union[DetailsOutCurrent, DetailsOutLegacy]:

        if search.legacy:
            details = await self.search_anime_legacy(search)
            return DetailsOutLegacy(results=details)

        details = await self.search_anime_current(search)
        return DetailsOutCurrent(results=details)```
pine yew
#

can you post your <style> tag for us?

halcyon lion
#

how do you load your css

quick cargo
#

my current lil router system for fastapi

halcyon lion
#

do you use static/css/css.css

smoky glacier
#

<link href="/static/assets/css/custom.css" rel="stylesheet" />

halcyon lion
#

or {% static %

#

try using {% static

pine yew
#

hm, that should be loading fine

#

@halcyon lion what are you even talking about?

quick cargo
#

he's talking about flask's url_for

halcyon lion
#

isnt it the same in flask 😄

pine yew
#

I know that

#

I'm not sure why he's talking about it

quick cargo
#

which wont matter cuz its rendered server side but meh

#

im curious if the browser is rendering the html before giving flask a chance to serve the CSS

pine yew
#

that would be odd. parsing the HTML should cause the css to be fetched before rendering

quick cargo
#

yeah

halcyon lion
#

frontend is dark magic 😄

quick cargo
#

just put a css delay on everything so you never notice it and it just looks like loading lemon_fingerguns_shades

halcyon lion
#

i had css not loading on a page where i literally do {% extend Qqqq %} {% load static %} while loading fine on the base page 😄

pine yew
#

but the point is

#

by the time it reaches your browser

#

it's already done all that

quick cargo
#

it'll be rendered

#

cuz server side

pine yew
#

your template isn't being rendered on the frontend

#

that's what things like vue or react would do

quick cargo
#

one of the reasons i like vue is the fact you dont need to have such a strict system for generating the html

#

like if you have a little bit of html that you want to make use of some simple AJAX a bit of vue is just simple

pine yew
#

I just like the logical way it separates concerns. style, structure, and behavior. Just like the base systems of the web

#

.vue files are really easy to consume for a reader

quick cargo
#

i hate this sort of debugging

pine yew
#

I wasn't a fan of the hypercorn/quart docs so avoided them

#

I wonder if flask will evolve to adopt the ASGI standard

quick cargo
#

probably not

#

flask works pretty well with grevent

#

Quart is pretty much a drop in replacement but isnt any faster imo

#

slower infact from the look

pine yew
#

yeah, doesn't seem to actually solve a problem. just gives people the ability to use async libraries without having to tap into asyncio

quick cargo
#

gives HTTP2 and HTTP3

#

while starlette etc... only support http1

pine yew
#

lack of completions with flask are what are driving me away. maintaining codebases in python is a nightmare

#

starlette has http2 support

quick cargo
#

only if you use hypercorn

pine yew
#

why do you need your framework to be a web server?

quick cargo
#

uvicorn which is the 'performant' server doesnt support http 2

#

hypercorn even though it supports http2 and 3

#

doesnt really give any advantages because its so much slower

pine yew
#

Uvicorn currently supports HTTP/1.1 and WebSockets. Support for HTTP/2 is planned.

Ah, I missed this statement.

quick cargo
#

you might aswell just use a reverse proxy like nginx todo http2 etc... and http1 between proxy and server

pine yew
#

I don't ever expose my web server to users either, though, my reverse proxy handles http/2 termination if it needs to (NGINX)

quick cargo
#

uvicorn and that have it easy 😩

pine yew
#

webdev is an onion.

quick cargo
#

they got their premade parsers, utils and everything

#

http 2 is gonna be a bitch

pine yew
#

I doubt I'll ever have to configure anything specifically beyond HTTP/1.1

quick cargo
#

doubt it

pine yew
#

everything internally probably still works on 1.0

quick cargo
#

at the end of the day

#

if nginx supports the newer versions

#

you're fine

pine yew
#

that's good enough, yeah

quick cargo
#

because is http2 really gonna make a large diffrence on localhost 🤷‍♂️

pine yew
#

I don't even have https on localhost

#

so 🤷🏽

#

but my work actively makes it hard to have such a case

#

since localhost is a windows host and certs are a pain in the ass there

quick cargo
#

also not the most likely thing that you're gonna have something doing an attack from localhost in the first place

worthy lake
#

If I have a CDN url that looks like https://media.somedomain.com/?t=ASDFG&h=ASDFG what are t and h most likely referring to? Token and hour?

quick cargo
#

random query parameters lemon_fingerguns

pine yew
#

good luck deciphering obfuscated query params

worthy lake
#

Mm.

pine yew
#

they will always be application-specific

worthy lake
#

Right

quick cargo
#

do we need to specifically close a connection with a keep alive delay if the connection doesnt explicitly specify in headers?

pine yew
#

!mdn keep-alive

#

ah fml, bad bot

#

I don't know off the top of my head, but I'm currently doing work-work so I can't research further atm 🙂

quick cargo
#

hmm doesnt seem like it

#

the things i would do for breakpoints rn 😩

#

ooh maybe its not unpausing the flow pithink

autumn hill
#

Hi, gunicorn nginx newbie here. I just deployed my flask app on server using sudo systemctl start nginx and it works just fine. But now I need to update my flask app abit. After making changes to the code, do i just restart nginx again to push changes to my production server or what?

pine yew
#

you don't raise pets

#

is how

quick cargo
#

you would restart gunicorn

#

nginx is just a proxy

autumn hill
#

Cool thanks

pine yew
#

gunicorn also has a --reload option I believe

quick cargo
#

yeah

#

though not le best when in prod

#

had some real 🤡 moments before from that

pine yew
#

@quick cargo any clue if you can transform incoming objects with pydantic? I have a field that matches a pattern, but I only need a piece of it

quick cargo
#

you mean like turn a set of data to a pydantic object or?

pine yew
#

like, when pydantic does its thing, can I transform the incoming object for a field

#

like a "hook" for a field

#

where I apply a function to it

quick cargo
#

you mean like a custom converter essentially?

pine yew
#

yes

quick cargo
#
class UserModel(BaseModel):
    name: str
    username: str
    password1: str
    password2: str

    @validator('name')
    def name_must_contain_space(cls, v):
        if ' ' not in v:
            raise ValueError('must contain a space')
        return v.title()

    @validator('password2')
    def passwords_match(cls, v, values, **kwargs):
        if 'password1' in values and v != values['password1']:
            raise ValueError('passwords do not match')
        return v

    @validator('username')
    def username_alphanumeric(cls, v):
        assert v.isalnum(), 'must be alphanumeric'
        return v```
pine yew
#

the main problem I have is the incoming object can be str or List[str] but I need to enforce one contraint

quick cargo
pine yew
#

Implementing OAuth kind of sucks

quick cargo
#

that what you want?

pine yew
#

exactly so, thank you

sly echo
#

Hi

#

Can anybody help me with a HTML code?

pine yew
#

it helps if we can see it 🙂

sly echo
#

@pine yew

#

So there are 2 problems

lavish prismBOT
#

6. No spamming or unapproved advertising, including requests for paid work. Open-source projects can be shared with others in #python-general and code reviews can be asked for in a help channel.

#

4. This is an English-speaking server, so please speak English to the best of your ability.

#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.

quick cargo
#

xD

#

get there in the end

pine yew
#

there we go. YT automation is against ToS

#

so we can't help you out, sorry

sly echo
#

This is a YT downloader guys

quick cargo
#

yes

#

which is why we're saying we cant help you

sly echo
#

Uh okay... sorry :(

pine yew
#

It's against this server's rules

autumn hill
#

though not le best when in prod
@quick cargo can you tell me/direct me to get best practices for production?

#

Messing up the server really haunts me tbh😅

native tide
#

hello coders

quick cargo
#

ehh, proper scaling (Gunicorn is 2*num_cpus btw) workers, no auto reload for accidental changes, max conncurent conenctions set. stuff like that

#

serving static files with a performance server not gunicorn or flask e.g. nginx

autumn hill
#

Ahh all right

#

What about restarting gunicorn in general? Do i use sudo systemctl start myapp everytime I change my code?

quick cargo
#

are you running gunicorn with systemctl

autumn hill
#

Yes...?

quick cargo
#

then yeah thats pretty reasonable

#

personally i put everything in containers but its personal choice

autumn hill
#

Hmm i see

sly echo
#

I have a question (won't violate anything)

#

I'm very bad at getting the logics. I see that you guys are pro in web dev and I suck at even the basics of python.
Have you seen Dr. Strange the movie? In that film Strange asks Master in the beginning that how can he grow from his place to the master's place?
Exactly. How can I, from the place where I am, match your level and grow even more?

#

How?

#

@quick cargo

#

And how long should I practice each day?
2 hours?

quick cargo
#

the rate you learn will be diffrent from others

#

just practice really

#

doesnt matter how long as long as you enjoy it and do it regularly

#

i tend todo about 8 ish hours a day after school

#

but thats cuz im sad

pine yew
#

!resources @sly echo

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.

pine yew
#

I tend to put an hour or two reading programming articles outside of work per day @quick cargo

#

but I have two kids, so time is short

quick cargo
#

fairs

sly echo
#

Thanks people

frozen python
#

I created a Django Rest Project, but it’s not allowing me to activate it. I do “cd Project, then source env/bin/activate then python manage.py runserver BUT NOTHING

plucky tapir
#

@vestal hound That is true about learning more. You or anyone have a JS module suggestion? For a calendar, perhaps I'll look into event-styled calendar

indigo kettle
#

@frozen python what do you mean, nothing

dense lotus
#

@vestal hound This channel right? Cookies' data type is basically string. I'm storing lots of data for unauthenticated users, so I landed with "just use a cookie"

vestal hound
#

yeah.

#

I mean

#

@vestal hound This channel right? Cookies' data type is basically string. I'm storing lots of data for unauthenticated users, so I landed with "just use a cookie"
@dense lotus but why?

#

have you considered

#

local storage?

#

localStorage

dense lotus
#

The server needs to access the data simulatneously... although I think I could probably access the data and send it via js...

vestal hound
#

The server needs to access the data simulatneously... although I think I could probably access the data and send it via js...
@dense lotus yes, you could

#

but other than that

#

well

#

I mean

#

you could come up with some way to compress your data

#

but @ that point I'm questioning your model

dense lotus
#

Yea I think the localstorage ajax is good enough. Can't believe I forgot about it...

#

so thanks!

vestal hound
#

yw!

twilit needle
#

guys I need some help here

#

so When an html button is pressed

#

I want to show a div

#

and when another button is pressed I want to hide it

#

is there anyway I can achieve this with pure python, html

#

I dont want to use js pls

#

ping me when help

#

thanks!

vestal hound
#

I dont want to use js pls
@twilit needle why?

twilit needle
#

because I think I dont like js

#

py > js

vestal hound
#

I don't think you can

#

without reloading the page

twilit needle
#

why not

#

Why isnt py supported

#

like js

vestal hound
#

well

#

because

#

long story short?

#

because browsers can only run JS

twilit needle
#

Oh no

vestal hound
#

because it's what's always been done

#

there are transpilers

twilit needle
#

But I cannot ask js help here its a python server

#

and I dont even know js

vestal hound
#

which basically take code you've written in another language and convert it to JS

twilit needle
#

;(

vestal hound
#

and I dont even know js
@twilit needle you can learn.

twilit needle
#

js is so confusing

#

man

#

you don't know

#

how hard it is to develop with js

#

its okay though, it will be nice if browsers run python

vestal hound
#

I do, actually

#

because I learnt JS myself earlier this year

twilit needle
#

I will learn then

vestal hound
#

to build the frontend for my startup

#

and I don't have a CS degree

#

so

twilit needle
#

I just realized that I might have to learn js too

vestal hound
#

I do know that it is hard

#

but it's not impossible.

twilit needle
#

I thought I could do the frontend with only python

pine yew
#

It's really not that hard....

twilit needle
#

rip

pine yew
#

As far as languages go

twilit needle
#

I am going to take a crashcourse

#

and try to learn js within an hour

pine yew
#

You will fail

twilit needle
vestal hound
#

It's really not that hard....
@pine yew it's hard in a different way

twilit needle
#

like the time it takes

#

with js is a lot

pine yew
#

🤷🏽 most languages are not hard in the average use-case

twilit needle
#

but the language processing is fast

vestal hound
#

weak typing is its own kind of confusing

#

e.g. default array sort behaviour

twilit needle
#

🤷🏽 most languages are not hard in the average use-case
@pine yew bruh

#

is there any server for js

pine yew
#

learn fundamentals, stop being a zealot.

twilit needle
#

Like JavaScript

#

yeah imma do that

vestal hound
#

ye there defo are

#

just go look around

#

you can probably Google it

twilit needle
#

one sec

#

Is this it

#

I just guessed

pine yew
#

No.

#

4,600 members: Doubt

#

Use the server explorer

twilit needle
#

whats TypeScript

#

please dont tell me I need to learn that

vestal hound
#

you know

twilit needle
vestal hound
#

Python type hints?

twilit needle
#

I couldnt find js servers

vestal hound
#

it's bascially JS with type hints

#

which is a good thing

twilit needle
#

so I can learn typescript for frontend

#

and no js?

#

right

vestal hound
#

TypeScript is a subset of JS

#

superset

twilit needle
#

but it works with browsers?

vestal hound
#

did you understand what I meant by this?

#

TypeScript is a subset of JS
@vestal hound this

twilit needle
#

yeah

vestal hound
#

and in particular

twilit needle
#

okay thanks

vestal hound
#

it transpiles to JS

#

so

twilit needle
#

I better go now and learn

#

thanks for the guidance

vestal hound
#

yw

twilit needle
#

am lost

#

the server doesnt even have help for website dev

#

;(

#

@vestal hound it turns out typescript needs to be compiled down to js to be used with html and css

vestal hound
#

no need to tag me.

#

and, yes, I said it was transpiled.

#

what did you expect

#

if, for example

#

you use a framework like Angular

#

it'll take care of that for you

frozen python
#

Does Django Rest Framework import Apps the same way? I created a app, but it can’t find the “module” AppOne

vestal hound
#

Does Django Rest Framework import Apps the same way? I created a app, but it can’t find the “module” AppOne
@frozen python yes

frozen python
#

@vestal hound ok, do I need to import it? It can’t find it

velvet haven
acoustic oyster
#

that is because it is the name of your account, that means you can use it to add details to your profile page

pine yew
#

no, it's for github pages

crisp hemlock
#

How much would you guys personally charge someone for creating a website? Buddy of mine needs a simple site made for his trucking company. Never did freelance work in web development before so no idea really

pine yew
#

Probably a few grand

crisp hemlock
#

a few grand?!?!

pine yew
#

easily

crisp hemlock
#

damn

#

i was thinking like

#

200-500 lol

pine yew
#

eh, I get paid a decent salary. if it's going to take you more than a week, a few grand is safe

#

everything is simple until customers start asking for features

crisp hemlock
#

Hmm, that price will scare him away i feel like lol. He said he needs a site with just basic info/hours/contact

#

basically a static site

#

no fancy features

pine yew
#

well, build one for fun, figure out how long it took you, and base from there

crisp hemlock
#

Yea will do

#

thanks

pine yew
#

don't underpay yourself.

crisp hemlock
#

Yea i just never had an opportunity to create a standard

#

for myself

pine yew
#

if he owns a trucking company, he can probably afford a few grand for a site. that kind of thing brings in revenue

crisp hemlock
#

Ive been thinking that too but im pretty sure its a startup

#

I dont think it actually exists yet haha

green snow
#

has anyone got travelo template zip file?

winter spindle
#

hey is it fine to keep a django app out side of django project

unkempt sentinel
#

@crisp hemlock why not create the website or free? and market yourself on his website, then you know how long it takes to make something like that and it the marketing Strat will probably lead to more clients

#

win win

plush leaf
#

I keep getting a "TemplateDoesNotExist at /" for Django, my template is there but it can't find it

#

I already set my joinpath to the template folder in settings.py

#

Could anything else cause this issue besides not having the BASE_DIR set up correctly?

tall plaza
#

Hi

#

There is list product with their view button.

#

So when I click on then then a pop up should come with their information

#

But I have done that part

#

Problem is that only one product information is showing on different view button

#

How to differentiate it

#

Like there are 3 product tv,mobile, furniture. So when I click on each product view more button then it shows only tv information

nova nacelle
#

Like there are 3 product tv,mobile, furniture. So when I click on each product view more button then it shows only tv information
@tall plaza Okay, there are two ways to do it. First, you can have a detail view for each product. But, if you wanna see the details without reloading the page or changing the url, you can give each product an id and use some js with that.

tall plaza
#

Yeah

#

I am using js

#

But problem is that it only capturing one product detail

#

I am using queryselectorAll

nova nacelle
#

can you share your views and template

#

?

tall plaza
#

Views rendering fine

#

I am only facing problem when I click on view button where it is showing same product detail on all products

#

I am using vanilla js

nova nacelle
#

can you show your js atleast?

tall plaza
#

Ok

#
         var openDetailButtons = document.querySelectorAll('[data-detail-target]')


         var closeDetailButtons = document.querySelectorAll('[data-close-button]')

         var overlay = document.getElementById('overlay')

        

      
            
   
         openDetailButtons.forEach(button=>{
            button.addEventListener('click', ()=>{
                    

                var detail = document.querySelector(button.dataset.detailTarget)
                console.log(detail, "this is the detail")
               

                openDetail(detail)
            } )


         })
     

         
    
        function openDetail(detail){
            if (detail == null)
                return 
            console.log(detail, "this is detected")
            
            detail.classList.add('active')
            overlay.classList.add('active')
     }

     
        
       closeDetailButtons.forEach(button=>{
            button.addEventListener('click', ()=>{

                var detail = button.closest('.details')

               closeDetail(detail)
            } )


         })

       function closeDetail(detail){
            if (detail == null)
                return 
            
            detail.classList.remove('active')
            overlay.classList.remove('active')
         }
       


        

    </script>
    ```
#

here it is html part```
{% for product in product%}
<button data-detail-target= "#details" class="btn btn-outline-success">View</button>

            <div class = "details" id="details">
                <div class="details-header">
                    <div id = "{{product.id}}"class="details-title">
                        {{product.name}} details
                    </div>
                    <button data-close-button class="close-button">&times;</button>

                </div>
                <div class='details-descriptions'>
                    {{product.description}}
                </div>
            </div>
            <div  id="overlay"></div>

{% end for %}

nova nacelle
#

Okay, so when you click on the button view for the product, you wanna show it's details?

tall plaza
#

yeah

#

but problem is that

#

only one product detail showing

#

please check html part

#

here for loop is also there

nova nacelle
#

Okay, just give an id to the view button in html using {{product.id}}
and also for the detail part

#

then run a for loop in js

#

like, when you click on the view of some id

#

it shows detail of that product

tall plaza
#

but how can i pick product id in js

#

?

#

i dont have any idea about js ?

#

here

#

this is code snippet of web dev simplified

nova nacelle
#

sorry, i got some work.

#

but how can i pick product id in js
@tall plaza just run a for loop as you do in in template

#

as far as i know and i've done

#

here it is html part```
{% for product in product%}
<button data-detail-target= "#details" class="btn btn-outline-success">View</button>

            <div class = "details" id="details">
                <div class="details-header">
                    <div id = "{{product.id}}"class="details-title">
                        {{product.name}} details
                    </div>
                    <button data-close-button class="close-button">&times;</button>

                </div>
                <div class='details-descriptions'>
                    {{product.description}}
                </div>
            </div>
            <div  id="overlay"></div>

{% end for %}

@tall plaza should it not be {%endfor%}?

tall plaza
#

yeah

cyan hill
#

what are some good resources for someone looking into web development? ive previously done some HTML,CSS and Flask but i was seeing what i could do to further my knowledge

tall plaza
#

freecodecamp

winter spindle
#

SError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'

#

what kind of error is this ?

#

in python

#

ii haven't even started to code

#

i just made a file and an app

frozen python
green snow
#

hi
can anyone help me find a zip file
i was learning django from telusko, in the tutorial he used template of a site called travello , which is no longer available for download.

lavish prismBOT
#

Hey @nova nacelle!

It looks like you tried to attach file type(s) that we do not allow (). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .svg, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .webm, .webp, .flac, .afdesign, .m4a, .csv.

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

nova nacelle
#

@green snow I'll send it on your DM.

green snow
#

that would be great ,thanks.

frozen python
#

Should my first app be named the same as my project?

digital hinge
#

hey all, mybe a simple fix but ive tried setup my flask script with wsgi and apache on windows, but when i run my script, the saved files go to the C:\Apache24 directory even know i have a path set in my vhost file and wsgi file:

# File name: web.wsgi
import sys, os, logging
logging.basicConfig(stream=sys.stderr)
PROJECT_DIR = "C:/Apache24/htdocs/flaskapp"
virtual_env = "C:/Apache24/htdocs/flaskapp/.venv"
activate_this = os.path.join(virtual_env, 'Scripts', 'activate_this.py')
exec(open(activate_this).read(),dict(__file__=activate_this))
sys.path.append(PROJECT_DIR)

from hello import app as application

Anyone know why?

<VirtualHost *:5000>
ServerAdmin email
ServerName localhost:5000
WSGIScriptAlias / "C:/Apache24/htdocs/flaskapp/web.wsgi"
DocumentRoot home=/htdocs/flaskapp
<Directory "C:/Apache24/htdocs/flaskapp">
<Files web.wsgi>
Require all granted
</Files>
</Directory>
ErrorLog "C:/Apache24/htdocs/flaskapp/logs/error.log"
CustomLog "C:/Apache24/htdocs/flaskapp/logs/access.log" common
</VirtualHost>

last steeple
#

@frozen python the project layout is wrong

jade lark
#

@frozen python the project layout is wrong
@last steeple No it's not. You can do the project structure this way. I wouldn't recommend doing it this way, but you can.

#

Is this the right layout for a Django Rest Framework?
@frozen python You can do it this way. I wouldn't recommend it. Once your codebase grows it is going to get very messy.

frozen python
#

@last steeple @jade lark that’s the way allot of tutorials show, I just moved the app into the main folder that holds everything, it works

jade lark
#

@last steeple @jade lark that’s the way allot of tutorials show, I just moved the app into the main folder that holds everything, it works
@frozen python Awesome. Keep going and learning. Worst case scenario you refactor the codebase as you go.

severe venture
#

is there a way to change the way a response is formatted when using a model in flask?

#

^my question, but this way I don't have to type it back out

frozen python
#

@jade lark but, is there a specific layout for Django REST framework vs just Django?

jade lark
#

@jade lark but, is there a specific layout for Django REST framework vs just Django?
@frozen python No there isn't. Django rest is just an addon to Django.

frozen python
jade lark
#

Much better.

frozen python
#

@jade lark so, I guess I’ll change, I think I “CD ..” in one part of my task, so I’ll add the app into the main folder then

swift sky
#

erm sooo

#

im trying to get a flash messages after using a send_file command

swift sky
#

im trying to get both a flash message and a send_file comman

#

however it does not show my flashed message until i refresh the page, but if i add the return statement, i have duplicate returns in the same function

#
    def survey_results():
        error = None
        connection = db_connection()
        cursor = connection.cursor()
        phone_survey = PhoneResults()


        if phone_survey.validate_on_submit():

            start_date = phone_survey.start_date.data
            end_date = phone_survey.end_date.data

            get_results = "SELECT upload_timestamp, email, terminal_number, was_this_a_pandemic_related_call,what_was_the_call, was_the_inquiry_resolved FROM phone_survey WHERE upload_timestamp BETWEEN %s AND %s"
            cursor.execute(get_results, (start_date, end_date))
            query_resolution = cursor.fetchall()

            df = pd.DataFrame(query_resolution, columns=['upload_timestamp', 'email', 'terminal_number', 'was_this_a_pandemic_related_call',
                                                      'what_was_the_call', 'was_the_inquiry_resolved'])
            df.to_excel('staffDashboard/output.xlsx', index=False)

            connection.close()
            cursor.close()

            flash("file downloaded")
            #return redirect(url_for('survey_results'))

            return send_file('output.xlsx', attachment_filename=f"{start_date}-{end_date}_survey_results.xlsx", as_attachment=True)


        return render_template("survey_reports.xhtml", form=phone_survey, error=error)```
velvet void
#

aaaaaagh

#

I need help

#
<html>
<head>
    <link rel="stylesheet" type="text/css" href="../static/css/style.css">
    <title>Chat app</title>
</head>
<body>
    </div>
    <div class="container">
        <div class="box-1">
            <img src="../static/images/icn.png" alt="logo">
        </div>
    </div>
    <form action="#" method="post">
        <div class="msg-box">
            <textarea name="chPut" rows="4" cols="180"></textarea>
            <button>⇨</button>
        </div>
    </form>    
    <div>
    {{MSGS}}
    </div>
</body>
</html>```
#

basically

#

Im having trouble making the backend for this flask chat app

#

I want to be able to add a newline every single time that the user posts a message

#

but im confused as to how I would do this with flask

#

I do know about the requests and stuff

#

but

#

how would I add p tags to this thing through flask

swift sky
#

Im having trouble making the backend for this flask chat app
@velvet void im literally doing the same thing

velvet void
#

so then help me

swift sky
#

if i can

#

why can't you just type <p> tags in the html?

snow sierra
#

hello all 🙂
i am using Django.
i want to use any 4 symbols [0-9][a-z] PIN code for each user..
any these PINcodes will be generate by me..

Question: need some good way for check pin if true Sign In... if not ("incorrect pin")

hope someone really understand what i am talking about..

thank you :***

mint folio
#

You can store the temporary code in a database?

native tide
#

anyone need help with javascript?

alpine lava
#

is there a good way of making a python browser game now?

#

something somewhat up to par with JS

#

for stuff like io games

#

or even just tile-based

#

I know there are ways but are there any easy ways?

plucky tapir
#

on Django, right now I have a transactions table, but I want to have like a savings/current balance type of thing going with my transactions. What do you guys recommend, is django oscar accounts recommended?

#

@native tide What method do you suggest for using JS to display charts (bar for instance) of my tables from a database?

vestal hound
#

on Django, right now I have a transactions table, but I want to have like a savings/current balance type of thing going with my transactions. What do you guys recommend, is django oscar accounts recommended?
@plucky tapir can you elaborate

#

like you want to be able to calculate the balance on demand?

plucky tapir
#

@vestal hound I believe so, as I enter in transactions, it would update the current balance.

vestal hound
#

@vestal hound I believe so, as I enter in transactions, it would update the current balance.
@plucky tapir materialised view

#

or else just recalculate balance each time you need it

plucky tapir
#

Would I have to create a 'balance' variable in the db table? Right now its, author transaction name amount date

vestal hound
#

nope

#

uh.

#

do you know how to perform aggregations in Django?

#

okay there are a few ways to do this

#

but the simplest, I think, is aggregations

#

look it up 🙂

plucky tapir
#

@vestal hound I sure will thank you

vestal hound
#

yw

swift heron
#

how would you go about running a function in html when you cant call a python function I am using the django framework

vestal hound
#

how would you go about running a function in html when you cant call a python function I am using the django framework
@swift heron access a route when the button is pressed

gaunt marlin
#

@swift heron if you want a function that run on page load then you can use custom template tag of django, else if you want the function to run on button press i recommend AJAX

swift heron
#

Ill look into it thanks to you both!

plucky tapir
#

@vital hare right now I'm looking at this, trying to pass cBalance as the total sum. Should I be returning it another way? ``` class TranListView (ListView):

model = transactions

def get_queryset(self): #gets only if user matches
    return self.model.objects.filter(user_id=self.request.user)

context_object_name = 'transactions'
transactions.objects.aggregate(cBalance=Sum('amount'))```
gaunt marlin
#

hello all 🙂
i am using Django.
i want to use any 4 symbols [0-9][a-z] PIN code for each user..
any these PINcodes will be generate by me..

Question: need some good way for check pin if true Sign In... if not ("incorrect pin")

hope someone really understand what i am talking about..

thank you :***
@snow sierra i suggest you would send a POST request on your form to a view to check if the PIN existed in database, if so then signin that user, else return message error

warm bay
#

I've been provided with a cdn, bucket name, access key and secret key. How do I send a request to fetch data with this information?

twilit needle
#
    def survey_results():
        error = None
        connection = db_connection()
        cursor = connection.cursor()
        phone_survey = PhoneResults()


        if phone_survey.validate_on_submit():

            start_date = phone_survey.start_date.data
            end_date = phone_survey.end_date.data

            get_results = "SELECT upload_timestamp, email, terminal_number, was_this_a_pandemic_related_call,what_was_the_call, was_the_inquiry_resolved FROM phone_survey WHERE upload_timestamp BETWEEN %s AND %s"
            cursor.execute(get_results, (start_date, end_date))
            query_resolution = cursor.fetchall()

            df = pd.DataFrame(query_resolution, columns=['upload_timestamp', 'email', 'terminal_number', 'was_this_a_pandemic_related_call',
                                                      'what_was_the_call', 'was_the_inquiry_resolved'])
            df.to_excel('staffDashboard/output.xlsx', index=False)

            connection.close()
            cursor.close()

            flash("file downloaded")
            #return redirect(url_for('survey_results'))

            return send_file('output.xlsx', attachment_filename=f"{start_date}-{end_date}_survey_results.xlsx", as_attachment=True)


        return render_template("survey_reports.xhtml", form=phone_survey, error=error)```

@swift sky sorry to interrupt

#

But is accessing a database like that good?
generally when you have a website like that you make use of a RESTful framework right

glacial wigeon
#

I am using flask for a toy project. I am implementing "forgot password" option. Currently I have it redirecting to the page for reset password through email. I would like to enhance this by making the user click "forgot password" and present two options as a popup - security question, reset via email and redirect the user accordingly. How do I do this in flask/python?

gaunt marlin
#

@glacial wigeon for popup you can use bootstrap modal to show 2 <a> anchor links to different views of secuirty question/email

glacial wigeon
#

Cool thank you.

native tide
#

@snow sierra store uses pins in database then compare if entered value is equal to what's stored in the DB? Use regex validator to restrict input

twilit needle
#

I want to logout my user in django when a button is clicked. How can I do this? Please help me.
I dont want to logout by redirecting to a logout page to prevent abuse.
what would be the best way to do this?

Also I dont mind using javascript somebody pls help me
thanks!

#
    <div class="config-container">
        <button type="button" class="logout-button" onclick="toggleLogoutModal()"><i class="fa fa-sign-out"></i></button>
        <button class="settings-button"><i class="fa fa-gear"></i></button>
    </div>```
#

The first button defined is my logout button

#

pls ping me when help!

nova nacelle
#

@twilit needle You can add a success url to the logout url that take you to the login page.

#

@twilit needle else, this should be your logout view:

def logout_view(request):
    logout(request)
    return redirect('login')
native tide
#

anyone can help me with some advice?

I want to develop a 2D CAD drawing program and I was wondering if HTML Canvas was the right option to use for the UI of the app. Anyone knows if it is my best option? Or if I could use something better than Canvas...

austere acorn
#

why does this fail to send a message to my webhook ? when I use 'content' it works fine but I can't send an embed

swift sky
#

is it supposed to be embeds?

noble smelt
#

Without quotes?

swift sky
#

just don't know if it needs to be plural with the (s)

#

idk anything about discord webhooks

#

just guessing

noble smelt
#

In the documentation it says embeds

swift sky
#

ouh, idk then good luck

proper osprey
#

Can someone help me with selenium?

maiden jolt
#

Hey,
I'm trying to modify a basic json file with python.
my JSON file :

{
    "ball1":{
        "xPos":100,
        "yPos":50,
        "color":[
            0,
            100,
            100
        ]
    }
}

I'd like to modify it by using the ID but i don't know how to modify the value deeper than ball1

import json

#Read and parse the json file
with open("..\\CommonData\\test.json", "r") as inputFile:
    jsonFile = json.load(inputFile)

jsonFile["ball1"] # modify xPos to 100
mint folio
#

Its just another dict, so you can do jsonFile["ball1"]["xPos"] = 100

maiden jolt
#

Oh, right! thanks

native tide
snow sierra
#

thank you for answers.

please, i need only one city and temperature, from any website or source..
which is short and better way ?

#

weather informtion i mean..

swift sky
#

just google weather api

native tide
#
def articleview(request, pk):
    blog = Blog.objects.get(pk=pk)
    comments = Comment.objects.get(post=blog)
    comment_form = CommentForm()
    context = {'blog': blog, 'form':comment_form, 'comments':comments}
    return render(request, 'blog-post.html', context)
#

i am trying to access the comments which have the post = blog

#

but i am getting error

#
DoesNotExist at /article/3
Comment matching query does not exist.
#

ping while answering

native tide
#

hi is anyone able to help me with discords oauth api lmk keep running into and issue

proper osprey
#
# Adding player
try:
    print('step3')
    add_player = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, 'list-input'))
    )
    print(add_player)
    print('step 3.1')
    add_player.send(player_name)
    print('step 3.2')
    add_player.send(Keys.RETURN)
    print('step 3.3')
except:
  driver.quit()
print('step 4')

This is with selenium, the driver randomly will literally get to the add_player.send(), and then skip everything else and move on. Output looks like this:

step3
<selenium.webdriver.remote.webelement.WebElement (session="d3364ffcca28171b3f143d5287a78815", element="ed15e142-fe85-427a-864f-7f3515be8b1c")>
step 3.1
step 4
#

*add_player is an <input>

winter spindle
#

Hey

#

i had an issue

#

even after i set my timezone in django it still shows utc when i run timezone.now()

#

how do i fix this ?

#

pls ping me

undone grove
#

Have u search on stackoverflow?

winter spindle
#

yeah yeah

#

i have searched but i doont seem to find a solution

#

like a guy have replied to tht

#

but i dont understand tht

#

@undone grove

undone grove
#

Emm,i've never use django before im sorry

winter spindle
#

wait should i send tht link

#

oh okay then

#

thanks

bright trench
#

quick internet quesion cuz ive lately been getting into it, domain is basically just the name and it forwards you to an ip with a port right?
[9:50 PM]
aka when you search for something.com it forwards that to whatever ip you want (copy pasted this straight from py general)

smoky glacier
#

Sorry for my english, I am using google translate.
Hi, I would like to know where I should start and what to look for to do this:
With Quart (Flask), I would like to display in real time the contents of a .json file stored on my server. If I modify the .json, then the content of my HTML page is edited in real time, without refreshing. But Quart, converted the data store in the .json to HTML. Thanks for your help and clarification. ❤️

candid lion
#

are there better ways to store numbers in the db than django-phonenumber-field?

native tide
#

Does anyone know how to change the route for pip installation?

#

I had to add a new folder to clean up my repo and I am struggling to install cors

#

@native tide in the terminal, do cd <directory-name>

#

Also are you trying to install cors for django?

#

I (think) I just implemented all of the functionality for my rich text editor 😳

#

@native tide Yay that worked

#

what's the error?

#

It's pretty huge

#

mostly saying about the path

#

make sure you're in the right directory when you runserver

#

I am in the correct directory

#

But because I added the DRF-Django folder to separate it from my DRF-React folder I think that is the cause of all my problems

#

in core

#

Ah, It was due to my cors.

#

It still had not installed correctly, so i ran ```
python -m pip install django-cors-headers

#

oh ok

haughty turtle
#

The rest framework is required when dealing with Oath2?

native tide
#

I need some help, I'm getting this queryset:
<QuerySet [<Group: gREkHm>, <Group: s9ychQ>]>
And I want to use it as a value for my object:
MyModel.objects.filter(some_name=val)
(val is the query set I got above), but how do I do that? It just doesn't work, I only get the last one...
I explained it bad I know but if someone understands what I mean please help

native tide
#

@native tide why don't you loop through your queryset (since it's a list)? I'm not too sure what you want to do

#

I tried to loop, but it only gave me the last value (s9ychQ), @native tide

#

Can you attach the code?

#

Like, I'm struggling to use the value I'm getting from the loop in the template

#
users_groups = request.user.groups.all()
for ug in users_groups:
    u = MyModel.objects.filter(some_name=ug)

When I print u inside the loop it works fine, but outside of it it gives the last one

#

It's like I know how to solve it but I can't

#

Yeah... because say you had a list ["a","b"] and then you looped through it, u would equal to "a" on the first loop and then on the second loop it would equal "b". So it will always equal the last one.

#

In your template you can loop through the list and show what you want to show (I don't know what that is as you haven't explained it).

#

Loop over u right

#

It got me confused already

#

Why would you want to loop over u? It only has one (of the two) values you want.

#

You understand why this won't contain both of your values, right? Or not?

for ug in users_groups:
    u = MyModel.objects.filter(some_name=ug)```
#
users_groups = request.user.groups.all()
context = {"queryset": users_groups}
render(<htmlfile>, context)

then in your html file, it's something like:

{% for group in queryset %}
 <div> {{group}} </div>
{% endfor %} 
#

What I want to do though is use the queryset I got as values for an object

#

object being a dictionary?

#

u = MyModel.objects.filter(some_name=ug)

#

This one

#
mylist = [MyModel.objects.filter(group) for group in user_groups]

Would list comprehension work?

vestal hound
#

u = MyModel.objects.filter(some_name=ug)
@native tide what are you trying to do?

#

from what I see of your code

#

I don't think that's how you should do it

#

you're going to run into N+1 problems

native tide
#

yeah I know I'm just trying out some things

#

@native tide try list comprehension

vestal hound
#

@native tide try list comprehension
@native tide like I said, N+1 problems

plucky tapir
#

There a way to easily round numbers? particularly using aggregation in django

native tide
#

I don't see how list comprehension would lead to that...

vestal hound
#

There a way to easily round numbers? particularly using aggregation in django
@plucky tapir Round

#

I don't see how list comprehension would lead to that...
@native tide one related queryset per object in the original queryset

plucky tapir
#

@vestal hound is it imported from a module?

#

Trying to round this context['cBalance'] = transactions.objects.filter(user_id=self.request.user).aggregate(Sum('amount'))['amount__sum'] or 0.00

haughty turtle
#

@native tide so you got a QuerySet of all obects, then you go and grab that object again in your loop by its name, are you not just doing double the work, and you say you want to print outside of the for loop, well of course its going to give you the last one as once you exit the loop u has stored the last variable.

vestal hound
#

@vestal hound is it imported from a module?
@plucky tapir there's a ROUND function in SQL

#

that is wrapped in Django Round

#

or if you want to do it in vanilla Python there's round of course

native tide
#

or // if you want to floor it

vestal hound
#

or // if you want to floor it
@native tide there's no division here though

native tide
#

oh lol i didnt look up

plucky tapir
#

@vestal hound in my views, tried this ```

class Round(Func):
function = 'ROUND'
arity = 2

context['cBalance'] = transactions.objects.filter(user_id=self.request.user).aggregate(Round(Sum('amount'),2))['amount__sum'] or 0.00
``` but got Complex aggregates require an alias

vestal hound
#

@plucky tapir okay, and then?

#

what do you plan to do

plucky tapir
#

I have it to display the aggregate sum although it does it to 10 decimal places rather than just two.
So if it’s 34.99
It’ll show 39.9900000000

I’m models it’s set to 2 decimal places

stable kite
#

@plucky tapir use .2f

haughty turtle
#

Eh why use DRF?

#

Every guide I read says it helps in converting to JSON but that seems pretty simple without a framework or is it not?

stable kite
#

@haughty turtle because it is an easy way to make an api in django

#

Every guide I read says it helps in converting to JSON but that seems pretty simple without a framework or is it not?
@haughty turtle it helps in a lot of things other than converting to json

haughty turtle
#

How does it help with Oath2?

#

@stable kite

stable kite
#

@haughty turtle I think it doesn't have any relation with oauth

haughty turtle
#

Whenever I search Oath2 it's always in relation to the DRF

stable kite
#

@haughty turtle no because Oauth is industry standard for authentication. DRF supports it with additional package

plucky tapir
#

@stable kite I'm never passing in string its a dictionary from the database made by DecimalField

stable kite
#

@plucky tapir sorry i misunderstood your question

#

check this out

#

if you want sum in float than why are you rounding it off

#

@plucky tapir try this```py
context['cBalance'] = transactions.objects.filter(user_id=self.request.user).aggregate(sum=Sum('amount'))['sum']

primal matrix
#

I am trying to match a curl post with requests.

#

Is this the right place to ask for help?

#

Anyone?

charred zinc
#

hello how can i pass a list of utf-16 encoded string in in post request?

#
import requests
resp = requests.post(
    "http://localhost:5000/predict",
    files={'file': ['इसका सीधा सा मतलब है की आज के bloggers और young']})

print(resp.text)```
#

I am getting this error if i run this

#
    fn, fp, ft, fh = v
ValueError: not enough values to unpack (expected 4, got 1)```
#
@app.route('/predict', methods=['POST'])
def predict():
    if request.method == 'POST':
        file = file = request.GET.getlist('file')
        if file is None or file.filename == "":
            return jsonify({'error': 'no input'})

    try:
        sent_list = file
        res = {'pred': test_model(sent_list)}
        return jsonify(res)
    except:
        return jsonify({'error': 'error in pred'})```
stable kite
#
import requests
resp = requests.post(
    "http://localhost:5000/predict",
    files={'file': ['इसका सीधा सा मतलब है की आज के bloggers और young']})

print(resp.text)```

@charred zinc i think you should pass files not string in the request

charred zinc
#

actually i want to pass a list of string only

stable kite
#

than pass it as data not files

charred zinc
#

oh how do i do that?

#

can i show the full error?

stable kite
#

you will need to change your flask code also

oh how do i do that?
@charred zinc ```py
import requests
resp = requests.post(
"http://localhost:5000/predict",
data={'data': ['इसका सीधा सा मतलब है की आज के bloggers और young']})

print(resp.text)```

charred zinc
#

thank you it solved that error but i am getting other errors now

#

let me try debugging it

stable kite
#

what error?

charred zinc
#
@app.route('/predict', methods=['POST'])
def predict():
    if request.method == 'POST':
        file = request.get_data('data')
        print(file)

    try:
        sent_list = file
        res = {'pred': test_model(sent_list)}
        return jsonify(res)
    except:
        return jsonify({'error': 'error in pred'})
    return jsonify({'result': 1})```
#
import requests
resp = requests.post("http://localhost:5000/predict",
                     data={'data': ['bloggers young']})

print(resp.text)```
#
(nlp) C:\Users\macer\Desktop\deploy_nlp\test>python test.py
{
  "error": "error in pred"
}```
#
@app.route('/predict', methods=['POST'])
def predict():
    if request.method == 'POST':
        file = request.get_data('data')
        print(file)
#

why isn't the print(file) statement not displaying the list?

tulip shoal
#

Sorry, wrong API, we're talking Flask, right?

charred zinc
#

yes

#

is it request.GET.getlist('data')?

#

i am a noob 😦

magic ingot
#

any idea why this isnt working?

#

Error: ```
FileNotFoundError: [Errno 2] No such file or directory: 'data.json'

acoustic oyster
#

hello, friends. My brain is tired. Does anyone know what could cause my django static files to stop working when using https? My site was fully up, but after using certbot to add ssl and force redirects to https, django cannot load any static files. Django is trying to load the static files over https, but this url does not work. I can manually see the static files if I force my browser to use http. I am using a reverse proxy as well as an ssl rewrite, I am not really sure what could be causing this issue. Any help would be EPIC.

red canopy
#

I have a form in flask-wtforms and it is extremely wide
I want to reduce the width of the Does the patient smoke and Age questions. This is the flask-wtforms code I am using:

class UploadForm(FlaskForm):
upload = FileField('Select an image:', validators=[
FileRequired(),
FileAllowed(['jpg', 'png', 'jpeg', 'JPEG', 'PNG', 'JPG'], 'Images only!')
])

smoke = SelectField(
    'Does the patient smoke?',
    choices=[('Yes', 'Yes'), ('No', 'No')]
)

name = StringField('Age')

submit = SubmitField('Get Results')

And in the HTML:

{{ wtf.quick_form(form) }}

But on mobile devices it isn't that big, so I need to decrease the width and still keep it centered but only for laptops and computers.

#

do you have any suggestions?

winter spindle
#

hey i get a template not find error for my django app
but apparently i think my routing to my html file is correct
idk it's giving an error

#

pls ping mem

native tide
#

i want to delete all entries in a table when the server is restarted

#

where to do this? i tried doing in app.py

#

but it says django apps are not loaded, then i did something which loads py import django django.setup() and then loads the models but still getting error

winter spindle
#

@native tide

#

hey i get a template not find error for my django app
but apparently i think my routing to my html file is correct
idk it's giving an error

#

can you help me with this one ?

native tide
#

have u registered the app in settings

winter spindle
#

yeah

#

all tht is dont

#

this is what i get

native tide
#

show your tree

#

directory structure

#

How to get post request body

#

request.body u mean

#

if its form data it will be in request.POST

winter spindle
#

oh okay

#

i will show my tre

native tide
#

ok

winter spindle
#
└───mysite
    ├───mysite
    │   └───__pycache__
    └───polls
        ├───migrations
        │   └───__pycache__
        ├───template
        │   └───polls
        └───__pycache__

#

this is my tree

#

@native tide

native tide
#

and in polls/template/polls/index.html is there

#

@native tide

#

it's a post request

#

can u show the view

#

what's that

#

the function

#

in views.py where u are trying to access data

#

i mean complete thing

#

that's all

#

what is request here?

#

oh lol u should've said its flask

#

check either request.data / request.form

#

I think it's data

#

yeah

#

idk much flask so yeah

#

i thought u were asking about django

#

I'll move onto django as well

#

soon

#

gr8

winter spindle
#
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader

from .models import Question
# Create your views here.

def index(request):
    latest_question_list = Question.objects.order_by('-pub_date')[:5]
    output = ','.join([q.question_text for q in latest_question_list])
    
    context = {
        'latest_question_list' : latest_question_list
    }

    return render(request , 'polls/index.html' , context)
    
def detail(request, question_id):
    return HttpResponse(f'You are looking at question {question_id}')

def results(request, question_id):
    response = "You're looking at the results of the %s"
    return HttpResponse(response % question_id)

def vote(request, question_id):
    return HttpResponse("You're voting on question %s." % question_id)
#

@native tide

native tide
#

is the index.html present at polls/template/polls/

winter spindle
#

yeah

native tide
#

also show ur INSTALLED_APPS in settings

winter spindle
#

oha okay

#

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls.apps.PollsConfig',
]```
#

@native tide

native tide
#

hmmm

#

idk i usually just put the application name

#

polls

#

like ```py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'chat',
'channels',
'userauth',
'sharededit',
]

winter spindle
#

what /

#

?

#

@native tide

#

i dont think we do it like this

native tide
#

i always do like this

#

never faced problem

#

maybe there are other ways

winter spindle
#

yeah

#

idk how do i make it work mahn

#

i am soo frstrated rn

native tide
#

whats ur templates in settings

winter spindle
#

nthin

#

it isnt set to anything

#

i havent set templates to anything

#

@native tide

native tide
#

hmmm

winter spindle
#

how should i set tht ?

native tide
#

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]```
winter spindle
#

what did you do here @native tide

native tide
#

this stuff is usually present in settings.py along with TEMPLATE_DIR or something

#

check that out on stackoverflow

#

i don't know exactly

winter spindle
#

yea yeah ok all this

#

oh okay then

green snow
#

guys

#

do u know why comparsion operator doesnt work in django?

torpid pecan
#

What is the best service for deploying a django app

severe venture
#

what is the difference between using @app.route(path) and using the api.add_resource(resource) in flask? is one better than the other?

stable kite
#

do u know why comparsion operator doesnt work in django?
@green snow wdym?

#

What is the best service for deploying a django app
@torpid pecan i think heroku ,pythonanywhere or aws

native tide
#

Hello, I need some advice.
I've been using Flask for quite a while and now I'm slowly expanding my Flask application with some extensions such as Flask-Limiter.
It has decorators like

@limiter.limit("1 per day")

So when I access that route more than 1x, I get ratelimited. My question is, what does

@limiter.limit("100/day;10/hour;1/minute")

do?

Thanks in advance 😄

stable kite
#

Hello, I need some advice.
I've been using Flask for quite a while and now I'm slowly expanding my Flask application with some extensions such as Flask-Limiter.
It has decorators like

@limiter.limit("1 per day")

So when I access that route more than 1x, I get ratelimited. My question is, what does

@limiter.limit("100/day;10/hour;1/minute")

do?

Thanks in advance 😄
@native tide it makes users to access your route as per limitation set by you

#

in your case 1 request per day

native tide
#

No, what does @limiter.limit("100/day;10/hour;1/minute") do? Not the decorator saying 1 per day

#

@stable kite

native monolith
#

Hello, can I use flask to make web like this?

  • upload image
  • select tickboxes /radiobuttons
  • return image and redirect after render (5-10 mins)
frozen python
#

I’m using Django Rest Framework, but, how can I use the API and also have the Admin? Right now, it only shows the API part. What path do I create for Admin?

native monolith
#
<!doctype html>
<title>Hello from Flask</title>
{% if name %}
  <h1>Hello {{ name }}!</h1>
{% else %}
  <h1>Hello, World!</h1>
{% endif %}

whats the difference between {} and {{}} ? 🤔 or is it {%%}

stable kite
#

No, what does @limiter.limit("100/day;10/hour;1/minute") do? Not the decorator saying 1 per day
@native tide for that you should see it's documentation

#

I’m using Django Rest Framework, but, how can I use the API and also have the Admin? Right now, it only shows the API part. What path do I create for Admin?
@frozen python add this into your root urls .py

path('admin/', admin.site.urls),```
frozen python
#

@frozen python add this into your root urls

path('admin/', admin.site.urls),```

@stable kite I did but it says “module “admin.QuickStart” “has no attribute “site”

stable kite
#

@frozen python have you imported admin package?

frozen python
#

@stable kite yes

stable kite
#

can you post your urls

frozen python
stable kite
#

@frozen python you have two imports name admin

frozen python
#

@stable kite do I get rid of one? It’s not working

stable kite
#

@frozen python yes get rid of quickstart one

#

and uncomment the path for admin

frozen python
#

@stable kite it worked!, but it’s not going to the api page at api-auth, it comes up as a error

stable kite
#

@frozen python what error?

frozen python
#

@stable kite well, the api is coming up at 8000, but when I try the path url of “api-auth” it comes up with the “tried these paths in order” error

stable kite
#

can i see your error?

native tide
#

@native tide for that you should see it's documentation
@stable kite I did.

stable kite
#

@native tide then?

native tide
#

There's no information regarding that

#

I already did that before I asked the question

stable kite
#

can you share the link of documentation?

native tide
stable kite
#

@native tide it is multiple limitations

native tide
#

I already know that but how would that work in detail?

#

I appreciate your efforts but it looks like you try to help me without understanding it yourself

stable kite
#

ya because i don't use flask

native tide
#

With all due respect, please don't try to help if you don't know anything more regarding the question than the person who asked the question

stable kite
#

ok

tight pilot
#

Is there a way to get different styles for fenced code blocks and indented code blocks when using markdown?

icy galleon
#

Guys, i have an html table which has dynamic row number. I need to transfer its data to js in order to transfer it to python. How can i take html table data to vue as matrix or array format?

native tide
#

how to get the discord colored embed? # Hello World print ("Hello World") print(type("Hello World")) print(type("Hello" + "World"))

#

im new im sorry

spiral smelt
#

Add py or python after the ```
```py

Hello World

print ("Hello World")
print(type("Hello World"))
print(type("Hello" + "World"))
```

slow rapids
#

Hello. Tried to use retrieve a product by id but Im getting an error.

@app.route('/product/<id>', methods=['GET'])
def get_product(id):
    if id is None or not id.isdigit():
        return jsonify({'result' : 'Missing ID!'}), 404
    return Product.objects(id=id).first()```
> mongoengine.errors.ValidationError: '1' is not a valid ObjectId, it must be a 12-byte input or a 24-character hex string
native tide
#

So I'm trying to learn web development off a book that works with html, js, and php. The problem being php is dated. Is there a way I can use the <?> tags but put python in it instead to run server side?