#web-development

2 messages · Page 222 of 1

obtuse robin
#

just use a form

#

in html

#

and get the info from the form in the python end

#

that little move of the images pisses me off so much 😭 idk what to do about it

trail axle
#

thanks

little ice
#

Hey guys, one question.

#

And that would redirect to a discord server invite.

marsh minnow
#

Bump

autumn tendon
#

hello

tropic blaze
#

Hey I am learning Django currently and wanted to turn the background color for my homepage blue and also render an image but am unable to do so. Any help would be appreciated.

upbeat zinc
upbeat zinc
tropic blaze
upbeat zinc
#

Press Ctrl+F5 (If that doesn’t work, try Shift+F5 or Ctrl+Shift+R).

upbeat zinc
#

btw look in dev tools, are static files are collecting successfully?

tropic blaze
#

What was I doing wrong?

upbeat zinc
#

nothing, you have to refresh cache

void geyser
#

Hi

#

I am also a web dev...

#

(Just started building some websites and hosted it on gitlab)

unique shore
#

nice

pallid lily
#

Which is better Framework and will be more popular in next 5 years Django or FastAPI

unique shore
#

FastAPI is growing in popularity fast but Django is likely going to be here forever

opal rain
lapis rivet
#

Long shot - anyone here use JS & PYTHON to script/automate in Microsoft Excel?

kindred void
#

i need to index all files in this url like search engines but how possible it is?

if i try bruteforce, there is need to try 37^29 possibilty

zinc lagoon
#

could some one help in #help-donut for an issue regarding to django would be greatly appreciated

pseudo spire
inland oak
#

yes

#

you can use almost ANY (from any language) backend framework with almost ANY frontend framework

#

as a rule they all follow generic www compatibility

#

I mean... almost any backend framework can be turned into REST API at least

#

Which will make it already compatible with frontend frameworks

#

Flask can do it in wheel reinventing way, or in Flask-restful library way

#

anything

#

I would recommend using React or Vue.js in general

#

at they are the most stable and library rich ones

#

I would recommend reading the book Head First Javascript

#

without basic of understanding of JS, it would be a bit not cool to go further

#

because in the end it is just Vanilla JS that does all of it

#

React/Vue.js are just wrappers to simplify the same process

#

Usually people use Axios library to make requests to backend

inland oak
#

Up to you. Up to you. The book I recommended is definitely best grade material. You will have hard time to find equally good video materials

stable bear
#

if there are two post requests going to the same route in flask, is there a way to differentiate between the two?

inland oak
#

you are meeting them in backend, where you have full programming language python access

#

you can differentiate them based on ANY criteria you make

dusk sonnet
#

Hi, in Django when i give a field a class name i cant access it in CSS to style it why is that?

    create_page_title = forms.CharField(label="", widget=forms.TextInput(
        attrs={
            'placeholder': 'Enter the title of the entry here...',
            'class': 'title-create'
            }
        ))
hoary spoke
#

how can I make an app that open websites in it such as gmail, google,..

rigid laurel
#

!docs webbrowser

lavish prismBOT
#

Source code: Lib/webbrowser.py

The webbrowser module provides a high-level interface to allow displaying web-based documents to users. Under most circumstances, simply calling the open() function from this module will do the right thing.

Under Unix, graphical browsers are preferred under X11, but text-mode browsers will be used if graphical browsers are not available or an X11 display isn’t available. If text-mode browsers are used, the calling process will block until the user exits the browser.

hoary spoke
#

ah thanks!

past dove
#
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style2.css">
    <script src="style.js"></script>
    <script src="https://kit.fontawesome.com/19340be48e.js" crossorigin="anonymous"></script>

</head>
<body>
    <div class="wrapper">
        <!--Top menu -->
        <div class="sidebar">
           <!--profile image & text-->
           <div class="profile">
            <img src="logo2.png" alt="profile_picture">
            <h3>User Guide </h3>
            <p>Business Owner</p>
        </div>
            <!--menu item-->
            <ul>
                <li>
                    <a href="#" >
                        <span class="icon"><i class="fa-solid fa-house"></i></span>
                        <span class="item">Home</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <span class="icon"><i class="fa-solid fa-download"></i></i></span>
                        <span class="item"> Application programs</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <span class="icon"><i class="fa-solid fa-network-wired"></i></span>
                        <span class="item">Computers and Networks</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <span class="icon"><i class="fa-solid fa-print"></i></span>
                        <span class="item">Devices and Network</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <span class="icon"><i class="fas fa-database"></i></span>
                        <span class="item">Data Traffic</span>
#
</a>
                </li>
                <li>
                    <a href="#">
                        <span class="icon"><i class="fa-solid fa-globe"></i></span>
                        <span class="item">The Suitabe Network</span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <span class="icon"><i class="fa-brands fa-windows"></i></span>
                        <span class="item">The Suitable Computer System </span>
                    </a>
                </li>
                <li>
                    <a href="#">
                        <span class="icon"><i class="fa-solid fa-address-book"></i></span>
                        <span class="item">Contact us </span>
                    </a>
                </li>
            </ul>
            <div class="section">
                <div class="top_navbar">
                    <div class="hamburger">
                        <a href="#">
                            <i class="fas fa-bars"></i>
                        </a>
                    
                    </div>
                </div>
    
            </div>
        
</body>
</html>
formal bronze
#

How to create a default disabled option in django dropdown list?
I have done this
category = forms.CharField(label="", widget=forms.Select(choices=categories))

midnight phoenix
#

I'm trying to deploy a small Flask REST-API on a Digital Ocean cloud. To make it simple I've dumbed it down to this, but I can't access this either. When I access the server_ip_address:8081/hello/ I just get network timeout. I have open the port on the ubuntu firewall. Any hint what I might be doing wrong?

from flask import Flask, request
from flask_restful import Resource, Api, reqparse

api_config = {
    "host": "server_ip_address",
    "port": 8081,
    "debug": True}


app = Flask(__name__)
api = Api(app)


class HelloWorld(Resource):
    def get(self):
        return "success", 200
        
if __name__ == '__main__':
    api.add_resource(HelloWorld, '/hello/')
    app.run(**api_config)
midnight phoenix
unique shore
#

go port 8000

#

also, I have never seem Flask with classes. is this some sort of like MVC-like method?

#

(i know its not exactly MVC but it reminds me of it)

midnight phoenix
#

Idk. what MVC means
This is from flask-restful which is a library for REST APIs.
I found it really helpful.

unique shore
#

yeah I know flask_restful. i have used it before

jade minnow
#

you ever just try and make something with javascript and it just doesnt work but if you did it in python it would

midnight phoenix
unique shore
#

also, MVC (model view controller) is a design pattern for making APIs

jade minnow
unique shore
#

his port 8080 is occupied :p

jade minnow
#

ohh

#

all my other ports i can think of are occupied

#

of just random css tests because i never turn off live servers

unique shore
#

it might be the host. I'm not sure if "server_ip_address" is a host. I have never seen it before, correct me if it is

#

also flask_graphql when

jade minnow
unique shore
#

oh ok\

midnight phoenix
unique shore
#

I've just always used localhost, so I'm kinda oblivious to other hosts

jade minnow
#

and easier to manage

unique shore
#

I think he is deploying

jade minnow
#

yeah then dont do htat

#

unless u want to debug

iron tusk
#

I want start do my own website:
Is there a equivalent to a IDE for web design where I can directly see what my website looks like with this html file I have right now?

native tide
#

Like... it reloads the page automatically everytime when u make any sorta change in the html file

#

Im till not sure if you're looking for this.. but give it a shot

iron tusk
#

what would be the opposite to real-time in this regard?

native tide
#

💀

native tide
#

I googled this lmfao

iron tusk
#

i mean more like in the sense of why would i want it not real-time? avantage-wise?

native tide
#

Eh.. can ya VC? Im lazy to type lol

#

Text**

fallen basalt
frank shoal
#

I think I've fallen in love with vue's <script setup> sfc tag.

unique shore
#

🗿

candid kestrel
native tide
#

Hi! I've setup a Flask server following the tutorial on the docs. I have a problem when running the server with flask run during development. It takes about 2 mins for the first request to get through to the server being logged, the browser I'm using is the latest chrome version. It's only the first request, the following requests aren't having this problem. Has anyone else experienced this issue aswell? Running everything on a Macbook pro M1 PRO Max.

feral widget
#

hello

#

i need help

#

anyone online who has experience in HTML & mabye css

austere cairn
#

How could i make a custom ratelimiting system for flask where i can make api keys that get limited instead of the ip that gets limited

lethal junco
wooden ruin
fickle basin
#

Hello, can anyone tell me why my templates render differ from browser to browser (police color for example)!

shell ermine
#

What templating engine do you use?

#

Also, when it comes to css, some browsers render things differently from others

#

And some browsers need a different css code for the same function

thin minnow
#

In a HTML file I want to divide the page into a grid, and each grid thing changes colour every second. Each grid being a different colour

