#web-development

2 messages Β· Page 179 of 1

sweet jewel
#

πŸ‘

glacial yoke
#

hello people of the internet, I have a problem, if I try to link a css file to html in my django so called project, it wouldn't show up when I runserver. I tried to fix it with static files and etc., but it still doesn't work, it says Not Found: /{% static 'main.css' %] in console

#

here is my code:

quick cargo
#

think you accidentally put ] instead of } to make it a template action

glacial yoke
#

oh yeah, you're right

#

Because I had to change it up a few times

#

because i was testing different stuff

#

let me try it out

#

nope, it still doesn't work

#

it doesn't say anything in the console though

#

Here's the code anyways

#

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'main.css' %}">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;700&display=swap" rel="stylesheet">
</head>
<body class = "content">
<div class = "right_header">
<a href='#'></a>
<a href='#'></a>
<div>
<nav id = "navigation">
<a href='#'>Support</a>
<a href='#'>Terms of Service</a>
<a href='#'>FAQs</a>
</nav>
</div>
</div>
</body>
</html>

#

this is the html, which i have in my site folder/templates

#

I have a different folder for css which is 'my site folder'/static

quick cargo
#

what does the rendered html look like?

glacial yoke
#

literally like the html without any css

#

so it just has the nav bar which look like regular links

#

here's the settings:

#

PROJECT_ROOT = os.path.dirname(file)
sys.path.insert(0, os.path.join(PROJECT_ROOT, 'apps'))

#

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')

quick cargo
#

send a ss of your console with requests and xhr enabled and reload the page

#

see what it's requesting data for

glacial yoke
#

what's xhr?

quick cargo
#

I cant remember the name lol

glacial yoke
#

How do I enable it?

quick cargo
#

basically im just talking about having this checked^

glacial yoke
#

Yeah, where do I do that? sorry I'm kind of a beginner at this thing

quick cargo
#

err go to your browser

#

open dev tools / console

#

in your top right of the console it should have some buttons to toggle it

#

with chrome it's a little settings cog

#

and you can toggle it there

#

you want to enable Log XMLRequests

glacial yoke
#

ok, thanks

#

now, do I just runserver?

quick cargo
#

run the server

#

load the page

#

and see what the console logs requests wise

#

if it's rendering the path correctly it should get the css file without issue

#

otherwise you'll see it send a request to some random location

glacial yoke
#

this is what it says

quick cargo
#

okay cool

#

so we know it's sending a request to get the css to that url which apprently doesnt exist

#

what was the url you were expecting?

glacial yoke
#

It doesn't show anything different if I switch off the requests thing, which means I don't think that it has to do something with the css file

#

And actually it says all the paths correctly

#

even in the sources section and everything

#

so idk what's going on

quick cargo
#

you're getting a 404

#

which means the server is saying that the file doesnt exist in that path

glacial yoke
#

and to change the path, do I need to change it in the html file

#

Where it says: <link rel="stylesheet" type="text/css" href="{% static 'main.css' %}">

quick cargo
#

what is your static file like again?

glacial yoke
#

Do you mean the folder?

quick cargo
#

yes

glacial yoke
#

it's right next to the templates file

#

and inside, the main.css is the first thing

#

same goes for templates and the html file

#

as I said before, I linked everything in settings, using sys and os

quick cargo
#

hmmm

glacial yoke
#

shall I just try to include a different path in main html?

quick cargo
#

does the admin site load the css content and that correctly?

glacial yoke
vagrant musk
#

Hey! Is it better to use local storage or S3 bucket for storing static files in django?

quick cargo
glacial yoke
rain wasp
#

Hi Everyone πŸ‘‹
I m stream I am going to learn backend development but I don't have any prior knowledge of backend
So I ma confused which language should I choose because their are lot of technology for backend like
Node js
Java
Python
Php
So which one should I choose
Any help will really appreciated
Thanks

dapper tusk
#

@rain waspIf you just care about backend, python is IMO the simplest option. But if you want to do both frontend and backend, JS is the better choice since you will need it anyway

outer lotus
#

All languages have their advantages and disadvantages, start learning that one with which you think you can have a job easier.

#

After learning a language you can start learning differences between languages and you can see which language is better for your project.

dapper tusk
#

I would argue that you should start with the simplest to learn language, not the one with the best job prospects

#

you will need multiple languages in backend anyways

rain wasp
quick cargo
#

best job prospects -> learn cobol hahayes

dapper tusk
#

@rain waspthen I would say just start with python backends if you already know the language, get familiar with the core concepts, then learn JS later, and pick whatever backend language is most desired by jobs

#

if you want a job that is

#

if you just want to make websites as a hobby, JS is still an excellent backend language

rain wasp
#

@dapper tusk I m currently in final year of my university and I need a job after my course completion that's why I want to learn a language that is easy so that I can make good project that can show my skill in less time

dapper tusk
#

yeah, python is nice for just getting something usable quickly

#

do your research what frameworks and libraries are companies hiring rn

#

here it's for example liferay

#

some places it's PHP

#

and learn that

rain wasp
#

@outer lotus hey that is vey time taking process thats why I came here and asking to the experienced guy who already did that thing πŸ˜…

#

@dapper tusk thanks

outer lotus
rain wasp
outer lotus
#

If you want to work remotely, yes. If you want to work at the office, depends where do you live or you want to live.

#

But, all the four languages you mentioned are popular. Java may be more difficult to learn. Python and php are easier to learn. I don't know Node.js.

rain wasp
#

@outer lotus thanks

balmy sparrow
#

Any Django ORM experts?

I have three models:
Trip β€”m2mβ€”> Car β€”m2mβ€”> Parts

Each m2m intermediate table has extra field, Quantity.

Given a single trip instance, is it possible to grab every Part instance and determine annotated fields like part.weight or part.cost?

Each trip has multiple cars, each car has multiple parts. I’d like to get th total cost for ever part of every car that’s on that trip.

balmy sparrow
vestal hound
#

if I understand you correctly

#

Parts.objects.filter(car__trip=trip).aggregate(Sum('price'))?

#

wait

#

hwo does the quantity figure into this

balmy sparrow
#

The quantity is how I determine how many cars of each type are in each trip. Same for parts to car.

#

Maybe my data structure is not good and I should add a new row for each of the same objects?

vestal hound
#

hold up

#

so

#

a row in Parts

#

is not

#

a part, but a part type?

#

okay I don't really get your data model at the moment

long jackal
#

why is this circle blurred?

Js file

const canvas = document.querySelector('canvas');
const c = canvas.getContext('2d')


class Player {
    constructor(x, y, radius, color) {
        this.x = x
        this.y = y
        this.radius = radius
        this.color = color
    }
    
    draw() {
        c.beginPath()
        c.arc(this.x, this.y, this.radius, 0, Math.PI * 2, false)
        c.fillStyle = this.color
        c.fill()
    }
}

const x = canvas.width / 2
const y = canvas.height / 2

const player = new Player(x, y, 7, 'blue')

player.draw()

html + css

<body class="bodyfont" onload='load()'>
    <div class="page-content center">
        <h1 class="title2">[Game Title]</h1>
        <canvas class="gameWindow"></canvas>
        <script src=./index.js></script>
    </div>
.....
.gameWindow {
    box-sizing: border-box;
    border: 2px solid black;
    width: 95%;
    background-color: #232323;
}
balmy sparrow
# vestal hound okay I don't really get your data model at the moment

