#web-development
2 messages ยท Page 79 of 1
https://www.youtube.com/watch?v=UmljXZIypDc&list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p
@quick cargo this was really useful for me starting out, I highly recommend this
In this Python Django Tutorial, we will be learning how to get started using the Django framework. We will install the necessary packages and get a basic application running in our browser. Let's get started...
The code for this series can be found at:
https://github.com/Core...
I can't avoid js when creating a web app Right?
Alright
So I can't cover for it with python?
@manic grail in web development to get into any company u need js
html css js - the main 3 in web dev
you can in theory, but in practice, JS is much better
Oh, alright, I have time to learn
you need basic JS tbh
Website JS is alot simpler overall compared to Node in reality
And what about TypeScript?
typescript is just strictly typed JS that you'd then need to transpile to js
Angular uses TypeScript
i havent really seen it used in frontend based stuff properly
html,css,js part in fontend python js(node)- backend
So:
Flask
Bootstrap
React
MySQL
Heroku
Is it enough for a decent web app?
i use postgres
u need to know how to use git aswell
@manic grail u need to know sass aswell
Sass is related to css?
yes
css framework
^
you do not need sass, it is helpful though. Raw CSS is writable though
i find the grouping css is very easier with sass - more organized
Heroku isnt needed
Heroku isnt used at all unless you want a lil free host for some basic stuff
MySQL is optional, alot of people prefer noSQL or Postgre best of the shitshow mySQL has been and still is in places
what about firebase
ye, sass is definitely nicer in that regard. But it adds more steps to compilation and deployment, which can be a pain
firebase or heroku
true. I guess if you are beginner stick to normal css for now
I am not a newbie developer, I am quite experienced, although out of all the programming languages I used am the least experienced with python, Anyway, I am struggling with choosing a framework-> Flask or Django?
firebase inst the same thing as heroku
@manic grail just try both and see which you prefer
hmm
Its not hard to learn both tbh
for the vast majority of websites, you could toss a coin and do fine either way
django file structure gives me headache
yeah same here
Django forces you into good practices
Some people told me it is easier to learn Django after knowing Flask
nah flask is amazing
alot of new people who use flask tend to fall into a really messy organisation system full of random global varibles
flask to django makes it easier not django to flask
Lol
Not really had an issue other than found it more awkward to properly organise stuff in Flask
i actually went django to flask
yeah you are right, im not very organized with my flask app
same
yeah
should I first study front end or start with django?
issue when people arnt forced into poper structuring
Well, organization is quite important for me, will Django make it easier to Organize stuff?
well DJango forces you to organise shit properly
yes
im gonna start using blueprints, my project is getting too big
and is designed and forces you to make things modular etc...
@quick cargo i 100% agree with u
flask does not, which often leads to people having messy code
i said bye to django when i saw the file structure
My only concern is that people told me that Django is more complex
i really wish flask had that, forcing us to structure better
i wish flask wasn't mirco-framework
@quick cargo you think flask blueprints is good for organization?
in many cases handling stuff for you
I dont use blueprints
I made a custom backend system when i was using flask
oh
Never used it lol
yeah good ORM, i heard djangos ORM is better tho
it's amazing
Hmm I guess I'll use Flask and If the shit hits the fan I'll learn Django
django uses their own ORM
Django's orm is probably the best orm in python
@manic grail u wont be disappointed with flask, its fun
What's an ORM?
and probably one of the best of any web framework in any language
apis works with flask really well
Oh wow
and everything becomes a object
Nice
flask-sqlalchemy use orm
alchemy is the orm
yes
When should u use Angular over react?
personal choice normally
I still havent learned any frontend framework
you dont even need React or Angular overall tbh
react is amazing u can build clone like ,yt,twitter,facebook
maybe jquery? idk if thats a frontend framework
What's Form validation lol
jquery is for animation
not really
thats good
jquery can be used for Dynamic reloading etc... as part of AJAX
U think vanilla js is enough?
yh
Generally or for python web apps specifically?
https://crunchy-bot.live/home This is basic JS tbh
tho i havent finished this site at all
i heard vanilla js is a good knowledge to have
generally speaking you dont need to have a front end framework
and plenty of sites dont use it
wait what
this looks nice, what did u use with this site
tho it can be helpful at times its certainly not required
some basic JS and TailwindCSS
ehh yes and no
Well, I have been told frameworks save you from a few headaches hehe
ah
but yes you can customise how it builds the css files
what are u hosting this on @quick cargo
my server
So I can get away with bootstrap and vanilla js?
yeah
i use figma because i don't like bootstrap in my website
Although I want a really good site, want to make it BOMB, it is a project for next year
never used bootstrap tbh so wouldnt know
bootstrap is good to put together a quick layout
@manic grail u can make ur own styling if u have a lot of time
No lol
id design a website using figma and put it together with html/css and some js
and then add in the backend
design,html,css,js ,python(flask) flask-sqlalchemy for database = proper website
@manic grail just start with flask tutorial
WSGI frameworks are good then you get into the work of ASGI systems for performance and more 
Is fullstack development a wanted job
yes
Does it pay well?
flask and django wouldn't be nice without jinja
i think most programming related jobs pay well
๐ค Django doesnt use jinja
if u find the right job
wait django don't use jinja
yh
Well, it is a good think to have in the resume
if i remember Django's templating engine came before Jinja and Jinja was a superset of Django's engine
oh
oh
What's js's main part in a website?
front-end
user interaction?
generally
user interection = font-end
animation, dynamic reloading stuff like that
^
@quick cargo do u know how i would use dynamically updated charts with flask
So gui, dynamic reloading, asthetics and stuff like that
@distant trout you wouldnt generally
that would have to be done with JS on the frontend
ohh okay
pygal
i learned matplotlib for no reason ๐ฆ
im gonna look into something like line charts
u can create chars using pygals
So, React is only for gui stuff?
generally yes
And Vue?
@native tide can i use with flask
yes
ah, ill look into it, thanks
np
Flask, Bootstrap, React, I have a lot to learn ๐
And deployment to cloud.
And the general basics of HTML, CSS and Javascript ah.
Fun. ๐ฏ ๐
Good luck, sorry for the monolog lol.
@manic grail bootstrap easy, just need to remember few classes that u will regularly use ๐
I ended up more overwhelmed and confused ๐
Can I use both flask and nodejs in an app?
Do you need something moderated?
no.
Please only ping that role if you need something moderated.
ok, thank you.
!mute 742012925950165043 1d Pinging the Moderators role multiple times, spamming the same message over and over again to various channels. Not a great start on our server.
:incoming_envelope: :ok_hand: applied mute to @native tide until 2020-08-17 20:28 (23 hours and 59 minutes).
I am trying to learn about REST API
I am having a problem trying to access the specific one I am working on
https://api.assetpanda.com/api-docs/v2#!/session/Api_V2_Session_token
How do you login to this via 0auth
I already have an account
and the client id and client secret
any push in the right direction would help a lot
How do I start a web app?
anyone know how to work with chromedriver?
Whenever I want I play my online CS50 course I fall asleep. Please help
yo
yo
@twin sable Watch it 1 hour after waking up and with that have a cup of coffee
If you can sleep under those conditions you're a degenerate
Also turn up the volume, open the blinds, brighten the screen. Wake up don't be a dungeon master
hi
Is anyone out theere
yea
Hey @crimson shard!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
my tables are not adding in the database
{% extends 'users/user_form.html' %}
{% block extra %}
<p>Click To <a href="{% url 'login' %}">Login</a></p>
{% endblock %}
How do I get it to show block extra?
{% block title %}{{ action }}{% endblock %}
{% block body %}
<form action="" method="post"> {% csrf_token %}
{% for field in form_user %}
<div>
{{ field.label }}: {{ field }}
</div>
{% endfor %}
{% for field in form_profile %}
<div>
{{ field.label }}: {{ field }}
</div>
{% endfor %}
<input type="submit" value="{{ action }}">
</form>
{% endblock %}
{% block extra %}{% endblock %}```My user_form
Oh I had to put block extra in block body
did you run makemigrations first?
yes,i have made some changes to my models file
And did you also migrate the migrations you made?
it says there is no database table. Is this the first run?
How could I implement something like this in django, if a object of a model is not modeifiet for lets say, 7 days, it gets deleted?
Can I just simply use a property?
@limber laurel if the timing doesn't have to be precise, you could just keep track of the modification datetime in the object and then run a cron job every day or hour or whatever to delete them if it goes over the timer
@uncut glacier What is a cronjob/how could I do that, and would it be better than setting a property?
https://django-cron.readthedocs.io/en/latest/installation.html I guess this is my answer to my first question,
is anyone familar with django authall?
i have an error
Hi, I'm working on a flask project, while I'm trying to do some css changes, the interface is not changing, even I change some html tags , it's not working.. It's showing previous result..
How can I fix that problem
disable cache in the network tab of devtools
@heady hearth ctrl f5
Stupid question, when creating a web app Do I still need to create a separate server or Django does it?
Sorry for the stupidity
During developpement django comes with its own server, however for prod you'll need a webserver (apache/nginx)
I mean, do I need to build a server from scratch, sockets, protocols, all this?
I am not talking about deployment
Well, I am not sure ๐
Nah you don't need to do any of that
Oh cool
So, um, how do you deal with requests and stuff like that in Django?
Is is dealt automatically with routing?
Ok, and what about some functionality that is done separately, some processing I need to do?
In this case do I need a separate server?
I disbales cache, while I'm trying to refresh the page, it's shows the previous styling results, even I restart the server,
Source code also shows the previous code..
Then changes are not applying
Fatal error in launcher: Unable to create process using '"c:\python38\python.exe" "C:\Python38\Scripts\pip.exe" install request': The system cannot find the file specified.
i have this error when i want to install pip requests
django
?
i learnt django
I disbales cache, while I'm trying to refresh the page, it's shows the previous styling results, even I restart the server,
@heady hearth I had the same "problem". Hold shift when you reload the page. That worked for me
I am deeply confused, I ak trying t9 install a package im vagrant, and I get a permission error, when I look at the permissions, all users have all of the permissions
You'll probably get more answers in #tools-and-devops or #unix for this
Ok
Hey there, im creating a simple web page. With some forms. I wanted to change all of them to wtforms (security reasons) but i guess i miss something. My webpage has a navbar, some of the items open a modal in which the form will be shown.
Since the navbar is inside my base template, every other template i gonna load needs to return the form. For me this seems kinda redundant.
OK i've solved it. The Modal without innterHTML stays inside the base file. OnClick an ajax call requests the template with the form. On success the innerHTML of the modal gonna change
Anyone with experiece with PDFRW lib ?
I'm having trouble getting started on a project. I want to write a simple notifier program that lives in the system tray / notification area on Linux and/or MacOS that shows notifications for new events on support tickets owned by the user. The product we're using offers an API, but I'm not sure exactly how I would leverage it for this purpose. Would anyone be able to brainstorm or guide me in the right direction? Happy to this in DMs to keep channels clear.
I assume I need some sort of http server that is listening for POSTs to a particular ticket id or set of ticket ids based on which user is auth'd with the app... or perhaps I'm thinking about that wrong...
You don't need a http server, just a http client that makes request to their api, and since you want something in the system tray that's not really web development
@bleak bobcat my bad I thought it might qualify as backend since it's dealing with http and API. can you recommend a better place for my question?
Hmmm....Maybe #networks for the api calls part, but for the rest it would be a generic help channel
thanks for the direction ๐
is there a way to make a registration form without haviong the user to pass in passowrd,
<p>
</p>
<p align="center">
<img alt="" src="assets\images\E1.png" ></p>
<p>
FIGURE <strong>E.1</strong> Schematic of a distillation column.</p>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="width:312px;height:228px;">
<p>
<img alt="" src="assets\images\E2.png" ></p>
</td>
<td style="width:312px;height:228px;">
<p>
<img alt="" src="assets\images\E2b.png" ></p>
</td>
could someone tell my why these images are not loading in, I have never used HTML before. i have other images written the same that are loading in and more that aren;t
I was about to ask the same question with a background
I'm pretty sure its smth with flask
And other ones
what's flask?
Hi, hoping someone can help. I'm getting this error when trying to submit my Django form:
'date1' value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.
I have a model with this:
meeting_datetime = models.DateTimeField(blank=True, null=True)```
A file to manually create the dates and times with this:
('', 'Choose...'),
('date1', '2020-08-25 14:30:26')
)```
and calling my manual data in forms.py:
`meeting_datetime = forms.ChoiceField(choices=DATESTIMES)`
Any help would be greatly appreciated!
I also tried adding the timezone like this: 2020-09-04 06:00:00.000000 UTC and these:
2012-09-04 06:00:00+0800
2012-09-04 06:00:00.000000-08:00```
But none of them work, I get the same error as above.
does someone know how to prevent beautiful soup from taking the text of a child (eg:
<div class="match-item-event text-of">
<div class="match-item-event-series text-of">Group Stage–Group D</div>
Cyber Games Arena Pacific Open
</div>
``` I just want to take `Cyber Games Arena Pacific Open` but bs4 gives me also `Group Stage...`. Here is the python code: `.find("div", {"class" : "match-item-event text-of"}).text`
why does my padding go inwards
whenever i use a pixel value e.g. padding: 5px; it adds the padding to the current width and height
but when i use a percentage value e.g. padding: 5%; the padding reduces the width of the element so that the element is ultimatley the same width
basically it minuses the width
django vs flask?
django
Also, quick question about django. is the variable pk saved in relation to model ids?
like when using it in the url paths
@dull jay that argument is more nuanced than x vs y
They are just tools, pick the right one for your job. Django is more inclusive, but comes at the cost of a steeper learning curve. Flask is easier to learn and faster to use right off the bat, but you have to do more bolt-ons to make it work like Django
someone help me please im getting this error with selenium well might not be selenium as such but ye
@half bough have you tried using the default widget? Why are you overriding a DateTime Input and passing it a string value?
@sturdy pike what do you mean
someone help me please im getting this error with selenium well might not be selenium as such but ye
@sweet field [17396:9180:0817/201811.393:ERROR:device_event_log_impl.cc(208)] [20:18:11.393] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
voice chat boys
hey how do i use cookies in aiohttp_jinja2?
i searched but couldn't find docs
oh?
so how do i use cookies in general XD
sorry but i am new to web-development
and i heard i can store the user info from discord in cookies so i can define that this info belongs to this user
thanks
.grid-contain {
display: inline-grid;
grid-template-columns: auto auto auto;
background-color: #2196F3;
padding: 10px;
}
.grid-contain img {
border: 1px solid #ccc;
box-shadow: 2px 2px 6px 0px rgba(0,0,0,0.3);
max-width: 30%;
}
{% for project in in projects %}
<div class="grid-contain">
<img src="{% static project.thumbnail.url %}" width="100%">
</div>
{% endfor %}
hi,
i have an issue with using a grid layout with a for loop
i want the images to be shown on 3 columns but it only puts the pictures on the first one and i don't know why, any idea?
it looks like this
last_visit = session['code']``` so i use this part ?
how do buisness website make such cool templates
css and time
hey i got this error RuntimeError: Install aiohttp_session middleware in your aiohttp.web.Application
import pyrebase
from aiohttp import web
from aiohttp_session import setup, get_session, session_middleware
import discord
from discord.ext import commands
import aiohttp_jinja2
import jinja2
from pathlib import Path
from oauth import Oauth
async def verified(self):
@aiohttp_jinja2.template('home.html')
async def start(request):
raise web.HTTPSeeOther(location=Oauth.discord_login_url)
@aiohttp_jinja2.template('cover.html')
async def login(request):
session = await get_session(request)
last_visit = session['last_visit']
print(last_visit)
return``` the code @quick cargo
this is a cog btw
@sweet field [17396:9180:0817/201811.393:ERROR:device_event_log_impl.cc(208)] [20:18:11.393] Bluetooth: bluetooth_adapter_winrt.cc:1074 Getting Default Adapter failed.
@sweet field bruh you guys are so useless on here i need an answer ASAP
@sweet field ๐
i mean i did ask at 20.18 my time
that's rude of someone who asks for help
Luckily for us we're just volunteer's and arnt your servants :P
nice
but i would expect someone to help me if i asked nicely
they could have at least said soz boet cant help you
what a terrible attitude
@stoic knot you should read the example https://docs.aiohttp.org/en/stable/web_quickstart.html#user-sessions
it shows how to install the session stuff when making the app
import asyncio
import time
import base64
from cryptography import fernet
from aiohttp import web
from aiohttp_session import setup, get_session, session_middleware
from aiohttp_session.cookie_storage import EncryptedCookieStorage
async def handler(request):
session = await get_session(request)
last_visit = session['last_visit'] if 'last_visit' in session else None
text = 'Last visited: {}'.format(last_visit)
return web.Response(text=text)
async def make_app():
app = web.Application()
# secret_key must be 32 url-safe base64-encoded bytes
fernet_key = fernet.Fernet.generate_key()
secret_key = base64.urlsafe_b64decode(fernet_key)
setup(app, EncryptedCookieStorage(secret_key))
app.add_routes([web.get('/', handler)])
return app
web.run_app(make_app())```
there are lots of beginners here and also more experienced people with knowledge in different areas. Sometimes people aren't able to help, it doesnt mean they have to respond to tell you they cant help
you can ask in a help channel but you do have to be patient
if no one can help you, then read the docs or google the error message
and try to debug yourself
@quick cargo i did
i even copied the whole example and i still get the error
you can ask in a help channel but you do have to be patient
@quick cargo lol patient ive waited 1 and half hours
ok
@sweet field if you actually gave us more to work with people might be able to see whats wrong, but last time i checked selenium had nothing todo with bluetooth directly so
i did say that in the orignal message btw
someone help me please im getting this error with selenium (well might not be selenium as such but ye)
lol
that gives us litterally no info
whatsapp open and then closes with that error
๐คฆโโ๏ธ What is your code
hastebin is not working
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
https://paste.pythondiscord.com/ilaretiwey.py @quick cargo ty
okay
well first off your indentation seems way off here:
secondly you dont actually install the middlewear like the example tells you todo
app = web.Application()
# secret_key must be 32 url-safe base64-encoded bytes
fernet_key = fernet.Fernet.generate_key()
secret_key = base64.urlsafe_b64decode(fernet_key)
setup(app, EncryptedCookieStorage(secret_key))```
hmmm but it works fine?
like its under the @aiohttp_jinja2.template
oh so that's the middlewear
i already have the app defined so i will use this part secret_key = base64.urlsafe_b64decode(fernet_key)
also idk where to put this setup(app, EncryptedCookieStorage(secret_key))
and it seems i can't pip install cryptography
No matching distribution found for cffi!=1.11.3,>=1.8
ah nvm
@quick cargo i think this example is outdated or something
everytime i fix something i get another error
this is the last error setup(app, EncryptedCookieStorage(secret_key)) TypeError: setup() takes 1 positional argument but 2 were given
code : https://paste.pythondiscord.com/widucunibo.py
if i'm just making a rest api and probably some sort of webhook service and want something quite light weight what would you recommend? I've recently been shown quart and that seems to do what i need
hi @dark hare no, I haven't tried using the default widget yet
@dark hare I guess I was confused on how to pass a DateTime value to my drop down
hey my flask server returns js files as text/plain when i include them like this:
<script type="module">
import {init} from '/js/file.js';
otherwise .js files have correct mimes. any ideas why this could happen?
i saw ppl suggesting to fix my windows mimetypes, i did, but the error still persists
i get this error:
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain".
Did you omitt type="text/javascript" @native tide ?
i can't declare that when it's an ES6 module
also, it's the import that behaves incorrectly
Are you building an API?
I think it has more to do with how your request is sent and what is the Content-Type of response
the code above is how my request is sent
/js/file.js is interpreted as a text/plain, for whatever reason
Have you looked into this:
https://stackoverflow.com/questions/11773348/python-flask-how-to-set-content-type/24852564
no, but i'm serving this as a static file
i'm not gonna override all my static modules to an explicit request
me neither, btw this all got fd up on its own
I been working with flask too much for past few days, sometimes things work, sometimes they don't
better contact a flask ninja
I have implemented it on my blog but I need to configure the styles, and implement the ability to upload photos from machine.```
well it's not a fix and btw the web can go get coitus, but changing the extension from js to mjs solves the issue ...
mjs would be the correct extension, but until now it was just a recommendation
found a reference: https://stackoverflow.com/questions/57492546/what-is-the-difference-between-js-and-mjs-files
yeah and now your whole project breaks because of this
classic web tech skiddery ever since 1990
I thought it would be more like changing the extension... or do you handle things for different extensions specifically?
right
now i changed all the files and it works ๐ unbeliveable
not to mention i'll have to change like hundreds of files in my other projects
Automate all da thingies
i am habing trouble trying to add a car icon using font awesome i downloaded the css but it isnt working. i have the code but still isnt working
how does this user page look (im really bad with designing)
only using bootstrap and fontawesome for the icons
it looks serviceable
hey guys
thanks @vestal hound
It looks nice, I would consider centering the div that is on the left, then tucking the sidebar away on the right. But I am bad at that too.
Should be learn XML for flask data processing project
Or JSON
I already know some JSON so it should better if I learn XML aswell
XML isn't used as much
I wouldn't learn it unless you have a project you know uses it
Can anybody explain simply what the meta class does in Django in one sentence?
If you say it in a way that I can understand i'll fly over to your house and finish you
Having some issues with DB in Django, specifically trying to use Djongo (MongoDB) instead of SQLite3, things were working fine, now suddenly receiving database errors when I try to Migrate - anyone willing to lend a helping hand? ๐
Notably trying to set up Django REST Framework for API function to export JSON
not sure if that is an issue or anything
--flush migrate zero haha
How does that work? Did a cursory search found nothing but I think the --flush is making it difficult to search it
I tried django-admin flush but it also turned up errors
did python manage.py flush || confirmed and erased, still producing errors when I go to migrate
Is it possible to have a Django user without a db backend? I'm looking at SSO auth options.
flask.cli.NoAppException: Could not import "project.project"
whats this>
So fellow Django users, what do you prefer or think is better than the other: 1. Creating a custom user model or 2. using the default user model by forming a OneToOne relationship with your required models?
If anyone wanna work on a project together, dm or ping me (preferably in django) :)
Heya
I made this project called DomeCode. https://domecode.com/
DomeCode is a platform that simplifies your process to learn code and provides you with other tools as well to help you learn to code. Get more, with less hassle.
For those of you who don't know what DomeCode is,
I made a previous post on this subreddit about it, https://www.reddit.com/r/Python/comments/i9g0oo/made_a_platform_for_people_to_learn_code_practice/
DomeCode is an open-source application that helps you learn and practice code with the appropriate tools and a curated list of resources through the philosophy of practice. Itโs a single workspace where you can advance your coding journey with compiled resources to learn programming concepts, take notes, plan tasks, practice coding problems, discuss interesting stuff on the Forum, meet other developers and most all have the musical element with all of it without ever leaving the single workspace to navigate to dozen platforms.
Open-sourced at: https://github.com/the-domecode Would love contributions and stars!
You can sponsor the open-source project at https://domecode.com/sponsor
DomeCode helps you learn code, practice, discuss, take notes, plan and more with the appropriate tools and a curated list of resources from a single platform. - DomeCode
DomeCode is a platform that simplifies your process to learn code and provides you with other tools as well to help you learn to code. Get more, with less hassle.
If anyone wants to contribute to it, lemme know :))
i am habing trouble trying to add a car icon using font awesome i downloaded the css but it isnt working. i have the code but still isnt working
@native tide which version are you using?
Okay
i am facing a problem with flask> can anyone help me?
What problem @jagged sonnet ?
when I change a static file (css), the changes are not showing in flask live server.
i have to clear the browser cache, then changes works
How are you including css file?
Did you use url_for or the normal one?
url_for
Try using the normal one
And run the server on debug mode to make it easy to see changes
:/ don't know really, did you deploy it yet?
Yeah that's the thing, I read a blog about this and they advised to use a content delivery network for this type of thing
After deployment of course
For now I think you should keep cleaning the cache or look up another solution
ok. thanks
Np
hello, I have an error but I don't understand why :/ here's my code and my error https://pastebin.com/4Wpe0VFK can you help me please ?
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.
Can anyone from here help me out at #help-candy
I have a flask app where the current user can add employees to a SQLAlchemy employee class and projects to a project class. the current user has a one to many relationship to their employees and projects, so that users can only access their employees. I am now at the stage where I need to assign the employees to the projects via a many to many relationship. In order to do this, should I make a join table with just two columns, an Employee ID foreign key and a Project ID foreign key? Then when I query the table add a filter_by(backref=current_user). Or should I make the join table have 3 columns, adding the user ID as well? Basically I want to render a list of all the employees that are working on a given project, that belong to the current user .Im brand new to all things programming and Im trying to wrap my head around this.
has someone ever worked with lightbox or lity? the css frameworks?
Hey guys, im using next.js + nextauth.js in frontend with django rest api as backend:
The auth and it's provider and settings for it is taken care at frontend and when I signin I get the following data (example):
user object
{
name: 'xxx',
email: 'xxx',
image: 'xxx'
}
account object
{
provider: 'google',
type: 'oauth',
id: 'xxx',
refreshToken: undefined,
accessToken: 'xxx',
accessTokenExpires: null
}
profile object
{
id: 'xxx',
email: 'xxx',
verified_email: true,
name: 'xxx',
given_name: 'xxx',
picture: 'xxx',
locale: 'en'
}
How can I use the above data to login to django rest api?
{
name: 'xxx',
email: 'xxx',
image: 'xxx'
}
is available throughout the frontend btw, though I don't know if that's of any use in here
Please ping me when replying
hey! I'm learning Flask and I'm doing the flask tutorial. Flask keeps defining things as special objects like g' and 'current_app' and I don't know what that means. I have a basic understanding of OOP but I don't know what a special object is. Is that specific to flask? From the goggling I've done I think it has something to do with being specific to each request? But I'm really not sure.......
@glacial tapir yes they are flask specific. https://flask.palletsprojects.com/en/1.1.x/appcontext/
thanks!
Hello! Iโm trying to click on instagrams heart button in the dm box but itโs class name is the same for 3 other buttons and it has no name or Id. Anyone know?
ok. thanks
@jagged sonnet Hold shift and reload the webpage. That will change the cache
for flask can you do flash(render_template())?
I'm trying to make my module runnable online, I know about Brython, any way I can have a text field that would run (with my module pre-installed) on a website?
So that when you click "Run" it would run the import my custom module and then run the code?
Not like a Shell interface, more like a text box
Please ping me if you have any ideas :)
So, I have a weird issue with Django where the DIRS list in the dictionary in the TEMPLATES list in the settings.py file appears to not be read when run on an actual web server, but it doesn't have any problems locally. Does anyone know what the problem might be here?
Nevermind, figured it out. Turns out the server requires an absolute path, whereas the localhost development server takes a relative path.
for flask can you do flash(render_template())?
@native tide I do not understand why would you want to flash (render_template())?
You can't anyways, I was making a sign up page but realized I can render_template a new html file completely for the account verification
Hi guys, I'm currently working on an API server that featured login/register, email confirmation and password resetting options, I've decided that the use of JWTs for each option isn't good (due the that fact that I will have to create a blacklist for used tokens and use different "secrets" for each token so an attacker couldn't use them)
I thought about the following design, two tables:
- users
- tokens
each user can have multiple tokens (each token record contains an foreign key of the user id) and each token have a "type" column, the token type indicates it's purpose (e.g "auth", "emailverify", "passwordreset")
what do you think ?
can't you just gen tokens and give them an expiry date
@native tide that's not a solution for my second problem - I don't want to maintain multiple tokens secrets, I don't want people to be able to reuse the password reset token and I think blacklisting jwts is stupid
Why would you have to maintain or blacklist? When a user requests they want to change their password, gen a token with an expiry date of 15 mins, then an email is sent with their token and redirects to a new link. As soon as the link is pressed the token is used up, it can't be reused and is deleted
Are you using flask?
the technology here isn't part of my considerations, I'm talking about the design
the application code will get bloated if I use different secrets for each token (I already mentioned the various purposes)
although 15 minutes is indeed a short amount of time I don't want people to be able to use the reset link multiple times (and I don't want to create a blacklist for the used tokens)
Ok, so as soon as the token is used it can be deleted. Plus it can be stored in the user's session instead of a database. Look into itsdangerous
I think you got me wrong (+ I thought you meant to JWTs)
this isn't my problem here, I just asked a design question
storing this token in the user session is pretty useless
I want to create a generic token table, for authentication, email verification and password resetting, I asked for an onion about my idea for creating a "type" column
hello
trying to figure out how to place an unordered list, horizontally
everything ive looked at online hasn't helped
this is what i have so far
<ul class="menu">
<li><a href="{{ url_for('dashboard') }}">Dashboard</a></li>
<li><a href="{{ url_for('callagents') }}">Call Agents</a></li>
<li><a href="{{ url_for('schedules') }}">Schedules</a></li>
<li><a href="{{ url_for('jobsites') }}">Job Sites</a></li>
<li><a href="{{ url_for('reports') }}">Reports</a></li>
</ul>
</div>
</nav></strong>
</div>```
i knw it's supposed to be done in css
but everything ive tried doesn't seem to work xD
@swift sky so u wanna this be like nav-bar
yes sir
im googeling now
that aint it chief
stats?
how it looks
give me the html file and css file
!paste
just copy and paste the code here
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Staff Parent Template</title>
<link rel="stylesheet" type= "text/css" href= "{{url_for('static', filename='css/staffdash.css') }}">
</head>
<body>
<header>
<div class="container">
<h1 class="logo">Exp Staffing</h1>
<h2 class="navigation-menu">Navigation Menu</h2>
<strong><nav>
<ul class="menu">
<li><a href="{{ url_for('knowledge_articles') }}">Knowledge Articles</a></li>
<li><a href="{{ url_for('role_call') }}">Role Call</a></li>
<li><a href="{{ url_for('code_of_conduct') }}">Code of Conduct</a></li>
<li><a href="{{ url_for('training') }}">Training</a></li>
</ul>
</nav></strong>
</div>
</header>
{% block content %}
{% endblock %}
</body>
</html>
that's the parent template
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8"></meta>
<title>311 Project</title>
</head>
<body>
<h1> Welcome to the Exp Staff Dashboard </h1>
<p> Choose your options below </p>
{% extends "staff_parent_template.xhtml" %}
{% block content %}
{% endblock %}
</body>
</html>``` thats the dashboard html
ok wait
background-color: powderblue;
}
h1 {
color: blue;
}
p {
color: red}
menu {
display:flex;
justify-content: space-evenly;
}```
that's the css
give indent to the display ;flex and justifity-content
hmm
#menu {
display:flex;
justify-content: space-evenly;
}
try this
wait
try that
nothing
.menu {
display:flex;
justify-content: space-evenly;
}```
try this
we are styling the class so to style the class we need to use .whatever name of the class
i see
worked?
give background-color: blue;
no
give background-color: blue;
@native tide what do you mean
ill change it to blue
huh that's weird that didn't do anything either
so that didnt do anything
but odly
when i accidentally changed
background-color: powderblue;
}
h1 {
color: blue;
}
to
background-color: blue;
}
h1 {
color: blue;
}
it still didn't change anything
nav{
width: 90;
display: flex;
justify-content: space-evenly;
background-color: blue;
}
this should work
nope
i dont think my style sheet is working properly
it didn't pick up the change in what i wrote above
What browser u using?
u using chrome?
yeah
@app.route('/streamers/<string:streamer>')
is there anyway I can access the <streamer> in jinja2
{{string}}
I tried {{ request.endpoint }} but i get the function name of the route
im on a mac
@swift skygo to setting
<h1 class='text-center p-4'>Showing Stats For {{ string }}</h1>
this doesnt work ๐ฆ
ok
@distant trout u need to pass that string into def home(string)
yes
when i did cntrl shift i
yeah
ahh ok
press that
foudn the dev tools
ok
go to network and press disable cache
and keep it there
don't close that
ok
now
lets go back to code
nav{
width: 90;
display: flex;
justify-content: space-evenly;
background-color: blue;
}```
try this
and refresh the web page
ok
should we try flex box O.o
give
?
a{
text-decoration: none;
.menu {
display:flex;
justify-content: space-evenly;
background-color: red;
}
alright
show me>
ok i have to go bye
np
Heyy can someone help me with this issue please?
For an admin panel with Bootstrap (I'm going to use a template) and MySQL integrations, should I use Django or Flask?
Hi Good Night,Im making a blog and i have a question... for each post in the blog do i have to create a html for that post? does the blogs work like that?
i mean... i have let say a bueprint for each post i will create... do i have to use it to create each post and create a post1.html and the for the second one a post2.html and like that?
hey guys! ive never used py for web development but is it the same as normal py or is it modified for web dev
@weak lynx You could have a blueprint for reading posts that you pass the post number to and it pulls the data from the db. So, you'd have a post template, and depending on what post id you send it, changes the content.
So, your url might be /post/<id>/ and you're looking up id in your db, and filling it's details into a jinja template you render.
Assuming Flask for all this since you mentioned blueprints.
@hollow yoke Same Python. Look up frameworks like Flask or FastAPI or Django (not that any of them are required, just they're frameworks for web dev in python as a place to get started).
do i need to know html for this?
i know VERY little html so i'd have to get cracking on that
ya if you want to use flask, you should know a bit of HTML
So I'm looking to make a webserver to make a secure authentication system for a project I'm using. If I were to use a raspberry pi using my home-internet would it be safe / if it was ddosed would it effect my router.
I know the question is most likely stupid but when it comes to this web development and hosting and ect; my brain hurts.
@native tide home hosting is never safe
you will be exposed to the Internet and if you don't have any ddos protection installed (which I howly doubt since ur asking this question) then home hosting is not ideal
alr thank
hello, I'm facing a problem in fetching data from the database, while I'm try to do
x = mongo.db.fms.find(query1,{"_id":0,"due":1})
print(x)
im getting
<pymongo.cursor.Cursor object at 0x7f96939b9198>
please anyone help me to fetch the data
i am begging u please tell me how to fix the responsive problem on ipad like website is ok on all devices but on i pad it looks like a dustbin is the @lofty orbitia screen and (max-width:770px){} my only solution
dude sorry i cant fix the tag
med so sorry discord is glitching
i am talking html and css
and guys saying django
mi man i dont even like external stylesheets like bootstrap or any other
cause they so complicated for small things
wait. I just realized you were talking up top. I didn't even read it I just saw you typing something when I swapped over to this chat
we literally said the same thing "im begging u"
I was talking randomness
Maybe I can help you
What's the deal
ik thats y i am sorry
anyway the site is showing abrupt things when i check it out on ipad
lmao wut. abrupt?
aka a mess
ye
its not ipad responsive
lol
cause ipad width 768 px
noooooooo
lol y not
lol show css
its weird
thunder always uses it
@sturdy pike BRUh wut
OH you're a purest
he likes it vanilla
thunder don't lie I know you hate css
nope a noob

i dont have the time to learn bootstrap
lol
^^
but i never used it
you type words into the class attribute and it does everything
dead simple
as "net ninja" would say
I mean you can either use bootstrap in your project orr
can u send me exact code for alligning divs in a column on ipad that too centered ,divs are arranged in a row in the pc version
// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }
// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }
// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }
// Extra large devices (large desktops, 1200px and up)
@media (min-width: 1200px) { ... }
wtf
so i just copy paste this
no lol
and then define classes in it
you didn't even show me ur css
Aw shit.
let me
.cardContainer:after {
content:"";
display: table;
display: flex;
clear: both;
}
uhh buddy
thunders got this
can u post it on codepen or smth
in mobi they are in a column done via a width 100%
now on i pad i need 2 divs in 1 row
codepen.io pls @lean saddle I don't understand
yeah hes legiti watched it
I'm actually not that bad. I just want to take it beyond
I still feel scrubish
hmm
wait..
wtf
Don't you need them for changes in your css based on screen size?
I mean he only wants the cards to wrap according to width
not like he's changing card size or any other style
dang dude.. this is why you dont go to the web dev section in a python discord channel
tru
He totally gave up on us.
So thunder are you good with django?
yeah lol I work with it professionally
hello everyone
so should i learn django
No tran don't do that to us at 1 am
ig
do I need to know OOP well to start learning Django?
I don't use social media at the moment. literally deleted everything and phone broke but @sturdy pike
maybe ill be back
well not literally deleted. just the aps
Ig > i guess lol
lmao aw shit
why would I want ur Instagram
I was like why does he want to see my face. I'll do what i must to be a django god

^ exactly
just add me on discord
YES
a ok i need to go thank u sir
I totally get it.
I guess i'll go back to my endless youtube cycle with django. brb.. maybe*
Lol hold up
holding
I would love to XD
no
ok dm me lol
plz this is my shot
I couldn't
wdym
yea bruh u need to add me
just started learning Python
oh cool
I'm struggling at OOP
I do know classes class/instance vars and objects
Hello django developers!
I wanna add authentication to my website, should I better use default authentication system by django, or should I make my own auth system, or may be there some powerful packagaes for authentication?
Thanks, who will help
Thanks, gonna check it
django's auth via permissions is preety satisfactory for a lot of use cases
unless you want third party auth or social logins, it should suffice
hey im making my first website, does anyone know what i need to put in the terminal to get the adress?
when i put python3 app.py it doesnt do anything
app = flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True)```
Hi, I am a starter with Django and postgresql, is any front-end guy interested in making some cool websites as practice?
@dapper tusk
huh, that should work
im on windows so is there a different command?
try py
cause that the majority of my problems, that cmd's aren't the same as it is on apple
oh
ok
py or py3
Py will just open python shell๐โโ๏ธ
py app.py I meant
okok
Have you added python to path?
yup, windows has python3 open the store page of python, and if you pass any args, it does nothing
wonderful
now it says this
I think it is from flask import Flask
Just open the html file manualy :)
ahhhh maybe so, the second flask being Flask
thank you so much, the whole problmen was me not paying attention to the capitalization
problem
i think i got it
Hey guys,
I am developing an app for discord teams who use it as their main communication channel and i make the front end with react and the design with tailwind.
I'd like to share with you all the version <alpha>, that's going to change, but the main concept is that.
I'm really looking forward to hearing opinions from you all.
The purpose of the app is making remote teams communication better. Its not a replacement of discord, its a third leg, what you can replace the routine meetings/big announcements with.
If you wish, you can notify specific discord channels when you create a post. You just have to enable "Notification" options and add your discord account. Select from the available channels, and the bot's going to send a notification to that channel with the link to the post.
Thats good for managers, team leaders and those, who'd like to get the most important things in one place, and who DON'T really like to ask the same questions each day,week,month etc.
The creator of each routines can have an analytics about the answers, getting the best overview how your team feel today, or what are their biggest goal etc.
Some features will be definitely implemented yet.
But enough of talking, please let me know what do you guys think! I am so excited! ๐
Is somebody interested in it?
@weak lynx You could have a blueprint for reading posts that you pass the post number to and it pulls the data from the db. So, you'd have a post template, and depending on what post id you send it, changes the content.
So, your url might be
/post/<id>/and you're looking upidin your db, and filling it's details into a jinja template you render.Assuming Flask for all this since you mentioned blueprints.
@warm igloo Can you explainme how to do that?
can someone help me with this
@native tide did u install flask-sqlalchemy?
oml
how do i do that
do i need to use pip
yes
actaually my whole problem last night was that the commands were funky cause im on windows
what the commans
pip install Flask-SQLAlchemy
^^^
u always have to install flask extentions
pip install Flask-SQLAlchemy
in the terminal?
yes
pip is not recongized
wait what
is that a windows prompt?
try it on window prompt
no
what u using
like command prompt?
yes
i did '
same thing
that werid
pip is not recognized so i need a different command
cause i know i have it
u have env created
yup
oh
deactivate
what
just delete it?
no
wait
venv\Scripts\activate
activate the env now
i have the code to activate it so its fine if i need to delete
py -m venv venv
u have activated the env right
i already activated it
show me a pic
nice
its got the ()
now try pip install Flask-SQLAlchemy
how the fuck does that
work
i activated it last night
i mean thank you but i just dont understand
i think u installed pip while using env that why
worked
ahhh
ok does that install the datetime as well or do i need to do that next
datetime is in-built module
idk
oh
SQLALchemy is that supposed to be a l or an i?
L or i i mean
Requirement already satisfied: Flask-SQLAlchemy in c:\users\jansen\documents\flashintro\venv\lib\site-packages (2.4.4)
Requirement already satisfied: SQLAlchemy>=0.8.0 in c:\users\jansen\documents\flashintro\venv\lib\site-packages (from Flask-SQLAlchemy) (1.3.19)
Requirement already satisfied: Flask>=0.10 in c:\users\jansen\documents\flashintro\venv\lib\site-packages (from Flask-SQLAlchemy) (1.1.2)
Requirement already satisfied: click>=5.1 in c:\users\jansen\documents\flashintro\venv\lib\site-packages (from Flask>=0.10->Flask-SQLAlchemy) (7.1.2)
Requirement already satisfied: Jinja2>=2.10.1 in c:\users\jansen\documents\flashintro\venv\lib\site-packages (from Flask>=0.10->Flask-SQLAlchemy) (2.11.2)
Requirement already satisfied: Werkzeug>=0.15 in c:\users\jansen\documents\flashintro\venv\lib\site-packages (from Flask>=0.10->Flask-SQLAlchemy) (1.0.1)
Requirement already satisfied: itsdangerous>=0.24 in c:\users\jansen\documents\flashintro\venv\lib\site-packages (from Flask>=0.10->Flask-SQLAlchemy) (1.1.0)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\jansen\documents\flashintro\venv\lib\site-packages (from Jinja2>=2.10.1->Flask>=0.10->Flask-SQLAlchemy) (1.1.1)```
sligth issue
L
what
Alchemy is spelt with an L
scratch that
when i put from app import db in the python shell it says this File "<stdin>", line 1, in <module> File "C:\Users\Jansen\Documents\FlashIntro\app.py", line 2, in <module> from flask_sqlalchemy import SQLALchemy ImportError: cannot import name 'SQLALchemy' from 'flask_sqlalchemy' (C:\Users\Jansen\Documents\FlashIntro\venv\lib\site-packages\flask_sqlalchemy\__init__.py)
go to env
and what do you mean by that
did u type python
no
i typed py
in temerial
type
python
cause im on windows
it's ok
when i do it opend microsoft dtore
u can use python in terminal
ok im in
woah
from app import db
and show pic
hmm
is there something wrong with my code
from flask_sqlalchemy import SQLALchemy
from datetime import datetime
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
db = SQLALchemy(app)
class todo(db.model):
id = db.column(db.integer, primnary_key=True)
content = db.column(db.string(200), nullabe=False)
data_created = db.column(db.DateTime, default=datetime.estnow)
def __repr__(self):
return '<Task %r>' % self.id
@app.route('/')
def index():
return render_template('index.html')
if __name__ == "__main__":
app.run(debug=True)```
ok let me test this code
wait
there are different folders
i have app.py, index.html, main.css, and base html
u have app.py main file and templates and statics right
yes i do
it's ok
ik what to do
what is pychace
pychache
oh it's useless
oh ok
don't worry about that
@native tide try this command on terminal pip install flask_sqlalchemy
ok
just in the plain terminal or in the python sub thing
terminal where u installed all packages
ok
using env activated
what is teh actuvate code again
no
venv\Scripts\Activate
here?
pip install flask_sqlalchemy
^ try this
ok
after installed
type python
from app import db
requirements satisfied
yes
now
so now i put python in
yes
then type from app import db
yes
like this
press enter?
yes
ok
ok wait
i will
oh
what?
not from flask_sqlalchemy import SQLALchemy correct from flask_sqlalchemy import SQLAlchemy
u typed from flask_sqlalchemy import SQLALchemy
which is wrong
flask_sqlalchemy import SQLAlchemy
flask_sqlalchemy import SQLALchemy isw wrong
yes
from flask_sqlalchemy import SQLAlchemy is right
yes
silly mistakes
haha
now

