#web-development
2 messages Β· Page 127 of 1
se this
huh not this 1
i create 2 fields now
height and weight
i dont want that user enter bmi
okay
wait
ok
right now
this is view.py
if request.method == 'POST':
pregnancies = float(request.POST['pregnancies'])
glucose = float(request.POST['glucose'])
bloodpressure = float(request.POST['bloodpressure'])
skinthickness = float(request.POST['skinthickness'])
bmi = float(request.POST['bmi'])
insulin = float(request.POST['insulin'])
pedigree = float(request.POST['pedigree'])
age = float(request.POST['age'])
name=str(request.POST['name'])
date=str(request.POST['date'])
gender=str(request.POST['gender'])
mydb = mysql.connector.connect(
host='localhost',
user='root',
password='',
database='mdss',
port='3306'
)
mycursor = mydb.cursor()
sql = "INSERT INTO diab (name,gender,date,pregnancies,glucose,bloodpressure,skinthickness,bmi,insulin,pedigree,age) VALUES (%s,%s,%s,%s, %s,%s, %s,%s, %s,%s, %s)"
val = (name,gender,date,pregnancies,glucose,bloodpressure,skinthickness,bmi,insulin,pedigree,age)
mycursor.execute(sql, val)
mydb.commit()```
okay so add height and weight like you added other fields, then add
bmi = height*weight
then how i set the bmi in html form automatically
i can calulate but i dont know how to set it on html page
this is bmi in html page
<div class="col-md-4">
<div class="form-group">
<label for="bmi">BMI</label>
<input
type="number"
step=".00001"
class="form-control"
id="bmi"
value="0"
name="bmi"
/>
</div>```
right now
like the value set when height and weight multiply
hmm
not sure if it will work, add it in the html page where you want it to show
sure
Star Gym is a network of many excellent gyms where you can find modern exercices machines, ladies & wellness zone, great community and trainers.
someone can tell me what should be better?
how do u get a hel pchannel
@quartz plinth Could you read #βο½how-to-get-help?
Guys can I run my django project from my pc and see it from the phone?
I guess no right?
How
steps I don't know offhand, but you can google "locally host django project + your system / other details that are unique to you"
so add in Windows or Linux
or wahtever you're running on
and if you want it accessible outside your local network or not, I'd host locally first and check it out via local IPs
You need to get your IP address, and run it over there instead of localhost. Then only people connected to your WiFi will be able to see it
then worry about opening it up to the world
Yep, local network vs world wide
I'd recommend getting it up and running locally first, good dry run
might satisfy your current needs
Lemme try mm
then you can look into an rpi or something else with 24/7 capabilities, or use a free online service
That damn page is not pulling up
Can you access it ?
Ok it opened
python manage.py runserver x.x.x.x:8080 Where x.x.x.x you can get from https://whatismyipaddress.com/
I think the website gave me the wrong ip
mm
yeah it worked
ipconfig
Thanks so much guys :D!
who can help me? https://stackoverflow.com/questions/65688998/charfield-connect-to-another-model-charfield-django
can anyone help me #help-croissant
how can i allow various fonts from discord in my html file
some names are written in a weird way and i get errors
You have two separate views for question and answer. You need both of them to be in the same view if you want to attempt to show both forms in the same template, because having 2 views implies they are both are different URLs
@native tide so what do you advise me how to change? An example if you can see it
This is my advising you on how to change it
I want to automatically display as many such forms as there are questions and the question will be automatically selected. Do you understand?
@native tide understand?
how are you supposed to handle migrations
i have a web app that's deployed
and im trying to avoid having to use the CLI on the server to make changes
i am currently trying to make a proxy scraper that scrapes proxies from multiple sources, can anyone help?
DM ME
In flask, if I want to access request data like params, query, headers, etc. do I have to use app.request_context(environment):? What do I pass in for environment, if so?
no I don't really understand what you're trying to do
@native tide Can I write to you in pm if you have time
does anyone know why django is telling me disallowed host even though I added my domain to settings.py allowed hosts? ALLOWED_HOSTS = ['207.246.87.164', 'atomlink.tk/', 'www.atomlink.tk/']
idk if this is why but you don't need the /
I tried it without it and it still doesn't work for some reason
it is not updating
either you're not pushing it properly, or it's being overwritten somewhere else
ok
how do I update it?
I did systemctl restart nginx but it's still saying disallowed host
idk friend,
i have my own coding to do at the moment
but those are the commands to restart and check status of nginx server
oh ok
its likely something is happening elsewhere that is restricting access
did you link allowed hosts with available sites
@swift sky I fixed it. I did sudo reboot and it worked. I guess the nginx server just needed to be shutdown and started again to update. Do you know a way to update it with a command?
i usually use systemctl restart nginx
but it seems like you had some permissions and so it wasn't doing it
oh ok
ok
I deleted db.sqlite3 from my vps but now when I upload it from my local machine, it automatically deletes. Does anyone know why?
Hey guys, I'm having a problem with Flask and Jinja2, i'm passing a dictionary to the HTML, and looping over the keys with jinja, but the data is being displayed incorrectly inside a modal, and correctly outside a modal
sounds weird, so the modal is just some other html in the same file which you show / don't show with JavaScript?
Well, I have something like the following ```jinja
<table>
<tbody>
{% for i in organizations.keys() %}
<tr>
<h1>{{i}}</h1>
<button class="btn btn-white btn-sm" data-toggle="modal" data-target="#modal">Open</button>
<div id="#modal" class="modal fade" role="dialog">
<div id="modal-content">
<h1>{{i}}</h1>
</div>
</div>
</tr>
{ % endfor %}
</tbody>
</table>
And i'm doing ```py
return render_template("organizations.html", organizations=organizations}
And lets say organizations is the following {"test1": 1, "test2": 0}
{% i for i. -- the first i is correct?
Think so
But for each of the items added to the table, the first h1 outside of the modal is correct, but its wrong inside of the modal
wait
Sorry its supposed to be {% for i in organizations.keys() %} I typed it wrong
But its correct inside my code
ok
But yeah, theres still the problem
lemme see if I can get an example together to try it out .. do you have a repo I could clone?
Uh, not really, its a closed source app
np
So the first h1 is different both times, but the h1 inside the modal is test1 through both of the iterations
it gives out
test1
open
test1
test2
open
test2
for me and I think this is what I would expect.
still a typo in your {% endfor
Oh yeah, sorry
I typed it out by hand
Not sure why its not working for me then
Say I have something like this then ```jinja
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"/>
</head>
<body>
<table>
<tbody>
{% for i in organizations.keys() %}
<tr>
<h1>Title: {{i}}</h1>
<button data-toggle="modal" data-target="#modal">Open</button>
<div id="#modal" class="modal modal-fade" role="dialog">
<div id="modal-content">
<h2>View Organization</h2>
<h2>Title: {{i}}</h2>
<h2>Address: {{data[i][1]}}</h2>
<!-- And so on for every piece of data, so address, city, state, zip -->
</div>
</div>
</tr>
{{% endfor %}}
</tbody>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
@glossy arrow It looks like you're creating a bunch of modals with the same id
you need to create them with unique ids and target the correct one in each iteration
data-target="#modal-{{i}}"
id="#modal-{{i}}"
or something
Ohh ok
Wait, so a different modal for each organization?
Because users can add a new one any time
hi
how to set text field based on other 2 text field results
i need to set bmi = weight x height
i write javascript code but its not working
<script type="text/javascript" src="jquery-3.3.1.js"></script>
<script type="text/javascript">
var elem = document.getElementById("height").value;
var elem2 = document.getElementById("weight").value;
var result = parseInt(elem) * parseInt(elem2);
document.getElementById("bmi").value = result.value;
</script>```
when i enter height and weight on html page the bmi value is not set
you need on change of jquery to trigger it https://www.w3schools.com/jquery/event_change.asp
first you need to import jquery
i am new to js and query can u pls show me
like the link i posted above
$("input").change(function(){
alert("The text has been changed."); // you functions in this
});
@glad patrol javascript itself doesn't handle much on static website, to make static website interactable you need to learn jquery and ajax
shit
Depending on how many organizations you're gonna have you might need to find a better solution
you can make one modal, and alter its contents with javascript
how to set input field value on run time base on other two input fields?
var heightField = document.getElementById("height");
var weightField = document.getElementById("weight");
var bmiField = document.getElementById("bmi");
function handleHeightOnChange(event) {
bmiField.value = event.currentTarget.value;
}
function handleWeightOnChange(event) {
bmiField.value = event.currentTarget.value;
}
heightField.addEventListener('change', handleHeightOnChange);
weightField.addEventListener('change', handleWeightOnChange);```
how to add both height and weight event values ?
does anyone know why in my test db i could add a column of varchar(10000) but when i try to flask migrate over on to the deployment server
it tells me that its too large
row size too large*
I am having a problem with building my Python discord bot on Heroku
this seemed to be the best fitting channel
nvm
sounds dumb, but i know have node.js and django installed on AWS, can i just upload my code from my computer to the server and start the server and it work? or do i have redo all the installs for it to work?
if your project don't use thid-party packages then sure, else you have to have a requirements.txt file for package management
it doesnt require other 3rd party python packages, but does have 3rd party react packages, but they are all included in my files
You need all your dependency to be installed on your AWS server. If it is installed than you upload your code & start the server. It will work else you need to install all dependency first
If you don't mind me asking, what AWS service do you use for your django-react projects? I want to start learning how to use AWS
Also are you just using django to serve the index.html and then React handles the rest? Or is it some sort of other setup?
my server is fully up and running now. and yes, django is the server, im still using the developement server so im not gonna link anything to it. wanna run some tests
yea, i got it... took a while.
if i close the ssh will the server continue running
@wicked elbow when you close the ssh it's also mean the terminal will be closed, look into screen for keeping the terminal up and running
if you using python manage.py runserver
ah ok... im gonna guess thats something that cant be done for free
at least in aws
nah server is still up and running after closing my SSH link
oh ok
i suppose i could share the public ip though eh? anyone could find it anyways
what is this equivalent in function based views?
font-family style
what?
you can use inline styles
which would be in the HTML...
...but nevertheless, I don't really see your point
choice of font is not the province of HTML
css is a child of html... css cant do anyting by itself, but html is plain and ugly without html
man gotta wait up to 48 hours for dns to resolve my domain name 
thanks nutcrackerπ
Hello Nut
I can't implement pagination and search function together
Hello. I need help with flask sessions.
Basically, I have my frontend with react and the backend is in flask. My frontend port is 3000 and my backend is 5000 in my localhost machine. when I log in, I want to save some credentials of user in their session like their key. It doesn't matter if they are able to see it or not but I don't want them to change it. I'm already successful in saving their session so basically when they click that button it saves that user session. But when I try to get that session using another api in flask, it is None and its like the data has never saved before. I thought it might be because browsers don't save sessions if they are in seperated ports. I wonder why is this happening and how to fix it? Is it same when I push it into production server with domain?
who can help me? https://stackoverflow.com/questions/65705545/how-to-select-an-object-automatically-fk-item-django?noredirect=1#comment116172227_65705545
Hello all, I actually want one of my image tag in web page to move down on scrolling.
I referred to many online sites but I am not able to fix that.
Can anyone please guide me here.
I want that bike to move down on scrolling
Is there a way to remove the title "Long URL" in this Django form?
<form method="POST" action="/create" style="font-family: bebas neue; margin-top: 20%; font-size: 3em; animation: fadeInRight 3s;">
{% csrf_token %} {{ form.as_p }}
<center><button type="submit" class="btn link2" style="font-family: bungee; margin-top: 1%; font-size: 0.8em; background-color: white;">Shorten URL</button></center>
</form>
is long url a field name in your form in the django backend, because you display the form with form.as_p, maybe you can set a display name for this field then.
yeah it's a URLField
I have never implemented either, so I wouldn't know
I have an issue...
request.user tries to retrieve a user from the User model. However, I have a custom user model (AbstractUser), how can I change it so that request.user tries to reference it?
I just looked through the docs and found verbose_name which sets the title to be something else. I set verbose_name to be an empty string and it makes it blank.
@native tide I think you just need to specify AUTH_USER_MODEL = 'customauth.MyUser' in your settings.py
I have it like that, but request.user still references User
request.user should return an instance of AUTH_USER_MODEL, so i'm not sure
if they aren't logged in, it will be an anonymous user
@native tide
@native tide The custom model is in the DB?
That setting mentioned above should "reroute" which user model is used to the appropriate model.
AUTH_USER_MODEL = 'core.CustomUser'
hmm, I'll try test it, what led me to think that was the error was:
Print out request.user
See what you are getting
@native tide
I believe it returns an object.
Your User object.
So like request.user.email will return enail
request.user.username returns the username
request.user returns the User model for the user as an object, can't verify on mobile but I believe this is what it does.
So if your User model doesn't have a suite attribute you will get such error
@native tide
Working on it now
Sup
Is there any way to access request.user without making an API request
Been having a CORS issue despite following all the correct steps (I think)
you can just visit the api url directly in your browser
<center><a class = "download-btn" href = "information.html/files.zip" download="files.zip">bruh</a><center>
it doesnt work
how would I add some text inside the text box in django forms?
@native tide that means no one is logged in, do a try-if statement to catch that error or make logging required for that page
@native tide also I do not think you are making a call by getting the object. It's stored in cache on every request.
Yeah I can't log in because when I use postman to try to add my Authorization header (I use token auth) I get a CORS error
Are you passing in your CRSFtoken ?
No... do I need to?
If sending a POST request yes
It's just a GET
Then weird I have gotten such error when trying to login sending a POST requedt
When I got CORS error
What's the error exactly ?
Ok so I will lead you through what I have done this far
- pip installed djangocorsheaders
- added it to installed apps
- added it to middleware
- added this in settings.py:
ALLOWED_HOSTS = ['*']
CORS_ORIGIN_ALLOW_ALL = True
Then I try to make a GET request in postman
Can I pass jinja2 data in an onclick?
Like ```jinja
<button onclick="myfunction({{whateverdata}})">Click</button>
I'm so lost, are those the steps that you would usually use to modify CORS?
I have had it setup in the past no problem
@glossy arrow should be able to pass in whatever you want as a parameter
Yeah, but it doesn't seem to work
@haughty turtle No, its sort of working
So Im doing something like this ```jinja
{{% for i in organizations.keys() %}}
...
<button onclick="myfunction({{i}}, {{data}})">Click</button>
...
{{% endfor %}}
So im looping over a dictionaries keys
and lets say i is test
and data is a dict
Its saying that test is not defined
So its loading in the value for i
But saying its undefined
@glossy arrow it's because your passing a var inside of a string as said. Take a look at the link
Cool, i'll look at that, thanks :D
Hm, that doesn't seem to solve the problem
Wait
yeah it doesn't solve the problem
Its not showing anything about jinja values
I did successfully include Jinja2 in JavaScript like below, so maybe safe helps / maybe there is a way to rewrite your code?
<script> {% if mytable %} var table_data = {{ mytable|safe }}; {% else %} var table_data = null; {% endif %} // table_data.data = table_data.data.slice(0,5); // DEV config sub array </script>
Thanks :D I can't figure out why its not working, but I found somewhat of a workaround
Did you try the solution?
Didn''t work
Does anyone know why DRF is giving me an AnonymousUser forrequest.user?
So anyways I don't think DRF catches on to my AUTH_USER_MODEL
Do I need to write some sort of custom middleware so that request.user references my custom usermodel, and not that of the default django user model?
Shouldn't have to.
That is what I used to do it my first time and it shouldn't be a complicated process.
Last option is what you want.
Hello, i need to persist session after logout to load my cart on next login. Is it alright to overwrite logout function to do not flush session ? Thanks
So, when you extended User model with AbstractUser, did request.user return your customAUTH_USER_MODEL or the User model?
Because from what I see request.user is set to return an instance of the User model...
I'm pretty sure custom authentication / middleware is needed here...
Why does no data get sent when I include POST data directly in the urllib.request.Request object, but rather I have to pass the kwarg when calling urllib.request.urlopen?
e.g. : urllib.request.urlopen(urllib.request.Request(url, data=DATA), method="POST") doesn't work, while urllib.request.urlopen(urllib.request.Request(url, ...), data=DATA, method="POST") does
Both the Request class's initializer and the urlopen function accept the data kwarg yet only the former appends data to the body
sorry if this isn't the right channel to ask
Can someone explain why this header:
Authorization: Token cb5837c90e8f8c352a370798e058e42d5913eeb4
returns None from this code:
def authenticate(self, request):
auth = get_authorization_header(request).split()
if not auth or auth[0].lower() != self.keyword.lower().encode():
return None
is that the whole function?
you sure its not asking for Bearer or smth
assuming that get_authorization_header(request).split() is doing anything extra
Well, I'm using DRF's TokenAuthentication and when I make requests it's returning None. When I edit what the code returns, the output is different.
is that a yes?
Confident that it should be Token
not too sure on what this does though
self.keyword.lower().encode():
my guess would be
verifying that the header starts with the given keyword
self.keyword.lower() is token
which, in this case, is expected to be Token
yeah, what's with the .encode() on the end?
presumably
since the header comes from a HTTP request
it's a bytestring
and self.keyword is a string
so to compare the two you need to either decode one or encode the other
def authenticate(self, request):
auth = get_authorization_header(request).split()
if not auth:
return None
This still returns None
Maybe I'm looking at the wrong thing...
print(auth)
and maybe also print(request.headers)
i recon its gonna be a headers property or smth, i dont do much django but its pretty much the same across all systems
How do you get all the chosen options with select2?
This is the right header according to the docs:
Authorization: Token cb5837c90e8f8c352a370798e058e42d5913eeb4
However I am using postman and they may be adding something which I don't see, I can try from my react frontend.
The issue I am originally having is that request.user is returning AnonymousUser instead of my AUTH_USER_MODEL specified in settings.py
{'Content-Length': '', 'Content-Type': 'text/plain', 'Host': '127.0.0.1:8000', 'User-Agent': 'PostmanRuntime/7.26.10', 'Accept': '*/*', 'Accept-Language': 'en-GB,en;q=0.5', 'Accept-Encoding': 'gzip, deflate', 'Authorization': '', 'Origin': 'https://web.postman.co', 'Connection': 'keep-alive'}
Interesting
So the Authorization header is empty
would appear so
yeah, this was my guess
problem solved
I'm specifying a value for the header in postman π€·ββοΈ
I'll try this from my frontend and see if it differs
OMG
Postman has 3 columns, "key", "value", and "description", I mistook the "description" column for "value" as it was hidden.
Thank you so much @quick cargo @vestal hound I was stuck on that all day
yw hf
How do you get all the chosen options with select2?
Ive tried getlist but it just does the first selected object
django api link?
rest api?
so docs?
yea basically
thank you
wlc
db = sqlite3.connect("textPosts.db")
c = db.cursor()
sql = ("SELECT textContent FROM textPosts WHERE username=?")
val = ([user])
c.execute(sql, val)
result = c.fetchall()
for text in result:
print(text)
c.close()
db.close()
return render_template("view-text-uploads.html", result=text)```
```html
{% for text in result %}
<p>{{ text }}</p>
{% endfor %}
only returns last item of list
what it returns
what it should return
ping if responding
I guess you're retrieving all the columns
but there is only one
what happens if you do result=result
well the image
.
it will
nope
wdym
if you do result=result and do your for loop but use {{text[0]}} I think that should work
it doesnt
ok so what's happening
so you mean
return render_template("view-text-uploads.html", result=result)
{% for text in result %}
<p style="color: white;">{{ text }}</p>
{% endfor %}```
right?
mm, you might be consuming the data with your forloop inside the view
what
result = [x for x in c.fetchall()]
maybe try this instead of
result = c.fetchall()
do i do result=text or result=result
nope
are you doing text[0]?
How do you get all the chosen options with select2?
Ive tried getlist but it just does the first selected object
share what your form looks like too
actually, nevermind, I just figured out my actual problem and the solution to it as I typed the question
hi
i am creating some basic app hospital system , i need some help
how to generate report in django , i have some variable's holding information like name , bmi , age etc i want to display in some report template .
@glad patrol write model_name.objects.all() to get all objects of your models.
Pass the resulting query set to your templates and then in your html you can simply iterate over it query set using jinja
@ashen sparrow i am using sql database direct not model
Are you using SQLaclhemy?
phpmyadmin is a database GUI, not the database
sql database
he asking what ORM are you using
@glad patrol whatever you do, you need to perform a query on your database similar to
SELECT * FROM REPORT_TABLE
Now populate result in a list
like prescription reeport
And pass the list to your templates
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
i am getting this error even i import utf-8 in html page
Where did you import it and how are you using it?
Before you pass your results to the template, try encoding it into utf8
set this in your html meta tag
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
now its throwing this error
i set this
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<!-- Required meta tags -->
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>```
better to show the image of the error on the page
this happen after you submit the form?
when i open https://172.17.85.70:8000 then i selete diabtese form then this appear
can you show your form template?
yes
maybe it's missing in some child template or parent template
even better, right click -> show page source
so we can know if it has
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
from browser ?
yeah
it only show this
ok then post the html of base.html?
ok
Hey @glad patrol!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
β’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
β’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
yeah that the problem
should i need to run migration ?
or reload project?
yesterday this happen i add meta and its work now its not working
ok now show me the diabetes.html?
@glad patrol can you add space to these template tag?
{%extends 'base.html'%} {%block content%}
ok i add w8
like so
{% extends 'base.html' %} {% block content %}
w8
same error
if i reload the project
its works fine
if i add something then run it give me error
i have rar file backup
if i use that rar file backup its work
even the same meta tag are inserted
see now i unzip my backup and its working fine
if i add another html file in templates it start giving the errors
that pretty strange, what is your project structure like?
means?
what type of error?
you got a 500 server error @glad patrol try to print out what caused the error and put debug=True
i don't think the error related to the utf8
but the logic in the view itself
@glad patrol yeah put DEBUG=True in settings.py
so the page can show the real error
ok
pregnancies = float(request.POST['pregnancies'])
glucose = float(request.POST['glucose'])
bloodpressure = float(request.POST['bloodpressure'])
skinthickness = float(request.POST['skinthickness'])
bmi = float(request.POST['bmi'])
insulin = float(request.POST['insulin'])
pedigree = float(request.POST['pedigree'])
age = float(request.POST['age'])
name=str(request.POST['name'])
date=str(request.POST['date'])
gender=str(request.POST['gender'])
bloodgroup=str(request.POST['bloodgroup'])
mrn = int(request.POST['mrn'])```
i have this information which i send into database
how to generate report from this
yeah but can you reload that page with DEBUG=True?
1 mint
huh
i fix this
the error is i define index.html which is not even exsist
lol
i remove from diabetes.html
and its working
@gaunt marlin
i have report.html page
i add <a href="{% url 'report' %}">Home</a> in my diabetest.html page
when i click on home link it wont open the report page
thats why 500 erro occurs
`django.urls.exceptions.NoReverseMatch
django.urls.exceptions.NoReverseMatch: Reverse for 'report' not found. 'report' is not a valid view function or pattern name.
`
Use {% url 'app_name:report' %} where app_name is the name of the app that contains your report view function
@glad patrol you can set the name of your url like so
from django.urls import include, path
urlpatterns = [
path('index/', views.index, name='main-view'),
path('bio/<username>/', views.bio, name='bio'),
path('articles/<slug:title>/', views.article, name='article-detail'),
path('articles/<slug:title>/<int:section>/', views.section, name='article-section'),
path('weblog/', include('blog.urls')),
...
]
if 2 or more apps have urls with same name then you need to call app_name:url_name instead
so i need to run two manage.py for both app ?
or they both run at once with 1 manage.py?
manage.py runserver will run the entire project
project have many apps
so it will run all the apps
on the same ip and port ?
yes
it's a long shot, but any chance I can get some help writing some REST API in YAML?
for a language that claims to be human readable, it sure reads like some fat nonsense
Hey so I keep on getting blocked by Cors policy when I make a fetch request
Anyone know what can I do to fix it?
Hey so I keep on getting blocked by Cors policy when I make a fetch request
@plain zealot your backend needs to serve the appropriate headers
it's a long shot, but any chance I can get some help writing some REST API in YAML?
@pallid fable you mean parsing YAML in your API?
or rendering and returning a YAML response?
I literally have to send a REST request using YAML
okay so like sending YAML in the request body?
...I donβt really understand
But I actually have to format and send a GET request to an IPAM server, with the intention of receiving the next free IP address in a subnet
The code that sends the GET request is supposed to be written in YAML
Found another way to fix
But thanks
That makes two of us, but my boss is convinced this should be possible
The code that sends the GET request is supposed to be written in YAML
@pallid fable ...wtf?
Yup
Found another way to fix
@plain zealot okay, hope itβs secure
To be fair, Iβve figured out how to do something sorta similar using the URI module
If it helps, this is being hosted by Ansible
Well, the code is being run from Ansible
...YAML canβt even be run...?
I think Ansible makes it work somehow
I got introduced to YAML and Ansible like a week ago. Iβm a newish hire, and weβre in the process of moving our service onto Ansible. Iβm translating workflows into Ansible/YAML
...itβs not an executable language
The old code that did this task was written in JavaScript which makes so much more sense
This thought has gone through my head so many times over the last week you have no idea

best I can explain it is that Ansible interprets YAML as an executable language
here's an example from the URI module documentation page
- name: Login to a form based webpage, then use the returned cookie to access the app in later tasks
uri:
url: https://your.form.based.auth.example.com/index.php
method: POST
body_format: form-urlencoded
body:
name: your_username
password: your_password
enter: Sign in
status_code: 302
register: login```
I mean, this is definitely written in YAML. But it also looks a lot like it's meant to be executed
Is there a reason your boss chose YAML to do request of all the things that existed out there?
I think they like that Ansible Tower (service running the workflows) has a much more modern interface than the old service we used for workflows
so the fact that all this shit now needs to be done in YAML is more of a side-effect
but I also arrived after this transition began so idk
I'm just a sad new college grad I wasn't ready for the level of bullshit that makes up YAML
"human friendly" my ass
the only thing i feels comfortable for YAML to run is writing test flow π€£
but everyone going for that automation flow i guess
Β―_(γ)_/Β―
just looked into it a bit more closely. Ansible uses an 'easy and descriptive language based on YAML and Jinja templates"
ah yes, that reminded me why we switched to Ansible. Something about how updates and workflows can be automated to run locally on the individual machines of our clients instead of pushed from outside
in case you're not following this anymore, I figured out the disconnect: Ansible doesn't use YAML, it uses its own language based on YAML and Jinja
so it looks like YAML but it runs
because someone made the conscious decision that YAML would totally be a good executable language, somehow
i think they just like syntax of YAML without all the curly brackets
bahahaha they don't use the curly brackets? All my coworkers have been using them, can't wait to tell them why their code isn't running for shit
<div class="quantity">
<input type="number" class="qty-text" id="qty" step="1" min="1" max="12" name="quantity" value="1">
</div>
<a href="{% url 'add_to_cart' slug=quantity.value %}" type="submit" name="addtocart" value="5" class="cart-submit">Add to cart</a>
Django question to you guys, how do I pass to the slug the input value?
does "{{quantity.value}}" work?
I will give it a try but I doubt since it's not a variable? Give me a sec
Uh uh π¦
That being said, is there a possibility you can pass the slug through context to your template, then access it within the value?
I don't understand ^^
I'm just trying to add a product to the cart, and i need the quantity to be passed in the url as well (having 2 slugs/parameters is another problem i'll be checking later on)
So in your view you will set the slug
def view(request):
slug = "something"
render_template(request, template, {"slug": slug})
Okay and so the slug will be changed in the input?
I guess so, so you will pass your slug through the context and within your template you can access it with:
{{slug}}
Yes
And I believe you can access those parameters as so:
def view(request, slug, amount):
...
Alright thank you man!
<amount: amount> amount is not a valid type, if you want it to be an int it should be <int: amount> or if not an int, just leave it as <amount>
what is he doing here?
turn list of dictionaries that contains keys and values into json data for example it converted into this:
[{'field_1': value_1, 'field_2': value_2}, {'field_1': value_1, 'field_2': value_2}]
but when I follow that I get this error:
TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Decimal is not JSON serializable
@gaunt marlin
@native tide json.dumps(Info.objects.values()) does not work?
nope
I am trying to achieve by other ways
#help-pineapple please
Why doesn't Flask accept ../ as a path:variable in route decorator? e.g. @app.route("/test/<path:var>")
when I try to pass list as context and set that list as an array var in template and console log that, it shows some unusual characters like this:
['University of Oxford', 'Stanford University', 'Harvard University']
how can I solve?
Looks like the single quote is being converted into the hex value 27
what should I do?
how?
where exactly it is?
safeΒΆ
Marks a string as not requiring further HTML escaping prior to output. When autoescaping is off, this filter has no effect.Note
If you are chaining filters, a filter applied after safe can make the contents unsafe again. For example, the following code prints the variable as is, unescaped:
{{ var|safe|escape }}
thank you so much mate
Please see this post and help me
https://stackoverflow.com/questions/65719388/match-two-models-field-django
How can I serialize a queryset into JSON without it being a list?
Loop through it as so
for i in all_projects:
project_dict[i.pk] = { "Title": i.Title, "Description": i.Description, "PhotoName": i.PhotoName, "Tags": i.Tags, "GithubLink": i.GithubLink}
return JsonResponse({'details': project_dict})```
this is what I use
Thanks, I tried to avoid specifying the fields directly incase the model changes, I guess I can loop through the fields and do the same.
I mean I think what I am doing is mapping
What if you do .values() and get a list of dicts and then do a dict comprehension?
Does anyone know how to do a 301/302 redirect in python?
Server: WSGIServer/0.2 CPython/3.6.9
Content-Type: application/json
Vary: Accept, Cookie
Allow: OPTIONS, GET
X-Frame-Options: DENY
Content-Length: 109
X-Content-Type-Options: nosniff
Set-Cookie: β
I am trying to get json data from my api view
That I made with rest
But the obly thibg I get is this
Is there a way I could change that?
Show your view
So I got this message from a friend today together with a django pdf: "I got this book from Jesus and I will start my Django journey soon. I will follow this book."
I was a bit disappointed to find out that her new coworker's name is Jesus. We could use a new bible
Nice π
Hey! I'm trying to implement a kanban board for my task management project, using this library http://www.riccardotartaglia.it/jkanban/ . I'm having trouble trying to understand how to implement the backend logic, especially how to keep track of the order the items are placed in a board. I tried searching on google but I didn't find any relevant results. Does anyone have any ideas? Or search terms to help me find something?
Pure agnostic Javascript plugin for Kanban boards
@haughty turtle the api view?
Error:
raise ImproperlyConfigured("URL route '%s' cannot contain whitespace." % route) django.core.exceptions.ImproperlyConfigured: URL route 'http://localhost:8000/{{ chars }}' cannot contain whitespace.
Urls.py
path('http://localhost:8000/{{ chars }}', redirect_view),
def redirect_view(request):
response = redirect('{{ obj.long_url }}')
return response
```Does anyone know how to properly do this type of redirect? I'm creating a url shortener and I'm using django redirects to do the redirect
You can't have Jinja2 in your python backed code, only in the HTML templates.
also the syntax for django paths doesn't include {{}}
https://docs.djangoproject.com/en/3.1/ref/urls/
does anyone know how to put a limit to request.get() ? would requests.get("url", limit=1) work?
well its a string which looks like jinja2
ok
Hello, I keep getting psutil.AccessDenied: psutil.AccessDenied when my flask app tries to open files to get things like cwd and all of that. How can I make it so that the flask/apache app user has access to all process files? @ me when responding please.
In case of a request failure?
path('<str:url>', redirect, name='redirect'),
def redirect(request):
current_obj = ShortURL.objects.filter(short_url=url)
if len(current_obj) == 0:
return render(request, '404.html')
context = {'obj':current_obj[0]}
response = redirect(f"{long_url}", permanent=False)
return response
@native tide I'm getting redirect() unexpected keyword argument 'url'. Do you know why this is happening?
actually nvm
I forgot to pass url
that function is also recursive, I think unintentionally? You may want to rename it
Can we convert JS array back to python list in django template?
def page_redirect(request, url):
if request.method == 'POST':
form = CreateNewShortURL(request.POST)
if form.is_valid():
original_website = form.cleaned_data['long_url']
return HttpResponseRedirect(original_website)
````ValueError: The view urlshort.views.page_redirect didn't return an HttpResponse object. It returned None instead.` Does anyone know why this is happening?
if request.method is not 'POST' then you will return None
if form is invalid, you will return None
so how do I make it return a post?
how do you make a function not return None
you have to return something right
there are two places where your function can exit without returning
you can have a catchall return at the end
with some sort of error
like a Http400 response
return HttpResponseBadRequest('invalid request')
or something
oh ok
same error
def page_redirect(request, url):
if request.method == 'POST':
form = CreateNewShortURL(request.POST)
if form.is_valid():
original_website = form.cleaned_data['long_url']
return HttpResponseBadRequest('invalid request')
yeah
if either of those are false, then your function will return None
because there is no return after those if statements
oh ok
does that make sense?
yeah
I put a couple print statements
it's if request.method == 'POST': that's returning False
class CreateNewShortURL(forms.ModelForm):
class Meta:
model=ShortURL
fields = {'long_url'}
widgets = {
'long_url': forms.URLInput(attrs={'class': 'form-control'})
}
``` @indigo kettle this is my form. I want to get `long_url` and put it in my `HttpResponseRedirect()`. How would I do that?
form.cleaned_data['long_url'] did that not work
I did
def page_redirect(request, url):
if request.method == 'GET':
return HttpResponseRedirect(f'/')
```And it worked
but when i did
def page_redirect(request, url):
if request.method == 'GET':
form = CreateNewShortURL(request.GET)
if form.is_valid():
original_website = form.cleaned_data['long_url']
return HttpResponseRedirect(f'{original_website}')
```it didn't and gave me the same error as last time
@indigo kettle
?
you're checking if the request is a GET but then putting request.post into your form
the post. will be empty
your form will probably be invalid
and then your function will return None
oh, I meant request.GET
but even if I do that, it still gives the same error
@indigo kettle
you can use a serializer, and then pass it to your template
I have this issue with a form. It posts but the post code isnβt hit. Instead the get code is hit. I worked around it but never did get it fixed.
The form works fine though... mystery to me
so is the actual request GET or POST?
like based on logs
I see both when I hit the submit button, but the get is what actually hits with regard to console output
hm.
that's not right
also that could lead to production bugs
because GET can be cached
I am using an UpdateView. The form is an edit profile screen that displays the userβs details and lets them edit the fields
I hope thatβs not going to be a problem when itβs in production
so vanilla Django?
it could be
do you know the difference between GET and POST?
like from a spec perspective
okay then you should know why it could be a problem...?
What's the problem?
I guess from a behind the scenes caching I donβt know where there would be a problem. Not sure even where the caching would occur
Nothing as far as I can tell. I was commenting on someone else having an issue with form submission not hitting an if block checking if the request if a post
caching happens on the server side
like the actual webserver
but browsers can also cache responses to GET requests
So looking at potential memory problem
no.
okay example
a static image is retrieved with a GET
Yeah
and the next time you browse the page (if the site is set up a certain way), you won't need to retrieve it again
because your browser has cached it
if the update request is submitted with a GET
the browser could cache that too
so your request never gets sent to the server
but you get back a "success" response
also, separately, GET requests should be idempotent, but updating is also an idempotent operation so that's not a problem here
Thanks for that info. I have a lot more reading to do. There is a post recorded in the console it would seem it is posting. On form submission the user is sent back to the same page so I expect a get. Hopefully thereβs nothing to worry about, but itβs something to read up on to be sure.
Why is my stylesheets being replaced by the error page template?
oh nvm
That was wierd
uhm wtf
That was so wierd
I forgot to add the {{ url_for('static', filename='
I have a field named suite within my model:
class Customer(AbstractUser):
suite = models.OneToOneField(Suite, on_delete=models.CASCADE, null=True)
premium = models.BooleanField(null=False, default=False)
Why is it being named suite_id within my DB? Can I rename it?
@indigo kettle the first if statement is working now but the second one isn't. For some reason, the form is not valid. Do you know why this is happening?
I don't
I would write some print statements to see what is wrong
you can print form.errors or something
and also print request.GET and see if you're getting the correct params
<ul class="errorlist"><li>long_url<ul class="errorlist"><li>This field is required.</li></ul></li></ul> this is what form.errors returns
your form cannot be validated because some fields are empty (when they are required)
try use redirect()
oh ok
so replace HttpResponseRedirect with redirect?
I guess so, it may help (but it looks like the issue lies with the form)
hey guys, idk if someone can help me with this but I am really struggling with flask progress bars!
I have searched everywhere for this, found a some examples online but they were only for file uploads which is not what I want.
I am failing to understand how to bind the python to the js and html!
I am working with someone on a neuron tracing project and they need some help with frontend.
The web portal is pretty simple and it just includes inputting your file tracing path (*.txt) and image path (**.tif) and then wait until another tab opens up which reveals a neurologlancer with a 3d view of your neuron (pretty nice!)
Now, my issue with this is the following:
the function that basically takes the whole time to load is in a different file than app.py and it includes the following code:
def func_that_takes_the_whole_time():
# code here
with mp.Pool(mp.cpu_count() * 2) as p:
# p.map(p_matting, range(0, len(gs_dict)))
with tqdm(total=len(gs_dict)) as pbar:
for i, _ in enumerate(p.imap_unordered(p_matting, range(0, len(gs_dict)))):
pbar.update()
# more code here
return something here
this is a progress bar that shows in the terminal
how can i get this to output in the frontend for the user to see, because the neuroglancer tab takes a bit of time to launch!
I am still a beginner to flask and am not even studying to become a developer, so it would mean a lot if somebody can help, been struggling with this for days!
Sorry for throwing this at you, but the result of tqdm only showing in terminal, want to find a way to output to user so they don't think they entered wrong input after clicking run!
Thanks a ton to whomever helps with this!
I don't think tqdm is appropriate for use with the web
I think it's relatively simple to render the progress bar on the web page
The tricky part is how to update the bar with the current progress
Since the server has to somehow relay that info to the client
I don't have an exact picture of how to architecture this, but I imagine you could accomplish this with a websocket
There's also eventsource, but that may be trickier since it's uni-directional.
I'd say to look into using a websocket
import turtle t = turtle.Pen() turtle.bgcolor("black") colors = ["blue","pink","yellow", "red"] for x in range(1000): t.pencolor(colors[x%4]) t.forward(x) t.left(90)
@heady stream you need some JS for that
guys how can i remove effects made from jinja2?
the outcome should be this:
but with jinja2, it adds more css effects and the outcome is this:
this is the code of what should it be:
code of what i did with jinja2:
Hello everyone. im deploying a django project as a test on heroku wanted to know if i can use my local static file on heroku?
As much as that seems like a pretty good offer, it is against the Rules here to have the ads sorry
You sure its not escaping and / or overriding tailwind's css
try class="m-1"
anyone?
@nimble epoch django staticfile deploy on heroku you can look over the following document https://devcenter.heroku.com/articles/django-assets
i don't think it is escaping them probably it's just adding new ones too
now imma try m-1 thanks guys
ok so if yaself know it doesnt support it to use static files localy then i gotta use something called whitenoise. right?
ok thanks i am
and of course im looking.... do you yourself have any idea about it?
i never deploy static on heroku before, i usually use nginx on VPS to serve my staticfile folder
like you hosting the staticfile folder?
yeap
don't know if that a good choice, why not use an amazon s3 server instead?
i dont want to pay money lol
i mean heroku staticfile deploy is free
or any free web services?
you can deploy django on heroku without costing money
yeah im reading the docs youve just sent so that ill do that
@gaunt marlin just read this => ''Your application will now serve static assets directly from Gunicorn in production''. should i use something in Procfile to access static file or just like dev, i gotta add something like {% static ..... %}?
or im wrong?
oh ok i got it.thanks
@nimble epoch do you want to run django on heroku with production or development environment?
oh i'm just asking, because you don't have to handle staticfile on heroku if django is in development environment
guy who here is good at react?
oh
Hi, can anyone give me a good link that talks regarding what languages are needed to develop a website both back and front end? (Including Python)
from flask_wtf import FlaskForm
from wtforms import BooleanField
class MyForm(FlaskForm):
if settings[0] == 1:
my_default = True
else:
my_default = False
name = BooleanField('name', default=my_default)
@app.route('/dashboard/<int:guild_id>/commands', methods=["GET", "POST"])
@requires_authorization
def dashboard_commands(guild_id):
cursor = mysql.connection.cursor()
cursor.execute(f"SELECT * FROM commands WHERE guild_id = {guild_id}")
settings = cursor.fetchone()
form = MyForm(settings)
how to i fix it to work? I know about _init_ and make another function but how to i return form then?
Hey everyone. Have questions about Django.
For example if I have article model and want to steam it into my template i usually do it with {{ article.content }}
but if i want stream one content into few separate <div> first half of text from article.content </div> and <div> second part of text from article.content</div>
How can i do that?
maybe you should add two model functions to your model, one gives back the first part, one the second, those model functions you can call similarily to fields in a template.
how can i pass input from html form to python (flask) i am new to flask and html so forgive me if im being silly somewhere
Can anyone here help me out with web designing, I just got a theme and I wanted to change the background video every time someone changes the slide, I can only get one video to play in the background and it wont change to another video if I change the slide
I am in Code/Help 0
wait
wth I cant talk in code help :/
Ping me if you can help me, I can screen share my issue
I want to use my local dajngo media folder what should i set DEFAULT_FILE_STORAGE to?
Thanks looks like a plan.
Hey, is it possible to have html page running with form where user can type something and send it to python script running on other device? I want to call functions with arguments (from html) remotly from website and run scripts on raspberry.
I can make a simple html page with CSS and js but I don't know where to start. Searching on internet did not give me anything useful. Maybe you guys would help me?
you mean your raspberry runs a web app which is accessible in a local network (LAN) only?
where's django's default login.html located?
run django server on raspberry pi
from django.contrib.auth import views as auth_views
..., path('login/', auth_views.LoginView.as_view(), name='login'),
hey guys,
so I am following the following code to create a progress bar (loading bar): https://github.com/deshraj/flask-SocketIO-Progressbar
In my web portal as I click Run button to perform my web's functionality, my web starts loading forever and nothing new happens as I am supposed to enter a new tab!
As I enter: http://127.0.0.1:5001/socket.io/ I get the following message:
"The client is using an unsupported version of the Socket.IO or Engine.IO protocols"
I am running:
python-engineio 4.0.0
python-socketio 5.0.4
Flask-SocketIO 5.0.1
and I have changed the javascript socket.io version in the github from 0.9.16 to 3.13.2
According to flask documentation, these should be compatible!
Hey Guys,
I need to use classes in my app.py from another .py in my directory in my flask app.
my structure looks like this:
app.py
forms.py
config.py
init.py
in my app.py file, i need to use a class from forms.py.
I've tried to do so like this:
from forms import loginforms
@app.route('/login')
def login(formsetUp):
form = formsetUp.get(formsetUp()
return render_template('login.html', title='sign in', form=form)
however, im getting TypeError: login() missing 1 required positional argument: 'loginforms'
Full Stack Python explains programming concepts in plain language and provides links to the best tutorials for those topics.
Does anyone have a link for the django discord channel
or is there django help in here?
or is there django help in here?
@wintry dome here
I want to to enable password reset/forgot password with django rest-auth but its a little sparse for help in the rest-auth docs. What's the flow for building a password reset? It seems like a POST req (/rest-auth/password/reset/) should be made with the email address. And then some how and an email needs to be sent to the user. And then from there another POST req (/rest-auth/password/reset/confirm/) should be made but there's supposed to be a UID and token that goes with the POST req but I have no idea where this comes from or how to send emails out with it
and I've been searching around and can't find any tutorials either
I need some help with django-rest-framework
so I've got views like this
class CategoryPositionsPatchView(MultipleObjectMixin, generics.UpdateAPIView):
serializer_class = api_serializers.CategoryPositionSerializer
permission_classes = [IsAuthenticated, ManageCluster]
def update(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
ref_cluster = get_object_or_404(api_models.Cluster, id=self.kwargs['cluster_id'])
api_models.Category.positions.update_object_positions(serializer.data, ref_cluster.categories)
return Response(status=204)
class FieldPositionsPatchView(MultipleObjectMixin, generics.UpdateAPIView):
serializer_class = api_serializers.FieldPositionSerializer
permission_classes = [IsAuthenticated, ManageFields]
def update(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
ref_datasheet = get_object_or_404(api_models.DataSheet, id=self.kwargs['parent_id'])
api_models.Field.positions.update_object_positions(serializer.data, ref_datasheet.fields)
return Response(status=204)
class MultipleObjectMixin(object):
# A mixin that ensures that the view at hand can
# only take in an array of objects.
def get_serializer(self, **kwargs):
kwargs.pop('many', None)
return super(MultipleObjectMixin, self).get_serializer(many=True, **kwargs)
I would like to make an abstract base class so that the PositionsPatchView suffixed classes can inherit from it
can someone please help me with it?
Which is better to use? Django rest framework or django as full stack
Hi
Anyone familiar with any decent shared hosting for python web apps?
Heroku, pythonAnywhere and linode are expensive for me
heroku has a free option
you can use that
I use a web hosting service, called alawaysdata.net. its a french web hosting service they have a free plan
it depends, if you want to deal with other APIS and stuff, maybe django rest framework
it depends, if you want to deal with other APIS and stuff, maybe django rest framework
@buoyant shuttle Actually I am looking to build a cryptic hunt platform.
Yeah but then there will be times that the website becomes very slow or goes down
Resources to Master Full Stack Development | Beginner to Advanced (https://youtu.be/WQPkYvGsWo8)
Please watch full video. This can give you so many resources that you might want.
Many of the people have contacted me of asking for resources and which learning path is the best and most efficient for full stack development.
The problem with most of the people is that there are tons of courses and materials available for free on internet but they are confused with which one to use and which one not to use.
So in this vide...
hello can i get help in flask?
error
NameError: name 'Links' is not defined
link of code:- https://pastebin.com/7NKv9FRW (new to python)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
which line
61-63 and 30
im assuming Links is a class for the table?
you need to import that
name of import?
import Links?
you are trying to query the database
yea
what is the class for the table you are trying to access
it should be {Class}.query.filter_by() something along those lines
from yourapplication import User User.query.filter_by()
Anybody using MongoDB with Django?
I am using Mongo Atlas (free tier) on a Django website. Everything's running fine from my local, but on server all my queries are running slow. For instance an update_one() query that takes around 0.5 seconds on local is taking 4 seconds on server. Shouldn't it take the same time since the query execution is taking place on Atlas server? Or do I need to tweak some server settings?
Anyone is really good with css and js in Django? If yes, please let me know
I'm trying to fix a problem that I have been postponing for weeks
thanks
how to redirect wherever the current url is in django?
hey whars your problem
wdym, I do not understand
you could use the redirect function, inside of your function abased views
you can reference this, https://docs.djangoproject.com/en/3.1/topics/http/shortcuts/
if you mean in html, a href. instead of placing hardcore links like you would normally do in html you can do this in django. ```py
<a href="{% url <whatever the name is designated to your view in urls.py > %}">logout</a>
Tsoke I fixed it thank you man
coool π
instead stay wherever it is before the user does that task
so you mean when your user clicks on anything, the views should not change route?
in that case, you can use the redirect() function
yeah
redirect where?
wait i just finally understood what your question meant @native tide
If you want your user to do multple stuff on your website without changing webpages, or redirecting urls. Use Javascript
Thats basically what the langauge is meant for, it does the logic in a website.
Django only handles backend, with databases. Retrieve information, and collect. You will need to use the DOM effect of javascript to accomplish that
there should be a way
let be give you an example of what i actually mean
i can understand but idk how can I do it
is there any way I can do some django view funtion on clicking a html element?
even by using js
yeah it can be acheived using JS thats what is called fullstack development
i like how im trying to do something but i have no ideas to create an app
if you want frontend flexibility, you will have to use a JS framework for the frontend, django as backend API
exaclty
i regret not using react from start
now I have progressed a lot already
lol
Ive been there
I was making a project for 5 months, almost half way there, then something happened to my hard drive
@native tide do you have solutions for it?
lost all my work and rage quitted.
damn
damn bro, same happened to me but I had at least some of it uploaded to github...
it really is a life saver
how far have you progressed?
almost 50% of the project
yeah i should done that, i wanted to upload to github after i was done
that's not the way you use github though
I push to github after every feature changes
Well, maybe continue, but you can still implement React (you will have to learn it though). It will take away all your frontend progress
With a django/react project most of the time spent imo is on the frontend anyway
by a large margin
Because all you have to do on the backend is just setup a few API views and your models, some serializers, that's really it tbh
yeah but I will have to reorganize the whole project π¦
If reorganizing you project is the concern, you can use Vue.js. I haven't used it in any major project but have played with it for a while. You just need to load the Vue <script> tag in your html file and initialize the Vue app.
When using jinja, if i have a stylesheet in /static, and i want to use it with another static html file in /static, can i do the usual {{ 'static', filename="foo" }} to link it, or do i have to hardcode it in?
bruv
I made a todo app
and when I open it from my phone I see the tasks that I typed from the computer
how to fix that? I am using django
@vernal furnace do you have authentication in the app
nope
can someone help me with how to setup django on idle
@granite pasture any errors you are facing?
thing is I have never used Vue.js anywhere before
i was earlier now i got it solved from youtube π
it was saying pip not recognised
Ok
@granite pasture pip install --upgrade pip
HOW DO I REDIRECT TO SAME PAGE IN DJANGO?
@native tide
in your views.py
from django.shortcuts import redirect
return redirect('/')
@granite pasture nope
I am waiting for my hero academia
:O
that leads to the home page
ok before i start django i need to google about what is web development 
Instead put the page url before the slash
Not the whole url
One min lemme get on my pc
@native tide Redirect works in a lot of ways, but since u only want to return it to the same page add your path before the slash
for example I have this in my urls.py
from django.urls import path
from . import views
urlpatterns = [
path('todo', views.index, name='list'),
]
dude I have applied the pagination
Anyone what can I do in css to keep the page from showing the edges in white
Like it is showing this white edge
Have you tried width: 100%@plain zealot
it might be body and/or html where you need to set padding/margin to 0
body, html { margin:0; padding: 0 }
@native tide why would you want to redirect to the same page?
so, I have some contents and have used pagination feature. I have added a bookmark icon on each items. when a user clicks on that icon, it works well, but it redirects to page 1
I did that
But when I stretch the page it still shows the white page
And in smaller sizes it still shows the white space
@plain zealot can i see your css?
Can somebody show me how to make a simple form in flask that if you press sumbit button, python prints the input. I'm stuck at this from 2 days 
Edit: found it if somebody needs help too: https://www.youtube.com/watch?v=AEM8_4NBU04&t=446s