A trip would be a single event, like a road trip.

A Vehicle would be a type of car, Subaru Impreza, and the TripVehicle tables 'quantity' would be to indicate that there are '4' 'Subaru Impreza's' on that Trip.

The Parts would be to indicate, a wheel, or engine, or door, and the VehiclePart table would be to indicate how many of said part are in those vehicles.

vestal hound
#

ah

#

okay

#

that makes sense

#

in this case

#

you need annotations + F-expressions

balmy sparrow
# vestal hound you need annotations + F-expressions

This is what I have right now, however, I cannot figure out where to put the quantity field from the TripVehicle table to get the multiples correct.

This function exists in the TripManager class.

    def get_vehicle_part_weight(self, trip: int):
        """Return a total weight of all parts for each vehicle associated to a trip."""
        return Parts.objects.filter(
            vehicle__in=Vehicle.objects.filter(
                trip__in=self.get_queryset().filter(id=trip)
                )
            ).aggregate(part_weight=Sum(F('weight') * F('vehiclepart_quantity'))
broken oar
#

How different (or similar) are Flask and Django in terms of learning them? Would one be more difficult to learn/understand than the other? I"m learning Flask, but later on maybe also Django and don't want to be surprised.

eternal blade
#

django is a bit more complex than flask

velvet yew
#

I've started with both at the same time and gave up on Flask in a few days and continued with Django (it feels a lot more modern to me)

#

From what I see Django is not really more difficult but rather you can do a lot more with all the built in stuff, i.e. it's more complex not more difficult

dapper tusk
#

Django has a steeper learning curve, but if you wanted the same features from flask, it would be no simpler

eternal blade
#

Hello, I am learning the drf framework and I have a class function based view to create a model, so I have this script to make a POST request to that end point ```py
import requests

data = {"title": "test post", "body": "body of a test post"}
res = requests.post("http://127.0.0.1:8000/api/create-post/", data=data)
print(res.status_code)
This is code of the function based view py
@api_view(["POST"])
def create_post(request):
data = request.POST
Post(title=data["title"], author=request.user, body=data["body"]).save()
return HttpResponse(status=200)
``` So when the script makes a request it is making the request as an anonymous user so request.user is anonymous user but Post.author requires a User instance, so my question is how can I make the script make the post request as an authenticated user

long jackal
#

how can I get x, y coords of a mouse click on canvas (relative to the canvas element)?

As in, I want to get the x, y coords of the click relative to the canvas, so if I click on the top left corner of the canvas, the x, y would be 0, 0.

exotic pike
versed python
dusk portal
#

hello sir

#

i have a doubt

eternal blade
#

Have been playing with drf for the past few hours, its epic

eternal blade
versed python
eternal blade
#

Will try it!

dusk portal
#

so i was learning about the drf auth token system @eternal blade and then he just told me about tokens then i created token for my admin acc then from postman i just retrieved data from the token all was fine but then he told me to make url for token by import from rest_framework.authtokens.views import obtain_auth_token then i used it as a def in placing why he told me to do that and see screenshot no.3 is the page showing something

opaque rivet
dusk portal
#

umm

#

i readed this

opaque rivet
#

that view only accepts POST requests

#

okay, so what's the issue?

dusk portal
#

ohk ik that but how will the web browser knows that

#

how can i access it

#

from endpoint

#

or it can only be accessed by

#

postman

opaque rivet
#

well, firstly you're making a GET request... that's your first problem

#

no... postman is just a client for making request. That view only accepts POST requests, do you get this?

dusk portal
opaque rivet
dusk portal
#

so how can i change my func(that is default by django ) to send post req

eternal blade
# dusk portal

I think that you need to make a POST request with a valid username and password

opaque rivet
dusk portal
opaque rivet
dusk portal
#

my settings and url are correct right?

versed python
dusk portal
#

how can i see from /

versed python
#

However in your frontend you will probably be using something like axios that can make POST requests.

versed python
dusk portal
#

btw can anyone tell what i can do with this token now

#

;-;

dusk portal
eternal blade
#

Make a function based view which makes the POST request

versed python
#

You can use the auth tab in postman to make authenticated requests.

dusk portal
#

;-;

dusk portal
versed python
#

Look it up on the internet πŸ€·β€β™‚οΈ

true kernel
#

how do i delete a table in djangp

#

actually, I have to edit a field to set null=True

#

can I do this?

versed python
versed python
true kernel
#

so i did that

#

but the currently existing table still has null = False

dusk portal
#

did u make migrations

true kernel
#

i did

dusk portal
#

and makemigrate

true kernel
#

yeah dude

dusk portal
#

umm can i see

true kernel
#

what do you wanna see?

dusk portal
broken oar
#

@eternal blade @dapper tusk okay, thanks, all!

true kernel
dusk portal
true kernel
#

i set null=True, like I said

dusk portal
#

ohk ok

#

so what's the problem

versed python
true kernel
versed python
#

But that won't delete the table!

true kernel
#

i dont really wanna deletethe table, thats the last resort

dusk portal
#

;-;

true kernel
#

if I can set null=True in that field in the currently existing table thatd be the best

dusk portal
#

and it's done

opaque rivet
# true kernel yeah

do you have anything else, such as unique=True which implicitly makes the field non-nullable

true kernel
dusk portal
#

umm then how can it be possible

opaque rivet
#

maybe you can try to change the name of the field, makemigrations and migrate, then rename it later. I sometimes have the same issue.

#

and if that doesn't work, I usually delete all the data in the table, delete all migrations and remigrate.

versed python
#

Can you show the models py you're doing this on?

true kernel
#
from django.db import models
from django.contrib.auth.models import User
from django.db.models.deletion import CASCADE

# Create your models here.
class Section(models.Model):
    name = models.CharField(max_length=5)

class Teacher(models.Model):
    name = models.CharField(max_length=100)
    avgrating = models.DecimalField(max_digits=2,decimal_places=1, null=True)
    sections = models.ManyToManyField(Section)
    

class Student(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE, null=True)
    section = models.CharField(max_length=5)
    mod = models.IntegerField()
    section = models.ForeignKey(Section, on_delete=models.CASCADE)

class Rating(models.Model):
    student = models.ForeignKey(Student, on_delete=models.CASCADE)
    teacher = models.ForeignKey(Teacher, on_delete=models.CASCADE)
    rating = models.IntegerField()
    remark = models.CharField(max_length=10000, null=True)





dusk portal
#

so bro i have learned drf crud some ,auth tokens and class basef views

#

now what should i learn

true kernel
#

im talking about the avgrating field in class Teacher

#

it looks like once a table has been created you cant edit it's columns

versed python
true kernel
#

yeah, it says this field is required

versed python
#

In the admin?

true kernel
#

yes

versed python
#

You'll also have to set blank=True for that

true kernel
#

lemme try that

opaque rivet
dusk portal
true kernel
#

it just says no migrations to apply

dusk portal
#

umm

versed python
true kernel
#

the app itself?

#

obviously

versed python
#

Can you try adding a test field to the model and see if that change is detected?

true kernel
#

thats why the tables have been created

#

i should just delete that table

#

how can I do that?

#

without deleting the whole dbsqlitefile

versed python
#

You'll have to write some Sql

#

And then delete the migrations file

#

And then makemigrations again

#

Just delete the db sqlite file and you won't have to do all this

dusk portal
#

drf is hard

#

and finding path to learn it free is more harder

#

lmao

true kernel
#

but like, when the project is big

#

if i have to make changes to the table, I cant afford to delete the dbsqlite file

versed python
#

You can

#

If its the local db

#

But look up articles on how to do it

#

My method might not be the best

dapper tusk
#

what's the output when you do makemigrations?

dusk portal
#

in that particular app u can see one folder called migrations is created and it contains some files which gives command to the db @dapper tusk

#

and migrate sends it to db

#

xd

dapper tusk
#

I am asking @true kernel

#

since there should be some output if it failed

true kernel
#

it doesnt fail

#

the migration files are simply created

dapper tusk
#

and then migrate just says there are no migrations to be done

dusk portal
#

sir can u tell me why we use caching what is caching plz

#

@dapper tusk

dapper tusk
#

in webdev specifically, you store copies of parts of your site on various servers around the world, so that people can get to them faster and you don't have to render the template anew for each request

dusk portal
#

ohh

true kernel
#

i just fount out. the admin panel is slightly fucked

#

it doesnt accept null for a manytomany field, while the shell does

dapper tusk
#

I don't think sqlite actually supports non null fields, but I am not 100% sure

versed python
#

Null for many to many doesn't make sense anyway

#

It's just am empty list at that point

opaque rivet
past cipher
#

Does anyone know if its possible to pass through an argument with URL_for, without declaring the variable inside the route? Here is an example:

@student_bp.get('/login')
def login():
  return 'Login page'

return url_for('student_bp.login', message='registration_success')

So I want to redirect to /login page, but append message to the end of the url like: site.com/login?message="registration_success"

past cipher
#

Flask

jovial cloud
tranquil anchor
#

can anyone help me with deploying django project with heroku

#

it says i deployed app successfully but sites not loading

native tide
#

Are there any good books on Django?

versed python
#

It will have useful output

tranquil anchor
#

ok

frail pewter
#

I want to use make my webcam a live stream in Django. My question is, Why an image/frame in Python needs to convert into bytes?

native tide
#

How would I sell cd keys using a site made by django

#

Im not able to find much detail on that

stark urchin
#

Where would you recommend to start learning Django? sorry if this is a common question

versed python
#

Corey schafer. Django girls. Django docs.

native tide
# tranquil anchor ok

i solve this issue because the name of your project isn't the same you have in your wsgi file, i mean the Procfile and also Procfile has to be Procfile not Procfile.file in django repo

tranquil anchor
#

yes got it

#

i named it .procfile

#

thanks

native tide
#

Hello all, may someone help with an issue i have by running my new blog with Heroku host, this is django app i did but i'm newbie, so my site is deployed but the post and comments of my blog not showing and canno't access the django interface so i'm stuck here ... https://we-are-back-to-madagascar.herokuapp.com/

prisma heart
#

```127.0.0.1/:21 GET http://127.0.0.1:8000/static/js/particle.js net::ERR_ABORTED 404 (Not Found)````
I have two folder in the static/js dir, app and particle js

<script src="{% static 'js/app.js' %}"></script>```
The app.js file is getting loaded but not the particle.js file
I'm beyond confused
versed python
bitter phoenix
#

well, it started as a webserver where i upload images, then i've mad it also as a website

prisma heart
#

The app.js gets registered tho lol

versed python
#

That's weird

#

Try a force reload

prisma heart
#

FYI: particle.js is much bigger than app.js

#

alright

#

nope didnt work

versed python
#

Also send ss of error in the console

versed python
#

I have no idea tbh

prisma heart
native tide
#

what is ws-over-h2?

prisma heart
#

ya talkin to me?

#

nvm I removed particle.js cause apparently it is not maintained and has performance issues

prisma heart
#

they dont have one

#

i think

whole kayak
#

is this good formatting

#

i am using markdown to convert a .md file to html then using flask to display the html

#

code for rendering the documentation pages

@app.route('/docs/<path:page>')
def documentation(page):
    with open(f'docs/{page}.md', 'r') as doc:
        html = markdown.markdown(doc.read())
        css = f'<link rel= "stylesheet" type= "text/css" href= "{url_for("static",filename="docs.css") }">'
        return css + html```
#

the css ```css
/* tags used h1, h2, p, ul, code, a */
body {
font: 14px/1.1 sans-serif;
max-width: 550px;
margin: 1em auto;
}

code {
background-color: #eeeeee;
border-radius: 15px;
padding-left: 2px;
padding-right: 2px;
}

limber laurel
#
RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': could not connect to server: Invalid argument (0x00002726/10022)
        Is the server running locally and accepting
        connections on Unix domain socket "/cloudsql/codeweekapi:europe-central2:codeweekapi-instance/.s.PGSQL.5432"?

  warnings.warn(β€Š

Got this error, when trying to localhost for testing the Google Cloud, not sure what exactly is causing it

#

Any help would be appreciated, I have some more info ready if anyone interested to help :), as I dont want to spam the channel with multiple blocks of text.

#

My guess is that something wring is with the host name, as jt is actually running, but not sure what exactly

fathom pewter
#

I don't have much experience with web development, so I've been looking for general info about Django and I would like to know if this framework also handles the front end. And if not, what other frameworks/modules/idk you use to take care of this part. Excuse me if this question is too basic

wicked hare
exotic pike
exotic pike
fathom pewter
#

If I only use Django, can I achieve a "nice web page" or the appearance would look too plain?

#

I imagine I would need something else to make it nicer to the user's eyes

exotic pike
exotic pike
fathom pewter
native tide
#

how to make a website using python

exotic pike
#

you cannot make a web without basic understanding of HTML at least, with CSS you can give more style to your page

exotic pike
native tide
exotic pike
#

it's an web framework based on python

#

flask is a micro framework

#

django is more complex

fathom pewter
exotic pike
#

i think if your concern is the web interface and you have no talent with UI design, i'll suggest you to just look for existing HTML template and use it on your django project, you can have a beautifull web in no time,

#

rather than creating your own template from scratch

fathom pewter
#

That sounds excellent, I will check that. Thank you @exotic pike and @wicked hare

exotic pike
#

np!

dusk portal
#

oo

young umbra
#

Hey people! Is here that i get some help about flask? I'm having trouble about executing a route that interacts with another windows application...

dusk portal
#

just ask

young umbra
#

@exotic pike
I have a script that interacts with autocad.

If i run the script works ok, but when i execute it by a flask route, works ok in the first time, if i run the route again, raises an execption.
If i restart the flask, occurs the same, in the first time runs ok, but then raises exception.

dusk portal
#

im here to rock

#

just ask

young umbra
#

there is a pythoncom CoInitialize in my code, but i'm not sure that how this works... but is needed, because if there isn't occurs a error acusing that Coinitialize wasn't called...

limber laurel
#

Gotta fet used to those

lavish prismBOT
#

@fathom crown Please don't try to ping @everyone or @here. Your message has been removed. If you believe this was a mistake, please let staff know!

exotic pike
#

at least for now

whole kayak
#

ok so if i were to make a endpoint to start installing a server should i do POST or PUT

native tide
#

hi, how do i show a popup after a user submit the required form without redirecting to a specific page

final geode
#

hello webdev homies

#

How would you go about getting these buttons to show up when i put my curser over the image

vestal hound
#

put the image and buttons in it

#

have the buttons display set to none

#

then have another selector

#

on the container's hover

#

where display is set back to some visible value

final geode
#

❀️

vestal hound
#

I just want to say

#

it's a "cursor"

#

a "curser" is a witch

#

πŸ˜‰

whole kayak
#

string manipulation ftw```py
@app.route('/docs/path:page')
def documentation(page):
with open(f'docs/{page}.md', 'r') as doc:
html = markdown.markdown(doc.read())
url = str.split(page,'/')
code = '<h1>Navigation</h1><p><a href="/docs/index">index</a>>'
uri = ""
if not page == 'index':
for v in url:
print(v)
code = code + f"<a href="/docs{uri}/{v}">{v}</a>>"
uri = uri + '/' + v
code = code + '</p> <p>'
path = os.getcwd()
print(f'{path}/docs{uri}/')
li = glob.glob(f'{path}/docs{uri}/
')
subpages = []
for v in li:
if v.startswith('_'):
continue
parsed = v.split('/')
parsed = parsed[len(parsed)-1]
subpages.append(parsed[:-3])
for page in subpages:
code = code + f'<a href="/docs{uri}/{page}">{page}</a>'
print(li)
else:
code = ''
css = f'<link rel= "stylesheet" type= "text/css" href= "{url_for("static",filename="docs.css") }">'

    return css + code + html, 200```
vestal hound
whole kayak
#

i wish there was a better way to do all this string manulipation

#

hmm i could try nested f-strings

vestal hound
whole kayak
#

what do i do instead

#

so should i do more string manulipation and make it so each h2 tag makes it's own div for it's own content

#

also now nav has it's own div

vestal hound
#

πŸ₯΄

whole kayak
#

oh yeah that exist

vestal hound
#

abstract it away

whole kayak
#

(please explain i am relatively new)

#

i am guessing though that it means put it in a function

vestal hound
#

so like

#

imagine a library

#

where you can work with HTML

#

by creating instances of appropriate classes

#

e.g.

#
body = Body(
    Div(
        H1("header goes here")
        Ul(
            Li("list item one"),
            Li("list item two")
        )
    )
)
#

wouldn't that be nice?

whole kayak
#

html -> dictionary

vestal hound
#

by defining certain classes

#

and their methods etc.

#

you can come up with more pleasing syntax

#

that allows you to express domain-specific concepts more easily

whole kayak
#

hmm nvm the html.parser is decent

vestal hound
#

you can look into Dash

#

for an example of what I mean

#

but anyway

#

so for the above snippet

#

eventually you would have a body.render() method or something

#

that would inspect the child elements

#

and generate finished HTML

whole kayak
#

ok so i probally will make a markdown -> myHTMLib since all my documentation is in .md files

inland oak
#

So, no need to reinvent the wheel

vestal hound
whole kayak
#

Reincenting the wheel is my speciality

versed python
dawn heath
#

how do I say one tactic has multiples techniques, and one technique has multiples sub techniques ?? left or right?

twilit needle
#

does anyone have experience with graphql in python?

#

I just need to do input validation which doesn't come out of the box.
It would be nice to use marshmallow to do this, but how do I abstract the validation part for every mutation?

true kernel
#

is

object_ = class_.objects.create(parameter=value)

any different than

object_ = class_(parameter=value)
object_.save()

??

next comet
#

no

#

the .create automatically does object_.save()

#

@true kernel

cold estuary
#
start = arrow.utcnow()
end= .........``` what should be the end if i need the end to be 24 hrs after this have any one used this module , here my start is from current time
limber laurel
#

Ydst

#

I cant start a thread ):

native tide
#

how to use django-rest-framework with next.js?

opal quest
#

My old laptop cant running django in windows 7 even a django 2.2. How to fix it guys

limber laurel
# native tide how to use django-rest-framework with next.js?

Welcome to the Next.js Django DRF Ecommerce Project. This Next.js Django Rest Framework project is aimed at getting you started with Next.js Django DRF moving you into more advanced topics as the project progresses. This first tutorial is most definitely aimed at Next.js and Django beginners where we cover the basics of developing Next.js and Dj...

β–Ά Play video
limber laurel
#

Like what errors are being thrown etc.?

opal quest
exotic pike
exotic pike
opal quest
limber laurel
#

Can you run pip freeze in your terminal?

exotic pike
#

Can you try pip freeze

opal quest
opal quest
limber laurel
opal quest
exotic pike
# opal quest

Can you click thet python 3.7.1 in the botom left?

exotic pike
dusk portal
#

what are the use of token authentication

#

it generates a token but what have to do then

#

can anyone plz clear my doubts

#

i have read the docs

opal quest
#

i tried to download the last python version for windows7 but it not working too

prisma heart
#

Anyone wanna help with Django and Tailwind?

distant charm
#

can someone help me with some fastapi stuff

#

i am having a very weird issue

#

nvm

exotic pike
# opal quest

It seems you using differen python with your venv..

rotund perch
#

why I am getting this error in django?

#

This is the code

opal quest
limber laurel
#

@rotund perch can you show more of the error?

#

Like where exactly is it trying to look

opaque rivet
#

@dusk portal a token relates to a user and is sent on every request. It's so that the server can identify which user is making the request.

dusk portal
opaque rivet
#

@dusk portal session tokens store information about the session, you can store key-value pairs in the token and django will handle creating those tokens.

Basic tokens are assigned to a user's account to identify their requests. They usually don't store any information like session tokens, but there are other types like JWT that can.

rotund perch
#

nvm I found the solution

rotund perch
limber laurel
#

Oh, what was the problem?

rotund perch
#

My django app was deep in so much folders, when u put Base directory it takes the first location of the folder ur in (root), so when I only put /foldername/filename it looks for root/foldername/filename and thats wrong, the solution is writing the whole path after the root /folder1/folder2/folder3/foldername/filename

dense slate
#

That's not always needed, but password-less tokens are supposedly more secure than sessions and thus becoming more popular. I don't know all the specifics of why, but that's the growing consensus.

opaque rivet
#

@dusk portal just watch a youtube guide on it

candid sonnet
#

Any idea on what resources and interpreter I can use to learn python ;-;

dusk portal
dusk portal
#

but as i cant open it on browser just seeing the stuff on postman

#

xD

opaque rivet
#

@dusk portal they are very useful... you won't go far if you don't read docs.

#

@dusk portal and for that problem you had, reading the docs would've solved it instantly. That view only accepts POST requests.

#

But sometimes docs are lacking... especially with django channels

dusk portal
#

im gonna give my 101% and will achieve greatness for sure cez of devs who help like u @opaque rivet

final geode
dense slate
final geode
#
   
    context_object_name='obj'
    template_name="detailview.html"
    model = photos
    def get_context_data(self,**kwargs):
        context = super().get_context_data(**kwargs)
        a = photos.objects.all().filter(id=self.kwargs["pk"]).values_list('photo', flat=True)
        
        image = PIL.Image.open("media/" + a[0])
        
        w,h = image.size
        print(w)
        length = 'l'
        width = 'w'
        return (length, width)
    
cold estuary
#

could any one tell why i get this error and how this can be solved

dusk portal
#

ik it happens alot to me when i was a begginer

#

show code

#

@cold estuary

opal quest
#

i've a problem. when i change localhost in django admin from 8000 to 8080 all css layout disappeared only hyper text exists. If this an error and how can i fix this guys

versed python
opal quest
versed python
#

Ctrl shift r on windows

opal quest
#

i cant. its an error from django

#

more like pgadmin4 error

dense slate
#

+1 for Realest Estate project name πŸ˜„

versed python
inland oak
# opal quest

by default linux forbids me to raise local web sites to 80 port, perhaps you've got similar problem

#

anyway...

#

try to run command...

#

python manage.py runserver 0.0.0.0:8888

#

lets try 8888 port as experiment

#

8000 port is supposed to be free though

#

but perhaps you already have there smth

#

if you would be at linux, I would have recommended to run LISTEN port finding command in terminal

#

in order to find whatever keeps the port busy

dusk portal
#

what's the correct way to cache

#

in rest framework django docs :

#
@api_view(['GET'])
@method_decorator(cache_page(60*60*2))
def taskdetail(request,question_id):
    try:
        tasks=Task.objects.get(id=question_id)
        serializer= TaskSerializer(tasks, many=False)
    except Task.DoesNotExist:
        raise Http404('OBJ NOT FOUND')
    return Response(serializer.data)```
#

in django docs

#
@cache_page(60 * 15)
def my_view(request):```
dense slate
#

Looks like you have your answer.

dusk portal
#

umm

#

ig in both

#

they are different

#

am i correct @dense slate

dense slate
#

What is your question

dusk portal
#

docs show this method

dense slate
#

You asked how it's done and then showed a solution you found. So I don't understand.

nova sonnet
#

im trying to get the count of instances related to the User object, I want to get the count for objects that are marked "completed", and the count for objects that are marked "incomplete" (bool field). I tried using a model manager but I keep on getting errors anyone have any ideas?

dense slate
#

Can you filter an object into two new variables and just count each one?

nova sonnet
#

for example I want to show for each user how many they have completed and how many they havent completed

opal quest
dense slate
#

So you might return your own custom object in the context that includes the counts and your user.

#

Although user is usually handled already in the request.

nova sonnet
#

Ive tried using a manager but i cant access them through instances

#

how would i be able to return the count and user within a custom object

dense slate
#

So you're making a query, you can take that query and get a count for true_var = query.objects.filter(is_completed=true).count() and then one for false.

#

and return both variables, and on the template just render the variables.

#

If you've already taken steps, it's easier to show your code and whatever the current problem step is.

#

I think aggregation or even a for loop might be better performance than count() but I don't recall for sure.

nova sonnet
#

class ManageCommunityView(DetailView): template_name = 'recall/manage-community.html' model = Community context_object_name = "community" def get_context_data(self, **kwargs): context = super(ManageCommunityView, self).get_context_data(**kwargs) community = Community.objects.get(id = self.kwargs['pk']) users = community.users.all() context['users'] = users return context

#

thats the view

dense slate
#

Ok and where are you trying to count?

nova sonnet
#

its in the template

#

{{ user.questionresponse_set.all.count }}

#

so how can I find the incompleted objects

dense slate
#

what's the user model look like?

nova sonnet
#

its a subclass of Abstract user with only a manytomany attribute for the communities

native tide
#

!code

lavish prismBOT
#

Here's how to format Python code on Discord:

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

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

dense slate
nova sonnet
#

it gets all of the related objects for that user

dense slate
#

I know what it does, but you just said the user model only has a communities M2M

#

So where is questionresponse_set from

#

is it a field on user?

nova sonnet
#

no only the m2m field for communities

dense slate
#

so then how are you using user.questionresponse_set

#

literally where do you return that from the server

nova sonnet
#

i had a prefetch there before but when i got rid of it, it still worked

#

i returned it in the view

native tide
#

!code

nova sonnet
#

also is there a way of doing it in the backend?

#

would using a manager work?

dense slate
#

I think you need custom template tags.

nova sonnet
#

is that the only way?

dense slate
#

I would usually handle all the math in the view.

nova sonnet
#

would using a custom manager work?

dense slate
#

I mean if it works, it works. Isn't a manager just a function you call to do something?

#

I remember using them a couple times but I don't have a lot of experience with them.

opal quest
dense slate
#

I can't remember if that will work in a template

nova sonnet
#

i dont think you can do that in a template

#

seached it up

#

but im trying to do something like that

dense slate
#

Oh

#

I think I remember making a custom method for something like this before.

#

It handled the count in a custom method on the model class.

#

And then you call that method in the template to get the count.

#

I don't have an example on hand but I have a project where I did it at home I can send in the evening maybe.

#

But if you look for that kind of solution you might find what you want @nova sonnet

nova sonnet
#

if you can send me an example that would be awesome

dense slate
#

I think it's something like, do the math in the method that returns only true, or only false, depending on what you want, and then call it like {{user.questionresponse_set.all.custommethod() }} in the template

#

something like that

#

But I think you need to do it on one item, so do it in the a for loop.

nova sonnet
#

ill try it out then

dense slate
#

I had to count positive or negative reviews and did it this way.

#

This is along those lines

#

The accepted answer

nova sonnet
#

something like that?

dense slate
#

Yea that looks right

nova sonnet
#

i love you man

#

works

dense slate
#

❀️

#

Glad to hear it.

nova sonnet
#

Thanks for the help man fully appreciate it

forest berry
#

When u send a POST request when filling out an HTML form, does it basically mean ur using an a rest api? (Sry if question is dumb I’m a beginner)

#

Also say I make a make a login/register system on Flask and save the username and password directly into the database when they register. Is there any benefit for using a REST API to transfer the data to the database rather than storing it directly?

native tide
#

!code

lavish prismBOT
#

Here's how to format Python code on Discord:

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

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

ionic raft
dense slate
#

You're essentially doing the same thing in the end, but REST allows you to decouple your front-end so that you can just hit API endpoints.

#

Without REST, you're essentially doing a CRUD setup.

ionic raft
dense slate
#

It's a good habit to get into (REST) in case you work with others on a project.

ionic raft
#

Even got filtering working on a list view...So awesome to see these features working and being built so rapidly...

dense slate
#

Nice. πŸ™‚

ionic raft
#

Frickin LOVE Django though....amazing stuff

dense slate
#

Yea, it's my fav as well. Currently using it with a React front-end.

#

You have a python background before coming to web dev?

ionic raft
#

Come to think of it, I've not been stuck for more than 2 days on a problem.
OH, React is my next go to. I'm doing the back-end first, and then learning React to build a diagramming tool for the 7th and final app in Phase 1 of LanesFlow.

No, didn't know Python before Apr 15, 2021. I'm living proof at age 50 that you're never too old to learn to code.

dense slate
#

That's right, it's never too late.

ionic raft
#

When I started down this path I had NO CLUE how to implement this idea. It's nearly 4 months later and even though I have NO CLUE if I can build the diagramming app I've already got enough substance to put something out there that will be fascinating

#

I hear React has great diagramming libraries though...So, promising. I'll have the back-end data structure and forms built for the diagramming wizard and object editor I have in mind

#

It's the diagram editor on the front-end that I'm really curious about...

versed python
ionic raft
#

The diagramming front-end component is phase 1B. I'll still be able to launch Phase 1A in a few weeks, assuming all goes well.

versed python
#

What do you mean by diagramming exactly?

#

What kind of diagrams

ionic raft
#

Hmmm...Good question. I've spent the past 20+ years refining a mapping methodology I call, Collaboration Mapping. I presented it at the 4th Canadian Quality Congress in 2012 and since then have refined an algorithm for teaching pretty much anyone how to read and draw one. LanesFlow will include a wizard to build a Collaboration Map for you (get newbies started) and a designer to build from scratch or edit. If you're familiar with process mapping, swimlanes, it's similar, except there is an element for collaboration. The language has 7 symbols total. Think draw.io but with a very focused stencil...it that makes sense.

#

I've used Collaboration Mapping to form the requirements documentation for seriously large information automation systems. It's a powerful visual language because it captures responsibility, accountability, flow, reporting, consulting and collaboration.

#

And I can pretty much teach anyone to read a Collaboration Map in less than 5 minutes...

versed python
#

Ah so it's a business oriented methodology of kinds?

#

Like team work stuff i suppose?

ionic raft
#

Yup...any organization that has a goal of repeatable work can benefit from it. It clarifies team work.
The word Lanes in LanesFlow comes from the visual of a Collaboration Map where you have lanes for each job role...

versed python
#

Ah that makes sense

#

Good luck 🀞

ionic raft
#

Thanks. It's exciting that's for sure. There's nothing like this out there...

dense slate
#

Especially forms. That is all done on the front end.

#

But I love the enthisuasm.

#

My first Django-Python project was a MUD.

ionic raft
# dense slate Careful how much you do if you plan to build the front-end. All you need are API...

I've not built the forms for the diagramming app yet. However, forms are crazy easy in Django so it's not an issue. However, from the perspective of the app build I will likely get into learning React/JS first, and then build it out as my learning project. Based on what I can do in React that will drive the model design back end.
I'm REALLY hoping for the ability to do repeating-sections in forms

ionic raft
# dense slate But I love the enthisuasm.

And then enthusiasm is effortless when you have an idea you believe in, have 2+ decades of experience in the concepts behind the idea, are able to execute on the idea, and even have clients coming up at the end of August who will serve as your first alpha testers

forest berry
#

Wait so in my understanding, you would only need to make an API for login/register if you want to expand your website into a mobile app, so that you can access the database on the mobile app to check if the username and passwrd is correct. Am i right?

dense slate
#

Right

#

Your front-end will essentially live independently and talk to those endpoints.

forest berry
#

Got it, thanks! @dense slate so since im just making a simple web app with the login/register system, I can just allow the website to speak directly to the database to check user authentication. No need to make a rest api right?

tranquil anchor
#
           raise processed
       whitenoise.storage.MissingFileError: The file 'css/bachstreet_app/"{% static 'images/bachstreet_app/frog.gif' %}' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f7f3e554460>.
       The CSS file 'css/bachstreet_app/home.css' references a file which could not be found:
         css/bachstreet_app/"{% static 'images/bachstreet_app/frog.gif' %}
       Please check the URL references in this CSS file, particularly any
       relative paths which might be pointing to the wrong location.
 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.
#

Can anyone help, im trying to deploy my django project on heroku

#

apparently whitenoise cant find my static files

dense slate
forest berry
#

I don’t really know much abt web dev

nova pewter
#

hey, does having a project under a project fine for django?

#

is this considered as a bad practice?

dense slate
opaque rivet
#

@nova pewter if theres a reason for it, sure. I have multiple projects in one repo as they're all microservices to my app.

nova pewter
#

alright, thank you

manic frost
#

Does anyone know why Starlette redirects paths that don't end with / instead of just parsing the URL as if it had a / at the end?

vestal hound
#

I know it is in Django

manic frost
#

That's not something terrible, it just seems like an extra request

vestal bridge
#

What technology would someone recommend to produce a matplotlib-like animation of many dots moving around on a website

cursive sorrel
#

urgh being daft here but how can I find a '/' symbol in a strong without it causing an EOL issue

#

For the life of me character.index('') doesn't work

#

ahh.. I can escape the escape character

#

print(character.find('\\'))

heavy nexus
#

hi this is harsha while i was working on websocketapp for ever loop is not running and it showing an error in on_error which is a class function and also given as a argument in websocketapp, can somebody plz help me with this

dusk portal
#

whats the error

#

n all info

#

can u elaborate?

heavy nexus
#

ya please see this

dusk portal
#

which module r u working with

heavy nexus
#

websocket and threading

dusk portal
#

ohh

dusk portal
heavy nexus
#

ok

dusk portal
#

umm btw what project r u working in that u need websockets @heavy nexus

#

i mean what u r trying to build

heavy nexus
#

im building a treading bot

ionic raft
#

oh my goodness....this web app...it is moving fast! Had massive inspiration today. App 2/8 is about halfway done...

dusk portal
heavy nexus
#

ya

ionic raft
#

Hey. How did your pword reset issue go?

dusk portal
dusk portal
heavy nexus
#

nope

ionic raft
#

Not as yet.

heavy nexus
#

im learnig through udmy but i got stuck in the middle

dusk portal
dusk portal
# ionic raft Not as yet.

in ur proj umm what what things r u using im just curious about topics just name them - example pagination sign up n all

ionic raft
#

Hmmm...Well...quite a bit already. Got some pagination. sign up/sign out/pword reset, task app, profiles for individual/Org/Team, stripe connection for multiple subscription tiers, dynamic page builds driven by subscriptions, articles, processes for teams, projects for processes...

dusk portal
#

stripe connection for multiple subscription tiers, dynamic page builds driven by subscriptions, this is what idk

ionic raft
#

The above screenshot is the design for the project module...
I'm also going to use task automation and a self-selection by the user for their experience level with process improvement. That will drive how much training I automate at them

dusk portal
#

i can load dynamic page as per subscription but

dusk portal
#

r u using pure django or django channels or rest framework @ionic raft

ionic raft
#

There are five different subscription tiers. One is free. The other four are paid. The four subs connect to Stripe. When it succeed, their membership level is updated and they see applications that they've paid for.
Pure Django...until I turn to React for the diagramming app

#

It's over 5,600 lines of Python already tho

dusk portal
ionic raft
#

and around 4,000 lines of html/css

dusk portal
ionic raft
#

Yes. I'll use Rest for React. All good

dusk portal
#

how many apps

ionic raft
#

Hmmm...I think there are going to be about 14 apps all told.

dusk portal
#

why i dont get ideas uuf

ionic raft
#

πŸ˜„
I've been a business consultant for 25 years. This idea comes from the work I've done and the stuff I've innovated. It didn't come overnight.

#

The LanesFlow app is aimed at the business market. Any business that wants to grow, increase profits, happier customers, improved quality...LanesFlow is for them. No matter how small. That's why there's a free subscription tier

#

But today...oh today...some amazing ideas came through! I am so excited at what's happening with LanesFlow

ionic raft
# dusk portal and im 16

You're in great shape πŸ™‚ Plenty of time for the great ideas. They'll come. If you believe you'll achieve!

dusk portal
#

todo app

#

todo app with auth

#

blog app

#

contact page app

#

taskmanager app , ecommerce app

#

blog app with auth

#

umm

versed python
dusk portal
#

can u plz gimme any idea that i can really show people

#

@versed python

versed python
#

I plan to make a website where you can type words and it'd generate images related to it.

You can try that or something similar.

#

Though thats hardly a web dev project, it's in the AI analysis I'm interested in.

#

!projects

lavish prismBOT
#

Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

dusk portal
#

lol is that web dev damn

#

@versed python

versed python
#

Thats what im doing rn

dusk portal
#

ohh

#

thats good idea

#

btw r u too from india sir @versed python

versed python
#

Yeah, Delhi

dusk portal
#

nice

dusk portal
grave raft
#

how can i filter in django by foriegn key of foreign key

versed python
#

2nd

dusk portal
versed python
dusk portal
#

i want ur help bro plz can u @versed python

#

or @ionic raft

ionic raft
#

It's 2 am here and I'm about rdy for bed. If I can help I will...but will need to be quick

dusk portal
#

later

#

just a suggestion nothing else

#

will get it dont worry

ionic raft
versed python
dusk portal
#

tc gn

#

and thanks

versed python
dusk portal
#

πŸ˜‚

#

Sry my bad

long geode
#

Greetings all!
I'm working on a little todo web app, and I've got a question about best practices.

I'm currently trying to sort out a structure problem when it comes to local storage.

When dealing with information in local storage, is it best to:

  1. Be storing things in a single large stringified JSON file?

Then, when I something needs updating, the whole string gets changed and updated?

  1. Break up the data into smaller stringified JSON files and access them when needed?

I think it's probably this one, simply because it's still working with a small number of key value pairs in the local storage.

  1. Have the local storage hold every object separately?

I can see this one being correct as well. But I'm still fairly new to web dev, so I don't know how much I should be bouncing info back and fourth from the local storage.

Or is there another option?

quick cargo
#

And with regards to local storage on the client side, only store non-secure data that you dont care if it gets leaked, copied.

long geode
#

Okay. I hadn't thought of that. Thanks!

ionic solar
#

Hi people. I'm using django framework. I have several models with BinaryFields in them. Is there a way to create/update records of such models where I can somehow enter BinaryField values in hex notation (0x...)?

lavish prismBOT
#

@inland oak :white_check_mark: Your eval job has completed with return code 0.

0b100000
ionic solar
#

yeah sure, I know how to convert to/from bin from/to hex. the problem is to somehow make django admin form to successfully display the binary fileds as hex and parse hex when saving to binary fields

inland oak
#

uh. I got it

ionic solar
#

I already know I have to set the editable to true

inland oak
#

you are trying to have some custom form field

ionic solar
#

yes

inland oak
#

shrugs, it is surely possible

#

but exact syntax I can't provide

ionic solar
#

got any hints for the logic?

versed python
#

youll have to override the widget logic probably

inland oak
# ionic solar got any hints for the logic?

class MyModelForm(forms.ModelForm):
    icon = forms.ChoiceField(choices=[('1','1'),('2','2'),])

class EngineAdmin(admin.ModelAdmin):
    list_display = (
        "__str__",
        "name",
        "visible",
        "icon_tag",
    )
    form = MyModelForm


admin.site.register(Aggregator, EngineAdmin)
#

search for overrides of the form with MyModel
it allows overriding behavior for particular fields
i used it before to override CharField with ChoiceField for admin thing

versed python
#

before you waste time actually implementing this, you should think if you really need to do this. afterall the admin is not accessible to general public.

ionic solar
#

I could do it through the rest api but I would then have to also implement admin roles.

#

I purposely kept admin actions separate from the api so far

#

if I do it through the api I would then need to push the frontend guys to do a web-client for admins as well

ionic solar
winter adder
#

Hello everyone, I am Adamson a backend web development enthusiast

#

I would really appreciate it if I'm enlightened on the field

inland oak
#

turning lamp on and directing to @winter adder so he could be enlightened

graceful flax
#

Hi, I had a query, I've my application with users and unique usernames. I've my analytics service, for me to identify users, the analytics service requires a unique ID, is it good to use the usernames?

I'm on django with postgres or should I generate a separate unique id for the sole purpose of analytics

inland oak
#

Username can change
Primary id is changed...more rarely

inland oak
glacial yoke
#

wtf, it just fixed itself, I'm actually gonna kill myself

fringe cave
#

Hello. I am trying create an abstraction for flask, django from an fastapi application ...? Can someone help me, I don't know where to start ?

stark axle
#

writing filesharing site with flask+pymongo. Need to ensure no existing content will be overwritten on the upload of new file with same name. Any recommendations about how to achieve that?

I've thought about overwriting (original name will still be saved in database) uploaded file's name with some gibberish, leaving only original extension inact (like - you upload image.png and get download link that points to asd234.png) - not sure if its the best approach tho

mystic vortex
#

Any web dev here?

hollow minnow
mystic vortex
eternal blade
#

You can use a backend framework like django/flask

mystic vortex
#

@eternal blade Well Hey I have a question about ruby

eternal blade
#

Sorry, I don't know ruby ruby

mystic vortex
#

Ok so any other language that has the discord Library@eternal blade

eternal blade
#

Javacript, c sharp, java

hollow minnow
#
  • in JS, const cannot be reassigned
  • link elements are not used to add hyperlinks (it's a)
  • external stylesheets make it easy to update multiple styles at once? weird question idk what to answer
  • order of items in an array does matter
    rest looks ok
eternal blade
graceful flax
hollow minnow
#

@wintry gate i answered ur q

inland oak
#

If you wish them bigger

dusk portal
#

Umm

#

Have u guyz tried ds algo?

#

@eternal blade

valid void
#

Hello everyone, I'm working hard on Django and I want to be able to create entire web projects on my own. But I'm very bad in front-end dev (I know how to create a simple web page, HTML tags, CSS, JS etc). Do you know a good way to easily create front-end pages to use in django ? Thanks !

eternal blade
hollow minnow
#

oh I misread the external style sheets thing, it should be true I think

hollow minnow
#

Yeah fuck double negation :p

late creek
#

but idk maybe allot of folders can create allot of unneeded writes/reads

native tide
#

Is Django an alternative for Js?

late creek
native tide
#

I'm not exactly sure what Django does

late creek
#

Django is a framework for serving pages that can communicate with a backend

opaque rivet
#

@late creek Django is the backend

late creek
#

yep

native tide
opaque rivet
#

@native tide HTTP requests do that. Django is a backend framework which is the server for your web application. The other side is the frontend, which you can do with simple html (and you can serve these pages with django) or the frontend can be designed with a JS framework.

native tide
#

Like let's say I had a variable in python. I could move that same variable to javascript or something like that?

native tide
late creek
late creek
opaque rivet
#

@native tide yes - the frontend client can retrieve data from the backend server. You're on the lines to describe an API.

native tide
late creek
opaque rivet
#

Webflow is terrible and isn't developing anything, you're just fitting into their templates

native tide
#

I think he just wants to put his Django knowledge to use

#

Without learning a whole new language and getting good at it

late creek
#

well he wants to write smt easily, so I'm just suggesting I don't like em either lmao

valid void
#

I'll see what I'm able to do with Bootstrap Studio. Tutorials and Demo are looking crazy

native tide
#

I mean if react is easy u could do that

opaque rivet
#

@native tide APIs are for applications to communicate with eachother... so it can be between the frontend and backend, think of them as seperate entities.

late creek
native tide
valid void
#

@late creek I'll create my own company, so I'll be able to buy Bootstrap Studio with my business

opaque rivet
#

They are seperate if you use a JS framework. Django has templating which bridges that gap.

opaque rivet
#

@valid void if you're a student, you can get it for free with github student

#

Or just buy a .edu email for $1

dense slate
#

Django is a web framework that runs a server, allowing you to code the backend in python while delivering html templates as the "frontend" of the framework.

native tide
native tide
late creek
native tide
#

Me too

valid void
#

Hahaha

valid void
#

He opened Pandora's box with .edu email

dense slate
#

What don't you get?

native tide
#

What you just said

#

Like what does it mean exactly by coding the backend

dense slate
#

You code the server in python. The Django framework uses something called "templates" which are just html files. You put your website together in the html files and the python-based server makes it all happen.

native tide
#

What part of a website is front end and what is back end

dense slate
#

The html/javascript is the frontend. These are referred to as templates.

#

You can also use a framework like React/Vue to get more advanced.

opaque rivet
#

Frontend is what the user sees. Backend is the server.

dense slate
#

Right, basically.

late creek
#

frontend is (HTML, CSS, JS)
backend is everything written in the .py files

late creek
native tide
#

Ok so basically let's use Netflix as an example. The front end would be the display of all the shows. The back end would be the algorithms to show the recommended shows and stuff

opaque rivet
#

@native tide yes

dense slate
#

Sure, yea.

native tide
#

Ok so why do you need Django for that? Isn't that literally what python does

late creek
#

the database logic, the user authentication, that all backend

dense slate
#

Even fetching the data from the database, the frontend requests data from the database via the backend code.

dense slate
#

Django is a framework that allows you to do that in Python.

#

Python itself doesn't do what you need to display a web app/site.

native tide
late creek
dense slate
native tide
dense slate
#

But we also said that it communicates with the backend to get the data and actually serve the pages.

native tide
#

Yes

#

So Django does that?

dense slate
#

Right

native tide
#

Oh ok

#

So basically it's like an api

dense slate
#

You can read about MVC frameworks

#

That's what Django is.

native tide
dense slate
#

It's an API to your code, but Django itself is the web server. Someone created it so you don't have to.

#

It's like a car. You can build one, or go buy one.

native tide
#

Oh ok

dense slate
#

But either way you need one to go drive.

late creek
#

@dense slate have you tried using pyramid? it another web framework for python

dense slate
#

Nah, I'm a Django fanboy. πŸ˜„

#

I'm more focused on front-end these days, so Django serves my python needs.

late creek
#

ahh yeah I'm the opposite I'm more into backend, so I use flask I don't like Django all that much cuz it way too bloated for me

dense slate
#

Looks kind of flask-esque?

late creek
#

yeah

#

it like Django and flask had a baby

dense slate
#

Is there any perfomance improvement with Flask or Pyramid over Django?

late creek
#

idk about pyramid, but when using both flask and Django, I find it much easier to deploy my apps with flask, and it can handle more requests without using much resources from my experience

dense slate
#

Django is meant for scale, so I would be surprised to see that Flask outperforms it. I just haven't seen the data.

#

But either way, whatever tool suits your needs, that's the one to use.

late creek
#

yeah it more catered to big cooperations I would think, I don't think Pinterest would use smt like flask

#

and yep whatever makes your job easier for you

dusk portal
#

So do it @fair shale

opaque rivet
#

what type of encoding is this format? I can't find it online

#

\xf7&\xf8\xbd^\xb5d\xe0\xecE\xe8\xcb\xfe\xf5\xab\xfc\x7f\xff\xd9

inland oak
#

decided to chase devops as secondary direction

#

it is like multiplying the power of the backend

#

xD feeling myself like a character from MMORPG game

#

who puts leveled skill points into different skill trees

mystic wyvern
#

Is it possible to change design of the form in Django? I've created a form which extends UserCreationForm because I want user to add more data?

dense slate
#

Like, how the inputs look or what?

#

You can make it look like what ever you want.

mystic wyvern
#

but i can't give it a class

#

like here how can i edit it with css use classes with it

dense slate
#

CSS should go in your static files and then you apply it as a class in your html.

#

If you're doing templates.

#

Or you can do inline css right in your html, but not advised.

#

And you need to import the CSS in your html head.

mystic wyvern
#

how in this case ?

dense slate
#

Do you know how to apply css?

mystic wyvern
#

yes

dense slate
#

So what have you tried and what is not working?

mystic wyvern
#

how can i edit a specific element like inputs or lables?

#

And give a class to each of them?

#

@dense slate

valid void
#

@late creek I bought BootstrapStudio, it's fcking amazing man, what a big big tool to create front-end pages

#

I just have to create an example page, export it to my django server and it's already op

late creek
valid void
#

I'm currently using a VPS to develop my Django project, so I need to find a good way to host this

#

If someone have an idea... I need to read it !

lunar stream
#

Can someone help me out scraping a website?

opal quest
#

I need some help guys, why my variable password2 keep saying that data is keyerror when i tried to signup account

valid void
#

Maybe change quote to single quote (" " to this ' ')

#

And check if your field is correctly named "password2"

opal quest
#

ok i found the solution. But its still error cause of CSRF Cookie not set, now im confused cause no solution in stackoverflow can solve this

valid void
#

Just after your form you have to add "{% csrf_token %}", a protection against Cross site request forgery

velvet yew
#

Can you make an HTML form use the input text field as a query parameter (without JS)? For example:

<form action="?test=value">
    {% csrf_token %}
    <input type="text">
    <input type="submit">
</form>

I'd like whatever is put in the text input to go to value

opal quest
#

I develope website with react native and django + sass so i dont know how to put that {% csrf_token %} in js file

valid void
#

@velvet yew Why you just don't put a action="", and in your views.py you put a if request.method == "POST" and you redirect with the data of text value ?

cursive pine
dense slate
valid void
velvet yew
dense slate
cursive pine
#

Has anyone put Turtle drawings into a web site using Flask? I'm making turtle drawings using some user input. I want the final drawing to be displayed on a web page.

dense slate
#

Although it's kind of funny because I write everything inline in React. πŸ˜„

valid void
#

Just put an onclick on your form button that change the action value

velvet yew
#

I haven't used a single line of JS in the entire project do I really have to ruin it just to be able to go to an URL lol

#

I can use an a tag too if there's a way to change it with user input

valid void
#

For me the best solution is to create a single views.py function that will get your text value and just redirect

velvet yew
#

I just want to redirect to ?test=whateverusertypedin

late creek
#

it good for development

valid void
cursive pine
dense slate
#

I never used it.

late creek
#

same

cursive pine
#

damn!

valid void
#

@velvet yew Just adapt the function to whatever you need to display when user is redirect

#

Your form is created when the webpage is loaded, you can't edit it when you're clicking on the button, it's too late

#

Maybe there is a good solution not using JS but I don't have it, sorry !

velvet yew
#

Is there any other way perhaps something that doesn't involve forms at all? Really all I need is it a button that links to ?test=x but x should be based on the text input

#

Is HTML really this lame lol

clear bone
#

hi guys i have a quick question about static files, this is my settings.py file for my project

#

this is my file directory

#

when i try to load static file in my template i get a 404 error in command prompt and the image doesnt load on the page

#

is there something incorrect that i did here?

velvet yew
clear bone
valid void
#

@clear bone Have you created your STATIC_ROOT url ?

clear bone
#

no i have not

velvet yew
#

Oh wait you're missing the folder

#

It has to be /static/app/file.jpg

#

And then in the URL app/file.jpg

clear bone
#

this is what you mean?

velvet yew
#

Yes

valid void
#

Yes

clear bone
#

hmm still not working

valid void
#

Is your app in Debug = True or False ?

clear bone
#

true

late creek
#

put your static folder where the manage.py file is

valid void
#

I think it's already done as I saw

late creek
#

hmm vscode explorer is confusing

valid void
#

Yeah it's not very explicit

late creek
#

in the terminal