fickle saddle
#

Have someone seen this error before? I have django-stubs but doesn't work 😦

robust whale
#

Sorry my discord crashed and was unable to find your message again 😅

#

To me this looks like it's just type hints of your editor that cause an issue here. If you execute your code it should work without a problem. Is that the case?

#

So the Django static urlpatterns seem to be using the type hint

typing.List[URLPattern]

To avoid the issue, you could do the same by annotating your list:

from typing import List
...

urlpatterns: List[URLPattern] = [
...
]

small furnace
#

Discord glitch OP

errant locust
#

My goal is to make a photo gallery (for offline personal use currently) where I can sort the pictures by tags I assign to them. How would I get started making such a website? (And I am trying to avoid using services like SquareSpace etc.)

native tide
#

is django rest framework part of django or is it third party ?

wet hinge
#

@native tide DRF is done by Encode OSS Ltd, Django is done by Django Software Foundation

#

not sure whether they overlap

#

question: are rabbitmq, redis, celery, kafka interchangeable? do they serve the same purpose?

pallid tulip
#

I try to register 2 filters in the same file

#

but it only registers the first one

#

anybody knows why?

#

nvm i found out why
you load the file name not the function

knotty wren
#

i have started web dev

#

and i have just learned html and css

#

what to do now

#

i mean

#

i will start learning js as well

#

but how do i use python in building web apps

#

any idea?

unique shore
#

It’s mainly used on the backend

#

Flask and Django can serve static files though

#

And you can use frontend JS framework with them

knotty wren
#

ohh

#

thanks for sharing

native tide
#

Does anyone know where I can get a free .com domain.

unique shore
#

you can’t get a free domain afaik

#

SSL/TLS certificates and the domain cost money

native tide
#

Other than freenom?

unique shore
#

don’t know what that is

autumn flicker
autumn flicker
#

thats basically impossible

wet hinge
#

@native tide I've heard that after you give heroku your card data, they give you some benefits regarding customizing your domain, not sure if they do offer what you want tho

viral pine
#

Gay

unique shore
#

You still have to buy Dynos to get the custom domain and such

wet hinge
#

I see, thanks

wet hinge
autumn flicker
#

and cloudflare u can have it online 24/7 with its rules

wet hinge
native tide
#

hello
i try to use by window command with "python manage.py runserver" and error is "unreoconized command" Can someone help?

wet hinge
#

if linux then you might have to write "python3" instead of "python"

native tide
#

ohh

#

nope

wet hinge
#

are you in a directory that has manage.py file?

native tide
#

no

#

its me ok its work

#

sorry

wet hinge
native tide
#

no the probleme was i writ pyhton instead of

#

python

wet hinge
#

ahh ok 😄

native tide
#

thx

#

sorry

wet hinge
#

no problem, good luck

native tide
#

i try to add code to urls python.pyc to add new page in ly web site but now nothing work anymore

#

in pycache

#

i don t know why

wary niche
#

Does anyone know how I can remove these messages from my sign up form in Django?
I only use UserCreationForm() for the userform

fast bane
#

Hey any one can suggest a simple web project using django

native tide
#

whats the docs for flask? and is their a tutorial i can follow on it maybe Corey Schafer has one not sure.

fathom fjord
#

yo

frank shoal
#

In a vue setup sfc, is it possible to get $router or $el?

formal swift
flat bronze
#

i need someother api for tts

slow moss
#

Hey guys

#

how can I connect python to HTML

frank shoal
frank shoal
slow moss
#

I wanna merge python with HTML

fickle saddle
frank shoal
#

or you want to use python in a html <script lang="python"> tag?

slow moss
#

No , I have written html code , and now i wanna use if statments in HTML using Python

#

like if... <p>lorem...</p>

#

or if password == repassword

#

write logged in successfully on the screen using html

pallid lily
#

Hello is there a down side to using Profile._meta.get_fields()

#

I'm building my own serializer since the one in django is pretty much slow

unique shore
#

Jinja is a templating engine where you can embed Python in the HTML

#

It is used by Django and Flask iirc

#

!pip jinja2

lavish prismBOT
formal swift
#

You'll probably want to look into flask and jinja like moai said. This way, you are not dealing with passwords on the HTML form, but it is securely send to the flask backend and processed there, then you can pass variables into the html template and much more stephenson

frank shoal
#

though jinja doesn't make your page dynamic if that's what you're after. To change the page, you need to run it again.

#

And there is no such thing as pyx (jsx)

slow moss
unique shore
#

Maybe I should make pyx👀

slow moss
#

is Jinja a web framework like django and flask or what

unique shore
slow moss
frank shoal
#
<html>
<body>
  {% if name %}
  <p>Hello, {{ name }}!</p>
  {% else %}
  <p>Please provide a name.</p>
  {% endif %}
</body>
</html>
unique shore
#

Jinja is a fast, expressive, extensible templating engine. Special placeholders in the template allow writing code similar to Python syntax. Then the template is passed data to render the final document.

frank shoal
#

It takes the string and renders it acoording to the content in {% %} and {{ }}

frank shoal
#

{% %} is control flow
{{ }} is print

#

Yes.

#

note that you can't import things. You have access to whatever context you gave the template engine.

slow moss
#

is it able to use jinja only , like without a library like flask

frank shoal
#

Yes, but you would need to configure it. You can't just run it from the command line

unique shore
#

^

slow moss
#

okay thanks for helping

agile pier
#

hii, how do I add word-wrap property to
<p class="card-text" style="width:400px; word-wrap: break-word;">{{ dd.headers}}</p>

#

this is not working..

frank shoal
#

isn't word-wrap the default?

agile pier
frank shoal
#

Why are you showing me the headers?

#

unless that is your html

agile pier
#

it is in the html

#

this is the text

#

can it be because i m using p tag?

frank shoal
#

maybe. Try div

agile pier
frank shoal
#

¯_(ツ)_/¯

ivory kiln
#

for js

#

if i have a number in seconds

#

how would i calculate the days, hours, minutes, seconds since that number

scenic oak
#

Hi everyone. Does anyone know how this sight is accessing the match data that fills there website? They are not officially apart of pokemon unite and I can't find a public API being offered by the game so I am curious how they are doing it.

https://dev.uniteapi.dev/

Unite Api

Latest Pokémon Unite news and information

somber seal
#

Anyone here running dev projects on Apple m1?

unique shore
ivory kiln
unique shore
#

Well that would probably be a good first step

pulsar marlin
#

Im trying to store input signup data so they can log back in... Where do i store it?

#

And how

unique shore
#

Database

safe monolith
#
TypeError at /

'bool' object is not callable
Request Method:GETRequest URL:http://127.0.0.1:8000/Django Version:3.0.3Exception Type:TypeErrorException Value:

'bool' object is not callable
Exception Location:/Users/incognito/Documents/incog/incpay/incpay/views.py in get, line 15Python Executable:/opt/miniconda3/envs/myEnv/bin/python3Python Version:3.8.5Python Path:

