#web-development
2 messages Β· Page 179 of 1
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:
think you accidentally put ] instead of } to make it a template action
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
what does the rendered html look like?
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')
send a ss of your console with requests and xhr enabled and reload the page
see what it's requesting data for
what's xhr?
I cant remember the name lol
How do I enable it?
basically im just talking about having this checked^
Yeah, where do I do that? sorry I'm kind of a beginner at this thing
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
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
this is what it says
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?
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
you're getting a 404
which means the server is saying that the file doesnt exist in that path
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' %}">
what is your static file like again?
Do you mean the folder?
yes
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
hmmm
shall I just try to include a different path in main html?
does the admin site load the css content and that correctly?
yep
Hey! Is it better to use local storage or S3 bucket for storing static files in django?
mostly personal preference, but generally its not a massive bonus using it over local storage
It's so annoying how I'm always the special one, cos I can never find a fix for my problems lmao
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
@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
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.
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
Thanks for your reply it make me somewhat clear but I thought as I am learning ml with python so choosing python for backend cna help me
Yeas I want to learn both backend and frontend dev so what would be your suggestion now
best job prospects -> learn cobol 
@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
@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
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
@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
Because of that I think is better learning that language wich gives you a job. And after that you will learn working in real projects.
what your view for python is it a good choise for getting a good job?
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.
@outer lotus thanks
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.
what's your question?
Added the details above.
uh
if I understand you correctly
Parts.objects.filter(car__trip=trip).aggregate(Sum('price'))?
wait
hwo does the quantity figure into this
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?
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
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;
}
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.
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'))
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.
django is a bit more complex than flask
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
Django has a steeper learning curve, but if you wanted the same features from flask, it would be no simpler
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
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.
Have you tried something and doesnt work?
The same way you're authenticating the frontend. Probably authentication tokens. Just login first and then send the authentication token obtained along with the request.
same
hello sir
i have a doubt
Thanks, I'll try that
Have been playing with drf for the past few hours, its epic
Ask it here
Try graphql then, its even more so.
Will try it!
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
The obtain_auth_token view will return a JSON response when valid username and password fields are POSTed to the view using form data or JSON:
{ 'token' : '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' }
from the docs:
https://www.django-rest-framework.org/api-guide/authentication/
Django, API, REST, Authentication
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
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?
im not making any req see the code ss 1 and 2 it's default by django
yes ezz to understanfd
.
so how can i change my func(that is default by django ) to send post req
I think that you need to make a POST request with a valid username and password
Just as the docs say, you make a POST request to the endpoint with the credentials then parse the JSON response for your token.
but if it's not showing anything how can i
what's not showing anything? Show us a screenshot
my settings and url are correct right?
You can't obtain the token via the browser since when you visit a website, only GET requests are made.
thats what im saying
how can i see from /
However in your frontend you will probably be using something like axios that can make POST requests.
You can't via the browser. Use postman
this is what i wanna say @opaque rivet @eternal blade
btw can anyone tell what i can do with this token now
;-;
yes using and it;s working
Make a function based view which makes the POST request
You can use the auth tab in postman to make authenticated requests.
but in that how can i render token
;-;
hmm btw im not that familier with postman
Look it up on the internet π€·ββοΈ
how do i delete a table in djangp
actually, I have to edit a field to set null=True
can I do this?
Delete the class from models.py
Yes just do it
did u make migrations
i did
and makemigrate
yeah dude
umm can i see
what do you wanna see?
the admin panel and what u to delete in models.py
@eternal blade @dapper tusk okay, thanks, all!
i didnt delete anything in models.py
;-;
i set null=True, like I said
On a field?
yeah
But that won't delete the table!
i dont really wanna deletethe table, thats the last resort
;-;
if I can set null=True in that field in the currently existing table thatd be the best
so null=True then , makemigrations and then migrate then reload
and it's done
do you have anything else, such as unique=True which implicitly makes the field non-nullable
nothing like that
it says nomigrations to apply
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.
Can you show the models py you're doing this on?
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)
so bro i have learned drf crud some ,auth tokens and class basef views
now what should i learn
im talking about the avgrating field in class Teacher
it looks like once a table has been created you cant edit it's columns
Have you tried creating a Teacher with None as avgrating? Are you getting any error?
yeah, it says this field is required
In the admin?
You'll also have to set blank=True for that
lemme try that
continue with auth tokens and use them in a project.
till now idk the use of them idk why im learning that bro they just generate token for every login ;-; what's the use
it just says no migrations to apply
that's for you to learn...
umm
Do you have it in your INSTALLED_APPS?
Can you try adding a test field to the model and see if that change is detected?
thats why the tables have been created
i should just delete that table
how can I do that?
without deleting the whole dbsqlitefile
Manage.py dbshell
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
true
but like, when the project is big
if i have to make changes to the table, I cant afford to delete the dbsqlite file
You can
If its the local db
But look up articles on how to do it
My method might not be the best
what's the output when you do makemigrations?
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
and then migrate just says there are no migrations to be done
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
ohh
exactly
i just fount out. the admin panel is slightly fucked
it doesnt accept null for a manytomany field, while the shell does
I don't think sqlite actually supports non null fields, but I am not 100% sure
Null for many to many doesn't make sense anyway
It's just am empty list at that point
everything is there to learn for free. read the docs.
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"
Are you using framework?
Flask
You're on the right track. The code should be:
def login() :
#whatever comes before
return redirect(url_for('your_routename',message='your_parametervalue'))
can anyone help me with deploying django project with heroku
it says i deployed app successfully but sites not loading
Are there any good books on Django?
ok
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?
How would I sell cd keys using a site made by django
Im not able to find much detail on that
Where would you recommend to start learning Django? sorry if this is a common question
Corey schafer. Django girls. Django docs.
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
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/
```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
Send a ss of the js directory
https://github.com/Daishiky/website
this is the first website that i create, if someone has suggestions on how to improve it, please make a pr 
well, it started as a webserver where i upload images, then i've mad it also as a website
Also send ss of error in the console
I have no idea tbh
particle.js is just a copy of the file in this lib https://github.com/VincentGarreau/particles.js/
what is ws-over-h2?
ya talkin to me?
nvm I removed particle.js cause apparently it is not maintained and has performance issues
Just use their cdn then
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;
}
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
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
yes it does. It follows the mvc pattern so you can build a full web app using Django alone. Would highly recommend it.
Yes you can create fully functional web with Django Framework alone, however if you intend to create more interactive / dynamic user interface you might also need to use some javascript...
just create a thread for this question and put more info..
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
Are you familiar with HTML & CSS? if not, i suggest you to learn the basic first... after that, you can continue to learn python, and then Django..
if you need an example you can look for html template on themeforest.com, you can use any of them or achieve the similar result on your django project.
Not really. I would say I have experience with Python, so that's why I was wondering If with "pure Django" would be ok or it would be better to learn HTML/CSS
how to make a website using python
you cannot make a web without basic understanding of HTML at least, with CSS you can give more style to your page
you can use flask /django.
what is it explain a little bit
it's an web framework based on python
flask is a micro framework
django is more complex
I mean, I know a little HTML because I did some web-scrapping, but I don't think that's enough, is it?
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
That sounds excellent, I will check that. Thank you @exotic pike and @wicked hare
np!
oo
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...
go for it!
just ask
@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.
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...
Oh, right threads, forgot about those, thanks π π
Gotta fet used to those
@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!
its not a mandatory tho...
at least for now
ok so if i were to make a endpoint to start installing a server should i do POST or PUT
hi, how do i show a popup after a user submit the required form without redirecting to a specific page
you need JS for that
hello webdev homies
How would you go about getting these buttons to show up when i put my curser over the image
make a container
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
β€οΈ
btw
I just want to say
it's a "cursor"
a "curser" is a witch
π
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```
I feel physically ill π₯΄
i wish there was a better way to do all this string manulipation
hmm i could try nested f-strings
if not x == y is a sin btw
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
oh yeah that exist
yes
abstract it away
(please explain i am relatively new)
i am guessing though that it means put it in a function
okay
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?
html -> dictionary
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
~~pythons html library is weak https://docs.python.org/3/library/html.html~~
hmm nvm the html.parser is decent
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
ok so i probally will make a markdown -> myHTMLib since all my documentation is in .md files
Basically jinja2 library is for this
So, no need to reinvent the wheel
ILOVEREINVENTINGTHEWHEEL
Reincenting the wheel is my speciality
Unlike spelling?
how do I say one tactic has multiples techniques, and one technique has multiples sub techniques ?? left or right?
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?
is
object_ = class_.objects.create(parameter=value)
any different than
object_ = class_(parameter=value)
object_.save()
??
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
how to use django-rest-framework with next.js?
My old laptop cant running django in windows 7 even a django 2.2. How to fix it guys
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...
Could you be more specific?
Like what errors are being thrown etc.?
Every django modules in import could not be resolved from source in vscode. I think the problem that windows 7 too old for every django versions
What do you mean by how?
Provide what you do and what is the result, the error message etc, othewise no one can hepl you.
Can you run pip freeze in your terminal?
Can you try pip freeze
I still cant figured out what pip i missed to fix that django errors
Is that the output of the pip freeze?
yes
Can you click thet python 3.7.1 in the botom left?
Are you running on thr right environtment?
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
i tried to download the last python version for windows7 but it not working too
Anyone wanna help with Django and Tailwind?
It seems you using differen python with your venv..
how can i fix it pls help
@rotund perch can you show more of the error?
Like where exactly is it trying to look
@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.
Bro but
What's the difference between This Session(idp) method and token method
Just the token do 1 more thing it sends the token and before it
It asks for username and password and that's session method Authorization
@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.
nvm I found the solution
ty
Oh, what was the problem?
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
Tokens are also mainly important for connecting your website with external APIs (using multiple microservices). For example, if you want someone to be able to login to your website, and with the same token-auth go to a second website without having to have separate credentials, you can share the credentials between multiple sites.
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.
got it
got it too
@dusk portal just watch a youtube guide on it
ohhk got it
Any idea on what resources and interpreter I can use to learn python ;-;
yes bro docs arent that useful in web dev specially the practical part
i saw series on drf by JustDjango , in 1st he told about serializers and all the @upbeat sigil_view and the cbv and in 2nd showed us crud , and in 3rd i saw token auth (adding to settings.py then to installed app and then making a view that's imported and in 4th mixins
but as i cant open it on browser just seeing the stuff on postman
xD
@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
damn!! but that's my next target
im gonna give my 101% and will achieve greatness for sure cez of devs who help like u @opaque rivet
Yea i would say that you sort of have to learn how to use docs. I never used to read them either unless Google led me to them but now that i understand the benefit, it really should be the first place to go with new frameworks or libraries.
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)
could any one tell why i get this error and how this can be solved
this means ur code has no return statement
ik it happens alot to me when i was a begginer
show code
@cold estuary
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
How exactly did you change the port?
python manage.py runserver 8080
for some reason my 8000 port number got the WinError 10013 and i still try to fix it by relpace the 8080
Try force reloading
Ctrl shift r on windows
i cant. its an error from django
more like pgadmin4 error
+1 for Realest Estate project name π
Try restarting your pc
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
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):```
Looks like you have your answer.
What is your question
how to cache in django rest framework
docs show this method
@dense slate
okay done that
You asked how it's done and then showed a solution you found. So I don't understand.
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?
Can you filter an object into two new variables and just count each one?
but i want them to be related to the user instance
for example I want to show for each user how many they have completed and how many they havent completed
Cant do. seems like i've to create a new folder again
So you still do your math on the backend and just render the context on the page where you want to show it.
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.
Ive use prefetch_related to get the objects from the other model, and i can get the count for every instance but I cant get a count for all the instances that are marked "incomplete", Im trying to display a table of each user within a group and all of the data related to them.
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
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.
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
Ok and where are you trying to count?
its in the template
{{ user.questionresponse_set.all.count }}
so how can I find the incompleted objects
what's the user model look like?
its a subclass of Abstract user with only a manytomany attribute for the communities
!code
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.
so where is this coming from?
it gets all of the related objects for that user
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?
no only the m2m field for communities
so then how are you using user.questionresponse_set
literally where do you return that from the server
i had a prefetch there before but when i got rid of it, it still worked
i returned it in the view
!code
for the 'modelname_set' thing i dont think you'd need an extra field could be wrong though
also is there a way of doing it in the backend?
would using a manager work?
I think you need custom template tags.
is that the only way?
I would usually handle all the math in the view.
would using a custom manager work?
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.
i've found it!. I set the debug=false and allowed host =[*]
maybe thats why the 8000 port cant run
Have you tried something like User.questionresponse_set.filter(field=true).count()
I can't remember if that will work in a template
i dont think you can do that in a template
seached it up
but im trying to do something like that
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
if you can send me an example that would be awesome
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.
ill try it out then
I had to count positive or negative reviews and did it this way.
This is along those lines
The accepted answer
def get_incompleted(self): questions = QuestionResponse.objects.filter(is_complete=False) count = len(questions) return count
something like that?
Yea that looks right
Thanks for the help man fully appreciate it
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?
!code
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.
I believe that's the right thinking. POST is indeed a request HTML method, so it is effectively using the REST API. That said, I'm new to Django so may have that not clear.
As for your question about Flask, after using Flask for a month I shifted to Django because it has built in user management and authentication. I didn't go that deep I'm sorry to say.
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.
Right...that makes sense.
Yes, I'm currently buried deep in CRUD setup for my web application. It's working great. But you don't know what you don't know.
It's a good habit to get into (REST) in case you work with others on a project.
Another good pt. I'm the sole developer on this and it's my first project. Of course, I picked a really ambitious one...
But then I know this web app is due some serious refactoring and refinement...
Even got filtering working on a list view...So awesome to see these features working and being built so rapidly...
Nice. π
Frickin LOVE Django though....amazing stuff
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?
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.
That's right, it's never too late.
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...
Any specific reason why you're choosing react and not vue or svelte? Just curious.
Mainly because of recommendations so far. I'm not intimidated by learning complexity. But those that have shared their experience with React and diagramming have suggested it. I figure, I can give it a go, and see what shakes.
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.
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...
Ah so it's a business oriented methodology of kinds?
Like team work stuff i suppose?
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...
Thanks. It's exciting that's for sure. There's nothing like this out there...
Careful how much you do if you plan to build the front-end. All you need are API endpoints to then build your front-end to connect with.
Especially forms. That is all done on the front end.
But I love the enthisuasm.
My first Django-Python project was a MUD.
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
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
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?
Right
Your front-end will essentially live independently and talk to those endpoints.
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?
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
Not sure I understand that question. Are you going with templates or some framework like React/Vue?
Iβm using Flask. I was just wondering how I would make a login system and if I need an api for that
I donβt really know much abt web dev
hey, does having a project under a project fine for django?
is this considered as a bad practice?
You definitely don't need one. You could use Django, which takes care of a lot of that kind of stuff for you out of the box, but if you're set on Flask, you just need to send a post request to the backend and authenticate your user.
@nova pewter if theres a reason for it, sure. I have multiple projects in one repo as they're all microservices to my app.
alright, thank you
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?
is it not configurable?
I know it is in Django
Doesn't seem to be https://www.starlette.io/routing/#submounting-routes
That's not something terrible, it just seems like an extra request
What technology would someone recommend to produce a matplotlib-like animation of many dots moving around on a website
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('\\'))
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
just paste here with
what u want to do
whats the error
n all info
can u elaborate?
which module r u working with
websocket and threading
ohh
im not into that wait let some other peeps come dont worry , we'll help
ok
umm btw what project r u working in that u need websockets @heavy nexus
i mean what u r trying to build
im building a treading bot
oh my goodness....this web app...it is moving fast! Had massive inspiration today. App 2/8 is about halfway done...
ohh discord bot?
hey hello
ya
Hey. How did your pword reset issue go?
have u worked with caching in django
nope
nope
Not as yet.
im learnig through udmy but i got stuck in the middle
ask in #discord-bots
in ur proj umm what what things r u using im just curious about topics just name them - example pagination sign up n all
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...
stripe connection for multiple subscription tiers, dynamic page builds driven by subscriptions, this is what idk
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
i can load dynamic page as per subscription but
idk the payment thing
r u using pure django or django channels or rest framework @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
umm when u will apply react u will need to use rest framework
and around 4,000 lines of html/css
umm damn
Yes. I'll use Rest for React. All good
how many apps
Hmmm...I think there are going to be about 14 apps all told.
omg too big proj
why i dont get ideas uuf
π
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
and im 16
You're in great shape π Plenty of time for the great ideas. They'll come. If you believe you'll achieve!
umm i am just learning and learning and making proj according to ytbers and docs
todo app
todo app with auth
blog app
contact page app
taskmanager app , ecommerce app
blog app with auth
umm
Don't get caught doing tutorials too long. Better start your own project.
made ecommerce app by me
can u plz gimme any idea that i can really show people
@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
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.
You can also work on your own portfolio website
Thats what im doing rn
Yeah, Delhi
nice
which year student
how can i filter in django by foriegn key of foreign key
2nd
nice
You'll probably need a nested query
It's 2 am here and I'm about rdy for bed. If I can help I will...but will need to be quick
no no u can sleep rn
later
just a suggestion nothing else
will get it dont worry
Just put your question here. If someone wants to answer they will. :)
yes yes go sleep
tc gn
and thanks
I'm in India dude its 1pm here
Lmao i didn't see it was u was thinking it's carawen
π
Sry my bad
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:
- Be storing things in a single large stringified JSON file?
Then, when I something needs updating, the whole string gets changed and updated?
- 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.
- 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?
Dont use json files at all, use a database
And with regards to local storage on the client side, only store non-secure data that you dont care if it gets leaked, copied.
Okay. I hadn't thought of that. Thanks!
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...)?
!e
print(bin(0x20))
@inland oak :white_check_mark: Your eval job has completed with return code 0.
0b100000
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
uh. I got it
I already know I have to set the editable to true
you are trying to have some custom form field
yes
got any hints for the logic?
youll have to override the widget logic probably
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
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.
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
this is the main driving force that I want to keep django admin
Hello everyone, I am Adamson a backend web development enthusiast
I would really appreciate it if I'm enlightened on the field
turning lamp on and directing to @winter adder so he could be enlightened
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
I would try attaching to primary id in database
Username can change
Primary id is changed...more rarely
It is also known as pk value in django I think
It can be accessed for any model object saved in db
wtf, it just fixed itself, I'm actually gonna kill myself
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 ?
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
Any web dev here?
probably, just ask your question
Well I was searching for someone who can help us out in making a discord bot dashboard
@eternal blade Well Hey I have a question about ruby
Sorry, I don't know ruby 
Ok so any other language that has the discord Library@eternal blade
Javacript, c sharp, java
- 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
i am not familiar with discord api wrappers other than discord.py
Yes I was thinking the pk too, but 1, 2,3 felt too small
@wintry gate i answered ur q
Make a hash out of them
If you wish them bigger
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 !
no
oh I misread the external style sheets thing, it should be true I think
Yeah fuck double negation :p
you can put em in different folders for each user if you have users, if it an anonymous sharing platform, you can generate a random folder and put the file with the original name in it like anonfiles does
or you can put em all in one folder and rename the files to smt random and when someone downloads the file you rename it back to the original name stored in the database.
but idk maybe allot of folders can create allot of unneeded writes/reads
Is Django an alternative for Js?
you can use bootstrap studio to create pages with bootstrap rly easily basically drag and drop, or use a JS framework like REACT
I'm not exactly sure what Django does
Django is a framework for serving pages that can communicate with a backend
@late creek Django is the backend
yep
So basically Django helps connect js with python?
@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.
Like let's say I had a variable in python. I could move that same variable to javascript or something like that?
Is it free to use ?
Could you give me an example of something you would use Django for?
I think you can do that with Jinja yeah
bootstrap studio isn't, but all JS frameworks are
@native tide yes - the frontend client can retrieve data from the backend server. You're on the lines to describe an API.
Wait so ur supposed to use an API to connect within ur website too? I thought it was just to connect to other websites and retrieve that info
you can try webflow too, but they don't let you download any data, so you have to be creative with that
Webflow is terrible and isn't developing anything, you're just fitting into their templates
I think he just wants to put his Django knowledge to use
Without learning a whole new language and getting good at it
well he wants to write smt easily, so I'm just suggesting I don't like em either lmao
I'll see what I'm able to do with Bootstrap Studio. Tutorials and Demo are looking crazy
I mean if react is easy u could do that
@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.
I'm not gonna say you can torrent it but hint hint
Oh ok I didn't think they would be counted as seperate
@late creek I'll create my own company, so I'll be able to buy Bootstrap Studio with my business
They are seperate if you use a JS framework. Django has templating which bridges that gap.
best of luck buddy
@valid void if you're a student, you can get it for free with github student
Or just buy a .edu email for $1
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.
Ooh dats nice I should remember dat
You can do that?
where can I get those ?? I want one tbh
Me too
Hahaha
I still don't get it
He opened Pandora's box with .edu email
What don't you get?
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.
What part of a website is front end and what is back end
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.
Frontend is what the user sees. Backend is the server.
Right, basically.
frontend is (HTML, CSS, JS)
backend is everything written in the .py files
yeah pretty much
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
@native tide yes
Sure, yea.
exactly
Ok so why do you need Django for that? Isn't that literally what python does
the database logic, the user authentication, that all backend
Even fetching the data from the database, the frontend requests data from the database via the backend code.
Oh ok I see
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.
But I thought front end is supposed to display it
I mean if you wanna reinvent the wheel you can do it, nobody stopping you from not using a framework, it just makes things easier
Yea that's right.
Then why do you need Django to display it
But we also said that it communicates with the backend to get the data and actually serve the pages.
Right
K I will do that
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.
Oh ok
But either way you need one to go drive.
@dense slate have you tried using pyramid? it another web framework for python
Nah, I'm a Django fanboy. π
I'm more focused on front-end these days, so Django serves my python needs.
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
Looks kind of flask-esque?
Is there any perfomance improvement with Flask or Pyramid over Django?
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
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.
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
So do it @fair shale
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
and I decided that there is no point for me to chase front end in a close future%
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
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?
but i can't give it a class
like here how can i edit it with css use classes with it
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.
how in this case ?
Do you know how to apply css?
yes
So what have you tried and what is not working?
how can i edit a specific element like inputs or lables?
And give a class to each of them?
@dense slate
@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
glad you liked it man :)) just learn some css and you should be able to create business level websites
Yeah I'm going to work hard, I can now handle projects entirely. I'm so happy π I just need to find a good web host for django projects
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 !
Can someone help me out scraping a website?
I need some help guys, why my variable password2 keep saying that data is keyerror when i tried to signup account
Maybe change quote to single quote (" " to this ' ')
And check if your field is correctly named "password2"
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
Just after your form you have to add "{% csrf_token %}", a protection against Cross site request forgery
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
I develope website with react native and django + sass so i dont know how to put that {% csrf_token %} in js file
@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 ?
This works fine. But one time when I was trying to display a pandas dataframe as table in html (using jinja), the css properties JUST refused to apply via the link. The alignment would work but colours etc wouldnt. Spent 14 hours on it and tried all kinds of templates. Finally just wrote the css inside html. Still dont know why that happened.
DigitalOcean is my favorite.
@opal quest https://stackoverflow.com/questions/23349883/how-to-pass-csrf-token-to-javascript-file-in-django it doesn't help ?
Because that's rather overcomplicated for such a simple task, I just want to redirect in the form to whatever the user types in
Yea it can come in handy in a pinch but definitely the exception to the rule and not the standard.
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.
Although it's kind of funny because I write everything inline in React. π
I don't know if you can do it not using JS
Just put an onclick on your form button that change the action value
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
For me the best solution is to create a single views.py function that will get your text value and just redirect
I just want to redirect to ?test=whateverusertypedin
you can use heroku for that it easy and if you add a credit card u can serve your app 24/7 lifetime for free
it good for development
I'll look for this solution, thanks π
But that needs a form too no?
@late creek @dense slate any pointers?
I never used it.
same
damn!
@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 !
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
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?
Maybe the lack of space before and after?
still not loading
@clear bone Have you created your STATIC_ROOT url ?
no i have not
Oh wait you're missing the folder
It has to be /static/app/file.jpg
And then in the URL app/file.jpg
Yes
Yes
hmm still not working
Is your app in Debug = True or False ?
true
I think it's already done as I saw
hmm vscode explorer is confusing
Yeah it's not very explicit