['/Users/incognito/Documents/incog/incpay',
 '/opt/miniconda3/envs/myEnv/lib/python38.zip',
 '/opt/miniconda3/envs/myEnv/lib/python3.8',
 '/opt/miniconda3/envs/myEnv/lib/python3.8/lib-dynload',
 '/opt/miniconda3/envs/myEnv/lib/python3.8/site-packages']```
#

someone said the solution to this would be to ``Try to reload your server through comment on the get method.

`` but i don't understand

sick sluice
#

Hey I am using django and having some issues with web deployment. I am using heroku to deploy my website and it works fine, but when I change the domain name, I am getting some errors

#

These are the errors I am getting on the new domain

native tide
#

I'm unable to build my pelican blog because of this issue, which i imagine affects a lot of Flask projects as well. https://github.com/holoviz/panel/issues/3257

Does anyone have an idea what a temporary work around might be until they fix it? It basically just needs to have an import line changed in the pelican package but... that doesnt help me until they add it.

GitHub

ALL software version info Python 3.7.11 and panel 0.12.1 Description of expected behavior and the observed behavior jinja2 updated on 24th March 2022 and the Markup import must be imported from mar...

#

one guy said this "Same error on an internal project : current workaround was to explicitely pin the Jinja2 requirements"

#

what does he mean by that. jinja2 is in my requirements.txt file.

#

i figured it out.. explicitly revert back to 3.0.x is what he meant

torpid folio
#

is anyone here who has worked with django 4 ?
needed some help

candid kestrel
pearl vigil
#

I have set up Digital Ocean Spaces using a FileUpload field.

How do you upload other files outside of using the upload field like creating a PDF in a Post_Save Signal and uploading that to Digital Ocean?

#

This is using Django 4

candid kestrel
slow moss
#

what's the problem ? , I tried twice but nothing have changed

#

I created a "HTML" template, and I rendered it using flask but they tell me templateNotFound , I go back to ensure if there is something wrong on my code , but the entire code is correct

#

I have not even made a mistake on the path of the template

native tide
#

how can i host a django app without downtime for free?????

regal surge
#

hello everyone, im a beginner programmer. i want to ask something about django. why request.POST.get always return None?

native tide
#

if yes, do they get submitted?

regal surge
#

yes, and yes. i submited string in the form

#

and this is my html file

native tide
#

bruh

rotund perch
#

whats better (Pagination & Requests):
1-Pagination on backend. Frontend requests everytime the page changes.
2-Pagination on frontend. Backend sends all data when requested then frontend handles the paginiation and caching etc...

eager hornet
regal surge
# regal surge this is my views.py file

oh it solved. so in my form, i send POST request to index page. but, instead getting post request value inside views.index func, i get the value of post request inside of views.addtask func. lol

rotund perch
eager hornet
hot valve
#

for django, instead of the following

>>> # This will run on the 'default' database.
>>> Author.objects.all()

>>> # So will this.
>>> Author.objects.using('default').all()

>>> # This will run on the 'other' database.
>>> Author.objects.using('other').all()

could i specify in the Author model that i always want to use a specific database like 'other' for that model? or do i always need to call .using for selecting the non-default database?

fluid perch
#

hi i am writing a website but i got stuck in this fucking traceback

hot valve
wheat verge
#

can i add a custiom python file in django and import it in views??

#

custom*

agile pier
formal swift
wheat verge
#

The open cv file basically detects faces and appends the name in a list i want that name in my django project

agile pier
pearl vigil
#

Anyone done any FileUploads with Digital Ocean Spaces?

agile pier
wheat verge
#

ok sure thanks a lot

pearl vigil
#

Can you pass a file to a filefield without it saving locally?

radiant sundial
pearl vigil
#

Using WeasyPrint im creating a PDF in the post_save signal

#

then trying to pass it to a document model

radiant sundial
#

OK so you're creating it and you don't want to save it locally first just to send it over to Digital Ocean spaces.

pearl vigil
#

which then uploads to Digital Ocean Spaces

radiant sundial
#

I have an application where I am downloading videos using yt-dlp and I can't escape creating the file (or I haven't looked hard enough). I'm storing it in a TemporaryDirectory but you can use TemporaryFile. Before you go that route, have you looked at django-storages?

pearl vigil
#

im using storages yes with S3Boto

#

So far i only know if i use a FileField it uploads to DO, but not sure how to do it in code

#

html_template = get_template('claim_form.html').render(context)
pdf_file = HTML(string=html_template).write_pdf('test.pdf', stylesheets=[CSS(settings.STATICFILES_DIRS[0] + "/forms/style.css")]) #

    document = Document.objects.create(claim = sub_claim, document=pdf_file)
radiant sundial
#

OK so check this

#

import os

from django.core.files.storage import default_storage

def save_to_s3(file_input, directory_name):
with open(file_input, 'rb') as f:
file_output =
os.path.join(f'audio/{directory_name}', file_entry)
file_output_actual =
default_storage.save(file_output, content=f)

#

Now this is me hacking up my existing code to break out the gist of it.

pearl vigil
#

Yeh you ur using with open to read the file

radiant sundial
#

So if you are able to save the file local using TemporaryFile, then read that in and write to the default_storage.save, you should be home free.

pearl vigil
#

what is TemporyFile a library?

radiant sundial
#

at the top, tempfile.TemporaryFile. On my system it saves it as /tmp/tmpxxxwhatever I think

pearl vigil
#

so regardless it has to exist in the working dir before being shifted to S3

radiant sundial
#

Now if you can get the PDF file as a byte array, you should be able to skip that step.

#

for my use case, yes. But as long as you can get the file content in that f var using another mechanism, you should be good.

#

I'm not familiar with your PDF library.

pearl vigil
#

Can always clear out the tmp file once the process is done

#

I have a document model that has a filefield, ideally i could create that document and pass the pdf to the filefield and that would be it

mossy shard
#

I developer

#

I can make my Web brauser

#

Its Python server

#

I love Python

#

Kto ne verit tomy v glaz

#

Ok

primal grove
mossy shard
#

(( sorry

primal grove
#

@native tide @native tide please review our #rules so that we don't have to take further actions.

#

!ot

lavish prismBOT
radiant sundial
pallid tulip
#

can someone help me refactor those 2 functions?

#

Both of them have 4 similar lines of code
so I want to use the 2nd function in the first function bcuz DRY

#

but I don't know how to deal with the return statements of the second function

#

any help would be appreciated

alpine sparrow
#

@pallid tulip whats wrong with the return of the second function?

pallid tulip
#

lines 69 and 70 are the ones causing me the problem

#

let's say input of the first function has a tree.fruit_name that isn't in TREE_NAME_ICONS dictionary

#

how am I going to make the 2nd function deal with the return clause
(please mention me if you have an answer)

lapis basalt
#

Hello
I have an app with jwt access how to give a temporary access to a a temporary user with email for only one route (read only access)

zealous oar
#

Hi there 👋

I'm trying to use Google OAuth with my back-end (Django and DRF) so users can signup/login using google, first I read the official docs for it
https://developers.google.com/identity/protocols/oauth2

and tried to use google-api-python-client
https://github.com/googleapis/google-api-python-client/blob/main/docs/oauth.md

but I can't understand the docs Although it's the official 3rd party that google provides with Python, I did not find any tutorial about how can I use it with the rest API in Django.

I checked out django-allauth but it's not for rest API, so what should I do in this case? if there are good tutorial guides me on how to accomplish this task, please let me know!

mint garden
#

I’m going to make a e-commerce website for a small business and was wondering how much should I charge them for it and or if I should do a revenue share instead ?

mint folio
#

Also add some buffer on top to your estimate to cover any issues that could arise.

ivory kiln
#

!e py my_list = [1, 2, 3, 4, 5, 6] print(my_list[:5])

lavish prismBOT
#

@ivory kiln :white_check_mark: Your eval job has completed with return code 0.

[1, 2, 3, 4, 5]
ivory kiln
#

how do i replicate this in js?

#

how do i also do [-1] to get the last element

outer apex
ivory kiln
#

it worked when i did hourData.length - 1

outer apex
#

Ah, I'm wrong. The -1 doesn't work in JS, my bad!

ivory kiln
#

np :)

#

er

#

i have a list like

#

[1, 2, 3, 4, 5]

#

but its in a string

#

string.replace("[", "").replace("]", "").split(',').map(Number); is there an easier way to do this

formal swift
#

Is this reasonable to set up for mid size flask apps? https://www.digitalocean.com/community/tutorials/how-to-structure-large-flask-applications

Seems a little bit overboard, so much so it's hard to even understand where stuff goes.. Anyone have any sources on how to structure mid size flask apps?

ivory kiln
#

what does Cannot read properties of undefined (reading 'pingDifference') mean?

#

const pingDifference = Math.round((ping / Number(hourData[hourData.length - 2].split(" | ")[0]) * 100)) / 100; ignore the shambolic code

ivory kiln
dense slate
#

either you're asking to use it somewhere before it's ready, or it's not computing correctly.

#

If you log it, does it show the value eventually?

ivory kiln
#

er turns out i may have accidentally used the wrong dict path

rotund perch
#

Hello, I have multiple questions about RDS AWS Database (Free Tier):
1-What is the data limit
2-Is there a visual interface that allows me to see its data
3-If the data limit is exceeded/full does it change the plan automatically?

mild vapor
#

i am only 14 but i love logo_django2

native tide
#

Does anyone know of an easy way to add search to a flask-wtform selectfield?

steep bough
#

How can I debug where and why I got this 405 in my endpoint?

#

It is inconsistent sometimes it will 405 sometimes it will not

#

And the built in debugger isn’t giving me any useful errors

fair cloak
#

hey i need help with flask and stuff
i want to make a folder called Website into a package but its not working, yes i have a __int__.py in there but its still not working, can someone help me plz? and plz ping me when you answer

unique shore
#

it’s __init__

#

Hopefully that was just a typo

#

@fair cloak

fair cloak
unique shore
#

ok

fair cloak
#

it is init in my file i just missed the i in my text here

unique shore
#

what file are you importing and where are you importing from? Can i see your file structure

fair cloak
#

okok

#

@unique shore the main.py is outside of the Website folder btw

#

there is nothing in the statics folder either

unique shore
#

not sure if templates is supposed to have Python files

#

That’s where your html files go

fair cloak
unique shore
fair cloak
unique shore
#

yes

#

afaik

fair cloak
#

In this video, I'm going to be showing you how to make a website with Python, covering Flask, authentication, databases, and more. The goal of this video is to give you what you need to make a finished product that you can tweak, and turn into anything you like. We're going to also go over how you create a new user's account, how you store those...

▶ Play video
#

this is the one im watching

#

@unique shore also moai do i need HTML if im using flask even?

#

cuz i thought its all in python

unique shore
#

A webpage’s structure is made in HTML not Python

fair cloak
unique shore
#

You can use a Templating engine to extend HTML with some Python syntax

#

yes

#

if you are doing web development, specifically frontend, you need HTML, css and JS skills

fair cloak
#

then...what is flask for?

unique shore
#

server side development

cinder whale
#

backend

unique shore
#

But it can serve static files

fair cloak
#

oh wait

#

i think ik whats the problem

steep bough
#

@unique shoreare you familiar with flask?

fair cloak
#

im puting the files in the wrong places i think

#

yep

unique shore
#

templates dir is supposed to house the html static files

fair cloak
#

i think i have officially lost all my braincells at this point

cinder whale
# fair cloak i think i have officially lost all my braincells at this point

kekHands if you have the time, check this video some time - it can help put everything in context https://youtu.be/EqzUcMzfV1w

This is my annual guide to take you from start to finish when it comes to the web development technologies that are available for frontend, backend, and full-stack developers.

👇 Content Guide:
https://traversymedia.com/guide

👇 Website & Courses:
https://traversymedia.com

💖 Show Support
Patreon: https://www.patreon.com/traversymedia
PayPa...

▶ Play video
#

i know it helped me

#

when i first started trying to comprehend web dev

cinder whale
#

yeah he walks through okay what is frontend vs. backend vs. fullstack

fair cloak
#

big thanks to you two

cinder whale
#

what technology is what

cinder whale
#

yeah but he just helps you understand and categorize all the buzzwords/tech stack you might come across

cinder whale
#

yeah it was honestly overwhelming before i found that video

fair cloak
steel igloo
#

Anyone here in a javascript or totally web development dedicated server

gusty hedge
#

any trick to edit HTML files with live preview in Brave?

native tide
#

I need help, this is a issue with Digital Ocean when trying to deploy my app. How do I get ssh access to the web server, instead of using it through the console?

native tide
vague ember
#

np

native tide
# vague ember np

I can buy you nitro classic if you like, since you decided to help me out 🙏😁

vague ember
#

Thanks though

native tide
umbral rock
#

Hi all, I'm just looking at a website I made last year. I have five links in my navbar. Four of them hide the link so that the text is white, whereas the 'bcTech' link underlines and goes purple. Any idea how to turn this off?

#

Nevermind, got it 🙂

.logo a{
    text-decoration: none;
    color: white;
}
trail axle
#

is it worth learning django or flask if I am not going to use js?

agile pier
inland oak
#

knowing JS for backend person is nice to have at least as basics, but not really obligatory

#

one book like head first Javascript should be basically already enough for the backend guy to fill the JS quota up to Middle rank

glass swift
#

My company use Python and Django only for make backend services. The consumers of that API's are JS programs

#

(frontends)

hearty cloud
#

Good day everyone, I'm new to django and would really appreciate if I could find like a practice mentor or something

pallid cloak
#

hello anyone can give me some idea? I am writting Jquery in flask. Trying to store it as external JS scripts. But it seems when I have <script type="text/javascript" src="{{url_for('static',filename='outcontrol.js')}}"></script> code in HTML (a render template page). It treat outcontrol as a static file, and it won't able to execute $("#b01").click(function() { htmlobj = $.ajax({ url: "{{url_for('out')}}", type: "GET", the url part. But if I put it as a script in HTML template directly it works fine. Does this mean flask does not support Jquery written in a seperate file?

native tide
#

Hi! I'm trying to build a Twitter Scrapper, but I can't manage to do it

#

my knowledge on python is 4/10, and I've tried tutorials

#

but I get errors like this

#

Can somebody help me, please? Or send me a good tutorial or course

#

This is my code:

lavish prismBOT
#

Hey @native tide!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

native tide
craggy flame
#

Can someone recommend an django tutorial? Everything i can find (text / video) are outdated or behind a paywall... 🤔

formal gull
#

does anyone have any experiences with anvil? would love to hear experiences with it?

latent rivet
#

Hello. This is probably a FAQ but I can't seem to find the answer anywhere so please do help.

What i'm trying to do is when the "Add" button is called, i want to query the database and change the value of the "Stock" field. How will i go about doing this without having to reload the page?

cloud path
#

can i turn a flask with html web app into a desktop app?

vapid haven
#

When I first setup my website I registered on some sites like google console and all to get better listing now am setting up another site anyone knows where all I need to register to get good listing...?

hearty cloud
formal swift
native tide
native tide
# craggy flame Can someone recommend an django tutorial? Everything i can find (text / video) a...

you can check out this if you want https://youtu.be/jBzwzrDvZ18?t=13108 like it's beginner friendly (imo) ||for the first 3 hour & 30 minutes they're just teaching 'basic' stuffs so you can skip the basic stuff if u want||

This video is a full backend web development course with python. In the course, you will learn everything you need to know to start your web development journey with Python and Django.

✏️ Course developed by CodeWithTomi. Check out his channel: https://www.youtube.com/c/CodeWithTomi
🔗 Join CodeWithTomi's Discord Server: https://discord.gg/cjqNB...

▶ Play video
latent rivet
native tide
stoic osprey
#

does anyone familiar with web scraping

#

i need some help

cinder whale
hard spear
#

has anyone of you lately tried deploying Django on Heroku? It's throwing me a "Django heroku push gives could not build wheels for backports.zoneinfo error". I searched on the Internet but didn't find any answers.

flat lagoon
#

What is the best programming language for web dev/web hacking ?

unique shore
#

Frontend dev essentially requires JavaScript

flat lagoon
unique shore
#

Frontend has to do with the UI and how the site looks

#

Backend is the logic behind it and how it works

flat lagoon
unique shore
#

Learn JavaScript

flat lagoon
unique shore
#

But languages that can compile to webassembly like rust can also do frontend

#

I would recommend switching to typescript after becoming proficient in JS

#

Typescript is JavaScript with a type system

#

So all valid JavaScript is valid typescript

#

Typescript makes more correct code and is type safe

patent glade
#

Can anyone explain to me, in simpler terms, what an AbortController is and how to use it?

livid mountain
#

Can someone recommend a good flask open source project that I can learn from? (GitHub)

deft crow
#

uh

#

how to make the "instagram" go in the middle?

#

nvm i got my own solution

winter hinge
#

uhh if I want to have something like an admin panel for fastapi model how would I do that?

#

I want something like django panel

rich sage
#

I google the keyword and find Piccolo Admin, maybe it could help?

strange nacelle
#

How do I get global ports into a python socket? To be able to connect from another computer

latent rivet
# native tide javascript

Could you elaborate just a bit more? Does this mean i'll have to query the database through javascript rather than via django itself?

agile pier
#

How to add data to ManyToMany Field in Django using a .csv file?

#

the csv column has values separated by commas

lethal marten
#

hey, so if i have a wall of text on html in a tag, and i want to make it so that if i hover over a certain word in the wall of text, it should change color, but not the whole text... how do i do that?

agile pier
lethal marten
#

no like

#

i have

<h4> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </h4> 

If i were to hover over, say lorem, i want only lorem to change color, not the whole text

agile pier
# lethal marten i have ``` <h4> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed d...
<h4 style="display:inline"> <span id="hover">Lorem <span> ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </h4> 
#

add css to the span tag with id='hover'

lethal marten
#

and if i wanted that to be done for every word? i'd have to use a new tag for each word?

#

there's no single attribute i could use?

inland oak
#

since backend person already usually knows code quality technics of the other language

#

learning just JS syntax is usually enough to handle most of his tasks, or at least having understanding in what he wishes to achieve, even if he does not use JS / and its client side browser interaction

inland oak
#

it can be as backend language choice as well as any other one

#

quite a lof of backend positions in js. Just for the amount of job positions... quite tempting to choose learning js

cinder whale
#

i mean you dont have to convince me. im already learning js for frontend kekHands

#

but career-wise, i probably will either go DS or backend route

pine horizon
#

Hi everyone! Let me just say that Python for me is a very awesome programming language to do web development.

inland oak
lucid mirage
#

Hello everyone

#

Does anybody can use selenium to login to google mail

#

Google mail detect my selenium and ban it for sign in 😿 , i have search in stackoverflow/github but it no use

#

Does anyone have any idea

pearl thicket
#

Hi everybody, I'm not used to implement Flask application
But I have a goal for a customer, he has a web server on DigitalOcean configured with ServerPilot, with some web PHP classic apps
No he has a Flask project, and he wants it on the same server, what the best way to do that please ? I'm very blocked, and I don't understand all step I do sometimes...
I tried to search on Google, but nothing with ServerPilot + Flask, and the separated documentation is not easy to implement.

If someone already did something similar, or exactly similar, or just a big knowledge and can help to achieve this.

I use Gunicorn to bind the app on the 5000 port, and try to listen to it with a .htaccess:

https://serverpilot.io/docs/how-to-run-apps-in-any-language/ (modifié)

dusk portal
pallid lily
#

Django Question, Can i use redirect(request,'other-view') inside APIView?

serene prawn
#

Such as request host, for example domain.com or another-domain.com

#

I'm not sure if you can run gunicorn behind something like apache 🤔

#

But you probably can

pearl thicket
#

I saw some documentation on flask and other website to run flask app on apache but I think it's with WSGI or something like that, but I'm not sysadmin and I'm not very confortable with this stack (flask, etc...) So I don't understand everything ahah.

What did you say make sens, I will try to work with that during the weekend, I hope to find a solution. If anyone has skills on it, and want make a call to help me, it's appreciate ahah.

light chasm
#

hi, anyone know how it would be possible to make a page that sends push notifications to specific users, and they don't need to be on the website to receive it?

outer apex
light chasm
#

sorry for the late reply, on a webserver on Flask

outer apex
light chasm
#

more like you know how when you need to allow a site to notify to redirect you to the actual site? and then you suddenly have notifications even when you're not on their site lmao?, well like that, but with a better intention

whole sierra
#

Please someone answer

broken mulch
#

I don't get why discord does POST/channels/{channnel_id}/messages instead of just sending a websocket event back
can anyone think of any reasons they might do this?

#

does it like save bandwidth or smth

robust needle
#

Can anyone tell me if there's an easy way (using flask) to automatically scale text font to fit within a parent element (like a div)? The text is variable length and I need it to fit within a fixed area on the screen without cutting off. I see some javascript libraries that do similar things

inland oak
mellow marsh
#

Hey all,
wondering if yous might be able to help me.
Got a simple aspnet core app that works fine on my local windows environment, cant get it to work properly on a linux server.
It's a matchmaking http thingy for Among Us. Very simple stuff (I'm not a web developer, help!)

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:56630",
      "sslPort": 44385
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": false,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "AmongUsMatchmaker": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": false,
      "applicationUrl": "https://localhost:443;http://localhost:442",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

This is my launch settings.json file

  GNU nano 4.8                                                                                         /etc/nginx/sites-available/default                                                                                                    server {
 listen 80;
 location / {
 proxy_pass http://localhost:5000;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection keep-alive;
 proxy_set_header Host $host;
 proxy_cache_bypass $http_upgrade;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto $scheme;
 }
}

This is my nginx config on the linux server.

What am I doing wrong?**

pearl vigil
#

Anyone done much with the tempfile module? I can't seem to get it to work... I get a module 'tempfile' has no attribute 'TemporaryDirectory'

dusk portal
#

ERRORS:
?: (djstripe.E002) DJSTRIPE_FOREIGN_KEY_TO_FIELD is not set.
HINT: Set DJSTRIPE_FOREIGN_KEY_TO_FIELD to "id" if this is a new installation, otherwise set it to "djstripe_id".

#

n when i remove null n blank field from stripe_subscription column it shows

ERRORS:
?: (djstripe.E002) DJSTRIPE_FOREIGN_KEY_TO_FIELD is not set.
        HINT: Set DJSTRIPE_FOREIGN_KEY_TO_FIELD to "id" if this is a new installation, otherwise set it to "djstripe_id".
index.MyStripeModel.stripe_subscription: (fields.E320) Field specifies on_delete=SET_NULL, but cannot be null.
        HINT: Set null=True argument on the field, or change the on_delete rule.
void bison
#

Hi guys

#

new to web dev

#

I just have a quick question

#

I just installed LAMP stack in my ubuntu OS VM

#

I used php to write the whole back end

#

However, is it possible to write my request script in a separate file ?

#

I used a python script to retrueeve the apache default page

#

and used a socket to sent and http request as well as an ssl but iim not sure how to conmnect them to my main PHP script

#

import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("vulnerable", 80))
s.send("GET / HTTP/1.0\r\n\r\n")
while True:
response = s.recv(1024)
if response == "":
break
print response
s.close()

pearl vigil
#

So im using Digital Ocean Spaces, when I upload a document it created the entire path of files instead of just the file inside 1 folder, if that makes sense.

covert musk
#

Anyone know how to move H1 to middle of page?

unique shore
#

use flexbox

hard whale
#

Hello gentlemen! I'm lookig for full stack dev who could explain how to make API for python program. I couldn't find a good example and the concept is unclear. Thank you in advance!

manic crane
#

im trying to make a migration remove the occupiers field of my clique model but when i try to migrate i keep getting ValueError: Field 'occupiers' expected a number but got ''.

#
#A clique can have many users. 
#A clique can have many posts.
    class CliqueObjects(models.Manager):
        def get_queryset(self):
            return super().get_queryset().filter(level='public')
    options = (
        ('private', 'Private'),
        ('public', 'Public')
    )

    name = models.CharField(max_length=200, null=False, blank=False,default='')
    #occupiers = models.IntegerField(null=False,blank=False,default=1)
    created_at = models.DateTimeField(auto_now_add=True)
    occupation = models.CharField(max_length=90,null=False,blank=False,default='')
    level = models.CharField(max_length=10, choices=options, default='public')

    objects = models.Manager() # default manager
    cliqueobjects = CliqueObjects #custom manager

    def __str__(self):
        return self.name ````
sharp stratus
somber summit
#

Hello

#

How can I implement real-time voice call app with django framework without WebRTC and P2P(stream data must pass through the server)? (I've seen django channels but it supports UDP protocol in version 1.0 and I use version 3)

golden bone
hard whale
dense slate
#

@inland oak Hey any idea how I might have applied set_password to all the user accounts in my database? I was creating a custom password reset flow and I realized somehow during the process it changed the password of every user in the database. Without some kind of for loop, any idea how that might have happened?

inland oak
#
  1. during database migrations, default same value can be applied to every user possessing new field
    (Same happens if u use some randomizer in field default. Migrations are recorded for static values)
dense slate
#

I realized that it's a problem with JWT. I'll explain later. 🤦‍♂️

inland oak
# dense slate I realized that it's a problem with JWT. I'll explain later. 🤦‍♂️

Well. Unit tests are made for this
https://youtu.be/qeMFqkcPYcg

Eurythmics - Sweet Dreams (Are Made Of This) (Official Video)
Stream Eurythmics here: https://eurythmics.lnk.to/Playlists
Subscribe to Eurythmics' YouTube Channel: https://eurythmics.lnk.to/YouTube
 
Follow Eurythmics:
Official website - https://www.eurythmics.com/
Facebook - https://www.facebook.com/eurythmics/
Twitter - https://twitter.com/eur...

▶ Play video
broken swallow
#

I'm a beginner to webdev and I'm learning it for a project. Im thinking of using django because Ive worked with it before. I know there are two approaches to doing this:

  1. Using templates to render
  2. Using a js based frontend and REST api
    Which of the following would you recommend. Ive already worked a little with the first one so Id like to hear more about the 2nd. Will there be any difficulties if Im hosting because I need 2 ports. Noticeable performance issues with cheaper servers, etc. And also which one is more commonplace in medium sized projects.
somber forum
obtuse mantle
#

I want to start web so suggest me to how to start plzz

covert musk
silver bear
#

any good free hosts for FastAPI webservers?

hot valve
native tide
#

I am using Django and I was wondering what the best way is to remove the username field from everywhere and replace it with an email, and add a full name and a phone number field as well

#

currently watching this video https://www.youtube.com/watch?v=SbU2wdPIcaY

In this video, I'm gonna be talking about making a custom user model in Django. We will show you email authentication as well as phone authentication in Django. We will first make a custom user model that inherits from abstract user (or abstractbaseuser) and add a new email field which is unique (or phone number field which is also unique). We w...

▶ Play video
#

but it's about 2 years old

full badger
#

anyone know anything about phishing?

dusky minnow
#

i am trying to upload a file to an wordpress API and it works when i do it from reading an image file on my pc but fails when i try to get the image from another url

brazen pumice
#

[03/Apr/2022 10:11:37] "GET /static/images/grid.png HTTP/1.1" 404 1804
[03/Apr/2022 10:11:52,685] - Broken pipe from ('127.0.0.1', 57003)
can someone help me?

peak jungle
#

Can someone explain how to use templates and models in Django? And why do i need them? Thank you in advance

lethal pier
#

I could use some help in trying to get a dictionary read by my template file in #help-chocolate

tulip harness
#

im having an problem with positioning div

#

~~<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="login.css">
<link rel="icon" type="image/x-icon" href="static/logo.png">
<title>Document</title>
</head>
<body>
<div id="parent">
<div id="alignment" >
<img src="static/instagram2.png" alt="">
<img src="static/instagram1.png" id="overlay" alt="">
</div>

    <div id="login">
        <h1>Instagram</h1>
    </div>
</div>

</body>
</html>``

#

and this is css

#

~~body{
text-align: center;
}
#parent{
margin-top:32px;

}
#alignment{
display: inline-block;
}

#overlay{
position:relative;
right:175px;
top:25px;
}
#login{
height: 538.84px;
width:350px;
border:0.5px solid rgb(211, 211, 211);
display: inline-block;

}~~

#

why i cant place div with id login horizontally along with div with id alignment

hollow jungle
#

How can I make the python server auto-restart?

lucid inlet
hollow jungle
lucid inlet
hollow jungle
#

no

#

i have an api hosted with that

#

so data comes from json

#

the data in json keeps updated. or somehow i do that.

#

so the data in api also needs to be updated right?

lucid inlet
#

you want the server to restart when it receives a request?

hollow jungle
#

no, i just want it keep restart. to update the data.

#

thats what i have understood

#

and if i do it mannually, it works too

#

i dont know if it can be done another way.

#

but if server restarts, it works. thats why i was asking how to do that. 😄

lucid inlet
hollow jungle
#

basically yes.

#

if you want to see Code

lucid inlet
# hollow jungle basically yes.

inside of flask you have have a couple ways to do this.
Set up an endpoint or function that runs the "update" code,
and then use an external service to hit that endpoint when you need to ( cron job, airflow, etc), or tie that function to one of your existing endpoints so they run in sync

#

Looking at your code, you don't need to do that though, what you want to do is wrap your file reading into a function
def read_nepse_data():
with open.....
return nepse

nepse = read_nepse_data()

#

and then inside your route functions, add a call,
nepse = read_nepse_data()
before your return calls

#

then you will read the latest version of that file each time before returning any data

#

you want to make nepse a local variable for each endpoint, you can then delete the global one

#

if you paste the actual code snippet here, I can show you exactly what I mean

hollow jungle
#

Dude.

#

that worked

#

😄

#

Thanks.

dense slate
#

I'm running into this weird problem with Django sessions and JWT. If I login to the admin panel, the auth is performed via session middleware. Unless I log out of the admin panel and clear my JWT cookies, I remain logged in as the user session and am treated that way vs the new token. Is there a way to prevent that?

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'graphql_jwt.backends.JSONWebTokenBackend',
    
)
#

Swapping them around doesn't seem to do anything. If I login to the site under a different non-admin username, my session takes precedence and I'm still the admin user on the site.

ivory lotus
#

hello, how does one validate user inputs in django + store them in a db or something? I don't seem to find anything

#

lmao

dense slate
#

Django uses an ORM to store and modify data in the DB.

lucid inlet
# dense slate I'm running into this weird problem with Django sessions and JWT. If I login to ...

"If I login to the site under a different non-admin username, my session takes precedence" - have you considered adding a flush() to your login calls? That way your old session data would be removed on login https://stackoverflow.com/questions/16039399/how-to-clear-all-session-variables-without-getting-logged-out

dense slate
lucid inlet
vivid canopy
#

Hi guys, who work with emailhunter in django? please help me

zealous hinge
#

I am trying to use tailwindcss with my Django project, but the CSS effects don't work. I have done everything correctly according the official documentation

rigid laurel
lucid inlet
ivory lotus
jovial hemlock
#

EHHHHHHHHHHHHHHHHHHHH

#

im getting dumbfounded

native tide
#

With django, are you supposed to repeat column definitions in your custom register form like they are in your custom user model?

#

because that seems kind of weird

velvet yew
#

How should I import my utils package in the settings.py script? If I do import utils and run it from the IDE it works fine, but if I cd into web in console and do python manage.py runserver I'm getting ModuleNotFoundError

manic crane
#

im trying to remove a field of my models and when i try to migrate the change i keep getting this error => ValueError: Field 'occupiers' expected a number but got ''.

#
#A clique can have many users. 
#A clique can have many posts.
    class CliqueObjects(models.Manager):
        def get_queryset(self):
            return super().get_queryset().filter(level='public')
    options = (
        ('private', 'Private'),
        ('public', 'Public')
    )

    name = models.CharField(max_length=200, null=False, blank=False,default='')
    #occupiers = models.ManyToManyField(Occupier)
    created_at = models.DateTimeField(auto_now_add=True)
    occupation = models.CharField(max_length=90,null=False,blank=False,default='')
    level = models.CharField(max_length=10, choices=options, default='public')

    objects = models.Manager() # default manager
    cliqueobjects = CliqueObjects #custom manager

    def __str__(self):
        return self.name ````
#

Help would be greatly appreciated

indigo kettle
velvet yew
#

Can you show an example?

indigo kettle
velvet yew
finite thicket
#

hello what is the best payment service for django?

dense slate
#

I often use Stripe if that's any help.

deft crow
#

is there any bootstrap dev here?

limpid hull
#

hello guys ..

#

m not able to create superuser .. getting some Fatal error .. please help

zealous hinge
#

I am trying to use tailwindcss with Django but it's not working.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Hello</title>
    {% load static %}
    <link href="{% static 'css/index.css' %}" rel="stylesheet" />
  </head>
  <body>
      <h1 class="text-center">HI</h1>
  </body>
</html>

tailwind config js

module.exports = {
  content: ["templates/*.html"],
  theme: {
    extend: {},
  },
  plugins: [],
}

package.json

{
  "dependencies": {
    "autoprefixer": "^10.4.4",
    "postcss-cli": "^9.1.0",
    "tailwindcss": "^3.0.23"
  },
  "scripts": {
    "build": "postcss css/tailwind.css -o ./static/css/index.css"
  }
}

and I am getting "GET /static/css/index.css HTTP/1.1" 404 1798 on loading the page
how do I fix this?

quick cargo
#

I assume you've ran npm run build ?

zealous hinge
#

yes

quick cargo
#

is index.css being generated correctly?

zealous hinge
#

yes

quick cargo
#

what does your browser console log when you try load the page

#

(to be specific open the network tab in the dev tools)

zealous hinge
#

I get this error

quick cargo
#

what is the url it's trying to fetch?

zealous hinge
#

you mean this http://127.0.0.1:8000/welcome/?

quick cargo
#

I mean the url it's trying to request to get the css

quick cargo
#

and I assume if you go to that url directly it returns a 404

#

are you serving any othe static content from the static route?

wintry jetty
#

hi everyone!
i am building a website that makes it possible to download videos, but i have one problem.... i have to pass my HTML form value to my Python file.
I don't really know how to to that and i would appreciate it if someone could help.
Thanks a lot!

manic crane
#

if that helps

wintry jetty
#

i tried this one but i think i am just missing one important step or so

manic crane
#

oh

#

my migrations wont apply because of this error => ValueError: Field 'occupiers' expected a number but got ''.

#
#A clique can have many users. 
#A clique can have many posts.
    class CliqueObjects(models.Manager):
        def get_queryset(self):
            return super().get_queryset().filter(level='public')
    options = (
        ('private', 'Private'),
        ('public', 'Public')
    )

    name = models.CharField(max_length=200, null=False, blank=False,default='')
    created_at = models.DateTimeField(auto_now_add=True)
    occupiers = models.IntegerField(default=2)
    occupation = models.CharField(max_length=90,null=False,blank=False,default='')
    level = models.CharField(max_length=10, choices=options, default='public')

    objects = models.Manager() # default manager
    cliqueobjects = CliqueObjects #custom manager

    def __str__(self):
        return self.name ````
wintry jetty
copper bane
#

Hello! Can i get some help with Flask method routings?

shell ermine
#

sure

copper bane
#

The button i want to perform a function:

<div>
      <input type="submit" value="Interpret Actions" name="interpretActionsBtn" class="btn btn-outline-primary" id="interpretActionsBtn">
</div>
#

my app.py is working and the page appears fine with all the css

#

how do i make this button do something?

#

i want it to run a script i wrote earlier

unique shore
#

onclick I believe

copper bane
#

where do i write the function

#

surely not in the html

unique shore
#

you might have to write some JavaScript, but you should be able to do it in Python

#

you just call the function with the onclick button attribute

#

onclick=func() in the html

copper bane
#

the method is in a different file

#

if i import it and call it will it work?

#

onclick="script.method()"

#

?

shell ermine
#

You could use form action

#

Or a html in your input

unique shore
#

^ that too

copper bane
#

but i dont have a form

#

its just a button

shell ermine
#

<input type="submit" value="Go to my link location"
onclick="window.location='/my/link/location';" />

#

If you dont want javascript

unique shore
#

well onclick should work. You might have to use JavaScript to create some middleman between the html and your Python though

shell ermine
copper bane
#

it should call a script i already wrote in python, the page will stay the same

copper bane
#

so i just put the button in an empty form and add the action?

shell ermine
#

The form is not empty, it has the button

copper bane
#
<div>
    <form action="interpretActions" method="get">
      <input type="submit" value="Interpret Actions" name="interpretActionsBtn" class="btn btn-outline-primary" id="interpretActionsBtn">
    </form>
</div>

now what do i do

#

do i make a route for it in app.py?

#

it worked lads

#

thx

ruby sorrel
#

hello everyone 🙂 noob here,
started learning javascript, and i have come across this feature you are able to define anonymous functions as a value to a key in a dictionary which was really exotic to me. is there a similar feature in python?

const jsDict = {
  return_something: function(something) {
    return something
  },
  fruit: "banana"
};
console.log(jsDict.return_something("hello"))
unique shore
#

!e

def foo():
  pass

d = {"func": foo}
print(d["func"])
lavish prismBOT
#

@unique shore :white_check_mark: Your eval job has completed with return code 0.

<function foo at 0x7f7c82b3bd90>
unique shore
#

!e

d = {"func": lambda x: x + x}
print(d["func"])
lavish prismBOT
#

@unique shore :white_check_mark: Your eval job has completed with return code 0.

<function <lambda> at 0x7fa568833d90>
unique shore
#

@ruby sorrel there is a lambda example which is pythons anonymous function

ruby sorrel
#

yes i have recently learned about lambda but i havent used it on my own yet but yeah that sounds right

#

ty

timber jungle
#

I have a row iterator ( <google.cloud.bigquery.table.RowIterator object>

Is it possible to show it in Flask ( django html ), every row as numbered?

  1. row0
  2. row1
  3. row2

Done 🙂
I needed to return the row iterator variable 🙂

wintry jetty
#

Hi everyone can someone please tell me what i am doing wrong? I want to pass my HTML FORM value to my download.py.
I woul dappreciate it if someone could help!

inland oak
#

unless u use Brython 🤔

#

you can't execute python code in web form (only HTML basic things/actions and Javascript code can be executed there)

zinc lagoon
inland oak
#

usually it can be done in a minimalistic way with web forms because

#

in GET method the page is rendered

#

and POST method web form invokes same page where it is

#

to call same URL but with values to put in

wintry jetty
inland oak
wintry jetty
#

alright can you like point out the things i have to change cuz i am new to the coding-space and i really need some explanation about what i am doing wrong

inland oak
#

at the address like / or /blabla

#

in your web form input this address <form action="/blabla"

#

press button in web form

#

accept request in backend / check it is POST type

#

do your thing, render answer in return

#

optionally render your web form from same url (/blabla) just from the GET type / if-flow check

wintry jetty
#

thanks! i'll see what i can do 😎

fast tinsel
#

i'm using django rest framework btw. thank you 😁

indigo kettle
#

it looks like you're trying to authenticate with a token. Do you have TokenAuthentication set?

safe monolith
#
from django.contrib import admin
from django.urls import path, re_path
from core import views

urlpatterns = [
    path('admin/', admin.site.urls),
    re_path(r'^$',views.home,name='home'),
]```
#

is there something I can use here instead of re_path?

#

this is my urls.py file: ^
and this is my views.py file: v```py
from django.shortcuts import render
from django.http import HttpResponse

Create your views here.

def home(request):
return render(request,'home.html')```

unique epoch
#

a question about HTML and how Xpaths work:
i have this relative-xpath: "//article//p" that returns all the text in the page, but includes one element wich is when the article was created,.

now i notice that the element (and only that) is located under the 'header' tag,
is there a way to exclude the 'header' tag from the Xpath ?

timber jungle
#

How do i save the jinja variables in python variables after form submit?

indigo kettle
safe monolith
#

path('',views.home,name='home'),this worked

#

ty ❤️

indigo kettle
#

The note states that you can change the keyword to something else, like bearer if you want. But you have to subclass the authorization class and set the keyword class variable

warped cobalt
#

anyone know why my javascript wont link to my flask app?

#
<script src="app.js"></script>
<script src="jquery.js"></script>
#

@me if you answering i dont have notis on

timber jungle
#

i have the javascript in static/js

#

For Flask you must have a specific folder structure.

warped cobalt
#

ye i did all that

#

i got it to work

#

but not that way

#

and i had to embed the css in the index.html for it to render that

#

inefficient but works for now ig

timber jungle
#

This is for my css

 <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/select2.min.css') }}" />```
#

app.py
templates/index.html
static/js/select2.min.js
static/css/select2.min.css

my folder structure

native tide
#

We have any room here related with cryptocurrency/binance?

#

!user

lavish prismBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

wicked tide
#

I need to find out some terms or vocab for what I am looking for:
A way to make sure images, when they fail to load, are properly replaced with something so they don't break the HTML

#

Like a placeholder, but not for lazy loaded images; for images that simply cannot load because the resource's URL changed.

#

But I can't find any information on this topic.

crimson shard
#

maybe "alt" text ?

brisk scaffold
#

yes use the alt attribute

wicked tide
#

That would still break the HTML because the element would resize.

#

I think I've found one part of the equation though: onerror attribute.

#

Either could be a URL or a function.

crimson shard
#

yeah that cloud also work. it also depends on how you build the HTML. for example if by default you display an loading image, and you change it when the actual image is available or something like that

wicked tide
#

I'm trying to keep my HTML & CSS as low complexity as possible, so if I can use built-in functionality, that's what I'm counting on.

#

Static site served by Jekyll on GitHub pages, you know

crimson shard
#

oh okay

wicked tide
#

Normally yeah, I'd go Vue and some lazy loading image extension with functions for automatic replacement with a suitably sizing placeholder image or some ballsy thing

crimson shard
#

then go for onerror

brisk scaffold
#

Hello guys, i'm new to web development, i just want to know how HTML & CSS Templates are sold in freelancing, as when i turn a Figma to HTML do i sell it as source code or in another way?

crimson shard
#

@wicked tide just in case you can write like this:

<!DOCTYPE html>
<html>
<body>

<img src="image.gif" id="_img" onerror="myFunction()">

<p>A function is triggered if an error occurs when loading the image. The function shows an alert box with a text.
In this example we refer to an image that does not exist, therefore the onerror event occurs.</p>

<script>
function myFunction() {
 //replace the original image if it's not possible to load it
  var d = document.getElementById('_img');
  d.src = "https://images.takeshape.io/4d46e476-8704-42c4-8d0d-06ebdd0e3c93/dev/3a75df3f-7ad3-46c6-b792-1825239fbd44/nuxtjs-logo.svg"
}
</script>

</body>
</html>
crimson shard
wicked tide
#

I'm not a big JS writer so function environments and contexts are not something I am familiar with

#

I know they are weird.

#

Would be better to at least pass the ID in the function call, encapsulate it

crimson shard
#

Definitely !! it will be more concise

obtuse mantle
#

guys what is bubble developer

#

Does anyone know it ???

pale spruce
#

@obtuse mantle only bubble developer i know has a wand a bottle soap.

obtuse mantle
pale spruce
#

@obtuse mantle it was a dumb joke. I don't know anything about developing code

obtuse mantle
pale spruce
#

yep. and WOOSH right over.... Crickets chirp (nobody laughed) that's usually the response i get when i make a joke.

cinder whale
#

i highly recommend anvil if youre starting out kekHands

#

at least its helped me

inland oak
#

Yet another no code solution

obtuse mantle
dense slate
#

Bubble is a no-code development platform, I used it a bit.

true warren
#

Hello

#

is there a way to make it so that when a user reloads a endpoint it returns a new random image

#

i'm using FastAPI

#

i'm trying to learn how APIs work and trying to make a basic random image API

#

currently stuck on how to make it random on each reload of the user

#

nevermind

delicate ore
#

@true warren

#

that should be pretty simple

#

you will first need to get the image

#

either from url or disk your choice

#

so if you have a url you do something like this

from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates

app = FastAPI()
templates = Jinja2Templates(directory="templates")

@app.get("/", response_class=HTMLResponse)
async def read_item():
    # get random image either from an api or whatever
    # then passing the img url to the template
    return templates.TemplateResponse("index.html", {
        "img_url": "https://upload.wikimedia.org/wikipedia/commons/c/c3/Python logo-notext.svg",
})
#

and then in the template

<img src="{{ img_url }}">
true warren
#

I already found a way to do it i don't really know if it's a good way

#

Kinda feels hacky

true warren
#
in TemplateResponse
    raise ValueError('context must include a "request" key')
ValueError: context must include a "request" key
#

@delicate ore

#

i don't know what to do

true warren
#

Never mind i'm a idiot

true warren
wintry jetty
#

hi is there someone that knows how to work with Flask? I have some questions about it.

rigid laurel
#

yes

wintry jetty
#

Can you tell me what i amn doing wrong here. I have to read my form data and make it a usable value.

#

thanks bud!

rigid laurel
#

what's going wrong, what do you get as the output vs what do you expect as the output?

wintry jetty
#

i just want to make the URL that u pasted a value that i can read in my python file

cinder whale
#

since no time till deadline

#

ah sorry

#

this is actually low code stuff since you can modify the code

true warren
#

When i run this i get an 404 not found error when trying to show one of the images

#
import uvicorn
import random
from typing import List
#from fastapi.responses import FileResponse
from models import User, Gender, Role
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
#from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates


edgar_imgs = ["Edgar/edgar.jpg", "Edgar/Edgar2.png", "Edgar/edgar3.jpg", "Edgar/edgar4.jpg", "Edgar/edgar5.jpg", "Edgar/edgar6.png", "Edgar/edgar7.png"]

app = FastAPI()
templates = Jinja2Templates(directory="templates")

db: List[User] = [
  User(first_name="iamSkev", gender = Gender.male, roles = [Role.student])
]

@app.get("/", response_class=HTMLResponse)
async def root(request: Request):
  random_edgar = random.choice(edgar_imgs)
  return templates.TemplateResponse("index.html", {"request": request, "img_url": random_edgar})

'''
@app.get("/api/v1/users")
async def fetch_users():
  return db
'''

if __name__ == "__main__":
    uvicorn.run("main:app", host="0.0.0.0", port=8000)
#

As i thought index.html couldn't access the folder where the images are in

#

I moved the folder inside templates

#

Still it throws a 404 not found error

#

Still can't find it

zinc mortar
#

Hello everyone
I am trying to make a page hit counter into my blog, Idon't want to use google analytics because it's a community blog and I want the authors see their post views.

I can do the normal post analytics but how do i know if a user is a unique / new visitor... I don't want to 2 views for 1 person that refreshes the page

Any idea on how to achieve this??

simple phoenix
cinder whale
#

my background is in DS

#

but nobody else in the group is doing jack

#

so here we are

simple phoenix
cinder whale
late trail
#

Hi, I have a question, I working on a project with my friend. I want to create an API but there is no localhost connection, so the question is how my friend can use the API? Should I upload it to the server or what is the solution in this case?

dense slate
#

He would need to connect to the address of the API

#

so you can host it virutally somewhere and work on it together or have him connect to your computer

#

@late trail

#

You can host virtually pretty cheap for a basic server to dev on

fast tinsel
late trail
dense slate
#

Digital Ocean is great

late trail
#

can I share it for free? @dense slate

gusty hedge
late trail
gusty hedge
#

for searching options, yes

#

I use DigitalOcean and AWS

late trail
#

Thanks

gusty hedge
#

DigitalOcean is not listed there though 🤔 And they have up to 3 static sites for free

late trail
#

okay, i will check it out, Thank you.

#

@gusty hedge Can Heroku be a good decision?

gusty hedge
#

depends, on your budget. I had used it and ended up moving out to kubernetes managed by AWS or DigitalOcean

late trail
#

maybe I will try the pythonanywhere.

gusty hedge
#

I want to give it a try to cloudflare workers

#

I tried vercel but pricing is a bit confusing for me

halcyon lion
#

@late trail r u a girl 😄

serene prawn
brave grail
#

ok so I have my flask app dishing out html pages on the test server and I'm pretty happy with it. It's a pretty rudimentary flask app I'm sure. what's the next step? How do I go from flask app on local macj=hine to networked flask app?

serene prawn
late trail
serene prawn
halcyon lion
#

got a friend who goes with the same name @late trail

#

Helena/Hels 😄

late trail
halcyon lion
#

haha 😄

native tide
#

For Django I18N do you need two different translations in your locale folder? If you want your website to be available in english and dutch, and you have created an english translation file from dutch, how do I use the default (dutch) translations then

halcyon lion
#

@native tide are you familiar with internationalization in django ?

thorny gale
#

There will be a button on the web page.
When the user clicks this button, a new tab will be opened, the specified email and password will be sent to Netflix's login page and login will be made.
Its purpose is for the user to be able to log into Netflix without accessing their login information.

How can I do that?

halcyon lion
#

whats the purpose of that 😄

thorny gale
#

I am making a shared netflix account sales site.

halcyon lion
#

not sure if u can do it just by going on the netflix page

#

since the password cant be hashed in any way

thorny gale
#

What does what I want to do have to do with password hashing?

lucid inlet
# thorny gale What does what I want to do have to do with password hashing?

Because what you are trying to do is not possible. "Its purpose is for the user to be able to log into Netflix without accessing their login information." - if you open a window and put creds in, it would be trivial to have those creds read out in the context of the session. So everyone's password WOULD be being leaked

Netflix login forms are plaintext, NOT hashed or protected client side.

halcyon lion
#

exactly 😄

#

i think his idea is to have something like a subscription based website

#

u pay lets say 5$ compared to the 12 euros on netflix

#

and he will provide an account that has premium unlocked

thorny gale
#

yes I am making such a website but not for myself

halcyon lion
#

so 4 ppl can use 1 acc and he will be getting 20$ for 12 euro 😄

#

but seems impossible 😄

#

to code that

lucid inlet
plucky wadi
#

Hey , I'm looking to deploy a django app using docker , should I go for gunicorn or uwsgi as my webserver ?

plucky wadi
halcyon lion
#

dont ask why

#

google gunicorn advantages

#

and ull know why 😄

#

i always do that

#

when i ask for help in some forums

lucid inlet
plucky wadi
lucid inlet
plucky wadi
#

gunicorn it is

wheat verge
#

I want to update the timeofattendance field everytime i make some change,for ex here every time I increment the value of attendance i want the timeofattendance field to be updated how to go about it

#

what?

jovial hemlock
#

Does anyone know how to add apache full?

indigo kettle
wheat verge
#

ok

wheat verge
indigo kettle
ionic raft
#

Django question. I've been building a web application and the DB has been growing. However, I just went to add a new column to the model by adding the following:

    twilio_massaging_service_id = models.CharField(
        null=True,
        blank=True,
        max_length=20,
        help_text='''Enter the Twilio Messaging ID'''
    )

I've made no reference to this field elsewhere in forms or views. This is the first time I'm referencing the column. And, it obviously does not exist. However, when I run makemigrations I get the following error: django.db.utils.OperationalError: no such column: events_eventsetting.twilio_massaging_service_id

I am confused. Help?

lavish prismBOT
#

Hey @ionic raft!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

ionic raft
#

This seems like a very strange error. I am adding a column to the model and I have no idea why it would tell me there is no such column on makemigrations.

plucky wadi
#

Try python manage.py makemigrations <app_name>

ionic raft
#

It appears to not be letting me add any columns to models now. And I'm utterly stumped as to why

dense slate
#

is that error when you makemigrations or migrate?

ionic raft
#

makemigrations

#

Im trying to add the field.

dense slate
#

what's the last migrations file look like

ionic raft
#

from django.db import migrations, models

class Migration(migrations.Migration):

    dependencies = [
        ('events', '0161_event_event_payment_gateway_event_stripe_product_id'),
    ]

    operations = [
        migrations.AlterField(
            model_name='eventsetting',
            name='twilio_account_id',
            field=models.CharField(blank=True, help_text='Enter the Twilio Account ID.', max_length=80, null=True),
        ),
        migrations.AlterField(
            model_name='eventsetting',
            name='twilio_phone',
            field=models.CharField(blank=True, help_text='Enter the Twilio Auth Token', max_length=20, null=True),
        ),
    ]```
dense slate
#

ok so you're trying to alter a column that doesn't exist yet

ionic raft
dense slate
#

Oh actually no those are different fields.

ionic raft
#

Im trying to add a new column. I add the text > run makemigrations > get that error.

And I'm stumped

#

Here's the net-new text in the EventSettings model: twilio_massaging_service_id = models.CharField( null=True, blank=True, max_length=20, help_text='''Enter the Twilio messaging ID''' )

dense slate
#

what do you mean you add the text

#

You writing manual migrations?

ionic raft
dense slate
#

oh i see

#

and if you run makemigrations without the text?

ionic raft
#

This really has me puzzled. I've run hundreds of migrations and added plenty of columns.

#

It tells me no changes detected

dense slate
#

ok so you already added the column, or your DB thinks you did

#

did you add it and now are trying to alter it?

ionic raft
#

No. That happened immediately on trying to add

dense slate
#

ok but you said without the text it says nothing detected. are you talking about the help text or the whole field?

dense slate
#

so "added text" you mean you added a new field to the model?

ionic raft
#

As per the pasted text

dense slate
#

ah

#

is something referencing the new field before you added it?

ionic raft
#

I am now trying a completely different field to test test_field = models.CharField( null=True, blank=True, max_length=10, )

dense slate
#

like in admin or something

ionic raft
#

I get ``` return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such column: events_eventsetting.test_field

#

So basically, I appear to be unable to add a column to the DB anymore

#

I can alter fields...but not add

#

This is actually a problem. I either have to fix this DB or completely rebuild

#

If I make an edit to an existing field all is well

dense slate
#

run manage.py dbshell

#

and then .schema events_eventsetting

#

See if something is there you don't expect

ionic raft
#

`CommandError: You appear not to have the 'sqlite3' program installed or on your path.'

dense slate
#

ok so are you connected properly to the DB?

ionic raft
#

This is unknown territory...

dense slate
ionic raft
#

I start up the app and it calls from the DB

#

I'm inside the console in PyCharm

#

Yes. I can change fields but not add. I've made no changes to settings.py

dense slate
#

You using sqlite?

ionic raft
#
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}```
dense slate
#

And you didn't recently upgrade Django?