#web-development
2 messages ยท Page 23 of 1
@fathom prism i have not. so if im not mistaken, are you implying to make a html template page specifically for just a footer?
i feel like thats not optimal
why not?
The other option is to place the <footer> in your base template
Stick this in your base html
<footer>
Content here
</footer>
@fathom prism thanks
๐
Guys i can't handle django anymore
I don't think I like it.
How do you guys feel
I really do like python though
@radiant river by "can't handle" do you mean you find it too difficult or do you not like the way you're meant to use django?
If you find it too difficult, with practice, you'll understand concepts quickly.
If you understand how to use it but dont like the "django way", try a framework like Flask
Flask is a bit easier to grasp
hi i have flask pandas table and i want to sort her like DataTable.js
how i do that
hey would u define this as a user defined algorithm?
https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvi-full-text-search
idk
i have now ather problem
i have probelm on my project i try to open url from html
i
text = request.form['text']
processed_text = text.upper()
url = 'https://data.gov.il/api/action/datastore_search?resource_id=ff3b653c-...
can some one try to answer
plz
anyone know if there is a method to get the next tag after a particular element via dom ideally
for example if you have
<li class="something"> ... </li>
<li>... </li>
something to call on the first element to get a reference to that second one
oh nvm
nextElementSibling works
how can I make my page always appear in desktop mode and never shrink
@native tide Does your page have a viewport meta tag?
Anyone know how to replace all non Alpha Numeric characters in the Jinja2 template engine?
Like right now I have something like this:
<a href="/article/{{row[1].lower() | replace(' - ','-') | replace(' ','-') | replace('?','') | replace('!','') | replace(',','') | replace('.','') | replace(':','')}}/{{row[0]}}">
but having to use | replace for every single special character will get out of hand. Is there an easier way?
@warped robin if you also want to discard accents and stuff:
import string
valids = set(string.ascii_letters + string.digits)
text = "Hรซllรด Wรธrld!"
print(''.join(c for c in text if c in valids))
would print
HllWrld
Also please tell what exactly are you trying to achieve
Because it really looks like you are trying to reinvent the wheel here
I ended up telling him about slugify and pointing a link to a jinja extension in the help channel
which I think returns hello-world for that string
Hello I'm running into this error ./src/Components/Playlist/Playlist.js Module not found: Can't resolve '../BaseComponent/BaseComponent' in 'C:\Users\Sreyeesh\Documents\GitHub\Codecademy-Jammming\jammming\src\Components\Playlist'
I'm not sure why this is hpapening from what I can see I'm following the instructions on how to use this code
import { BaseComponent } from '../BaseCompnonent/BaseCompnonent';
import Spotify from '../../util/Spotify';
import SearchBar from '../SearchBar/SearchBar';
import SearchResults from '../SearchResults/SearchResults';
import Playlist from '../Playlist/Playlist';
import './App.css';```
can anyone help me ?
https://github.com/Sreyeesh/GitHub/blob/master/Codecademy-Jammming/jammming/src/Components/App/App.js
that's how the structure looks like within git
Hey
I'm up
Man traefik-auth-forward is poorly documented
I think I've got it working. I mean it works but i don't know how robust my config is, and I don't understand how it's working
Both of those things annoy me
can someone explain to me the difference between filter and get
Hi,
I created image recognition app with flask. User uploading image and AI model trying to predict result and returning it. But there is a problem. If user click predict button directly before upload any image than its returning last result of uploaded image.
How can i avoid of this problem? Should i search about session?
PS: all images are uploading in the same folder.
@app.route('/math', methods=['POST', 'GET'])
def math():
if request.method == 'POST':
print(request.form)
formula = request.form.get('formula')
a = float(request.form.get('a'))
b = float(request.form.get('b'))
n = float(request.form.get('n'))
hz = eval(request.form.get('hz'))
h = eval(request.form.get('h'))
All of the variables are None somehow and request.form does not exist? 
My .html file:
<html>
<body>
<form action = "http://localhost:5000/math" method = "POST">
<p>Formula <input type = "text" name = "formula" /></p>
<p>a <input type = "text" name = "a" /></p>
<p>b <input type = "text" name = "b" /></p>
<p>n <input type ="text" name = "n" /></p>
<p>hz <input type ="text" name = "hz" /></p>
<p>h <input type ="text" name = "h" /></p>
<p>Formula number <input type ="text" name = "formula_number" /></p>
<p><input type = "submit" value = "Submit" /></p>
</form>
</body>
</html>
Hey guys, how do you properly use flask "@login_manager.request_loader". I can see from the "flask-login" example how to load "Authorization" header but how do I pass token(JWT) to that "Authorization" header?
So that every request is login_authenticated (@login_required)
If someone can point me in the right direction, that would be great.
hello
i have this error where class.whatever is not callable
made a new file.py and i'm trying to use the data i queried from the database
Is psycopg2 the normal flask extention to use to connect to postgre?
I believe the package has been renamed to psycopg2-binary or something, but yeah I think it's the standard PostgreSQL adapter
๐
Hi! I have a question for you good folks if you have the time ๐
I'm trying to create a web app that allows users to select a few favorite restaurants from a list of restaurants, then when they hit 'recommend', it should trigger python scripts that eventually return another list of restaurants
I just need everything to run locally for a demo,
I've been recommended Flask + AJAX but I'm having trouble getting started
I already have the python scripts and all written - I need help displaying all that information on a webpage
hey guys
anyone here uses rest
i'm trying to do this with my permissions.py:
class IsAscomOrReadOnly(permissions.BasePermission):
def has_permission(self, request, view):
if request.method in permissions.SAFE_METHODS:
return True
else:
if request.user and (request.user.groups.filter(name='ASCOM') or request.user.groups.filter('Administrador')):
return True
return False
But says: Error: to many values to unpack . Expected 2
But with the:(request.user.groups.filter(name='ASCOM') or request.user.groups.filter('Administrador'))
But should not this be regarded as just an argument?
Which HTTP error code would correspond to the situation where the client makes a request which is not valid in the current system state, but which may be valid at a later time if the system state changes?
403 Forbidden?
hello everyone, i have a problem that i am currently stuck on and was wondering could someone help me
i'm current working on a zero touch provisioning project and i'm very stuck is there anyone that is good with python and familiar with linux, tftp server and dhcp servers
i'm following a online tutorial of zero touch provisioning. here is the link https://networklore.com/ztp-tutorial/configuration-templates/
Networklore
Using configuration templates
The ability go generate configuration based on a dynamic template in a critical part of a ZTP setup.
the part of this which i do not under stand and i'm sure that it is easy is to set your environment variables, both in the windows you are running the TFTP server and the one thatโs running rq.
you can see at the bottom of the page it asks me to set these environment variables. i don't know how to do this and believe me i have tried.
i'm sorry if i'm not being descriptive enough i am very much a noob
The ability go generate configuration based on a dynamic template in a critical part of a ZTP setup.
Hi. Does anyone explain me please how to work correctly with HTTPS requests sites using a VPS as workspace? I have been looking for information about this for several weeks already, I try various options, but nothing happens.
What i mean. I have created a simple request-script that collects information from website (try/except/if/else omitted):
# Some code
s = requests.Session()
r = s.get(url)
# Work with r.text
It works perfectly and correctly when i run script from my laptop (url can be http or https).
I have VPS (Ubuntu 16.04 Server) with clean installation (added only python 3.7 and libs). I posted and run script on the server, but it works correctly only with http sites. When i place an url with SSL errors occurs:
1.
Connection error: HTTPSConnectionPool(host=<https_url>, port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f1dba341320>: Failed to establish a new connection: [Errno 110] Connection timed out'))
Connection error: HTTPSConnectionPool(host=<https_url>, port=443): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x7ff938fa44e0>, 'Connection to <https_url> timed out. (connect timeout=10)'))
I tried to add a .crt, .pem, .key files as parameter for request, but nothing happens (new errors occurs (such as SSL doesn't correct and others)).
There is a problem with server? Or i need put some unusual headers (which i didn't put on laptop) to a request?
is port 443 closed for whatever reason?
hi, I was wondering if anyone here recommends a small business to use site builders like wix or wordpress or if there are better alternatives for a sales landing page?
That's not really a lot of info to go on. (Not that I can help you anyway, I'm not a webdev and don't know anything about js.)
However, it will probably help to be a bit more descriptive
!ask has some information on asking good questions
Asking good questions will yield a much higher chance of a quick response:
โข Don't ask to ask your question, just go ahead and tell us your problem.
โข Try to solve the problem on your own first, we're not going to write code for you.
โข Show us the code you've tried and any errors or unexpected results it's giving
โข Keep your patience while we're helping you.
You can find a much more detailed explanation on our website.
<!--Bootstrap Css-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Optional theme -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
My bootstrap collapse button is not working (nothing happens when I click on it). I have tried for a couple of hours fixing it but with no success hopefully someone here can help me find where I am mistaken
<nav class="navbar navbar-expand-md navbar-dark bg-light fixed-top" >
<a class="navbar-brand leftoright verticalline" href="#">
<button class="navbar-toggler navbar-light" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse rtl" id="navbarSupportedContent">
<div class="navbar-nav">
<ul class="navbar-nav">
<li class="nav-item">
<div class="d-inline p-4">
<p class="nav-link online" href="#">492 ืืืืืจืื</p>
</div>
</li>
<li class="nav-item">
<div class="d-inline p-2">
<a class="nav-link" href="#">ืืชืืืจืืช</a>
</div>
</li>
<li class="nav-item">
<div class="d-inline p-2">
<a class="nav-link" href="#">ืืจืฉืื</a>
</div>
</li>
<li class="nav-item">
<div class="d-inline p-2">
<a class="nav-link" href="#">ืืืจืื</a>
</div>
</li>
<li class="nav-item">
<div class="d-inline p-2">
<a class="nav-link" href="#">ืืืจืืืื</a>
</div>
</li>
<li class="nav-item">
<div class="d-inline p-2">
<a class="nav-link" href="{%url 'events'%}">ืขืืืืื ืื</a>
</div>
</li>
</ul>
</div>
</div>
</nav>
why ithe products urls doesn't work ?i don't want ecommerce urls
@honest hinge Does the ProductDetailSlugView have a model set that has a slug field?
i really confused
{% for book in resp %}
<a href= "{{book[2]}}">{{book[0]}}<input type="hidden" name='bookid' value="{{book[1]}}"></a><br>
{% endfor %}```
im trying to get bookid when i click the anchor any ideas?
i mean im trying to pass bookid
Is there a fast basic template I can use to launch a simple website for my business with linux? I'm trying hugo right now but started getting a headache I'm ready to just pay for dynamic hosting to avoid the headache but thought I might ask here first
hey all, I'm paginating a queryset of like 320 records right now and its growing. If I wanted to easily add a "rank" column to these results, is there an easy way to do it without killing performance? A bit lost since its a generator
The rank is basically just a incremental number from 1..n based on the queryset order_by
Hi just an update that I solved this using a Window Expression
Why does Django look up on comments in templates? I am getting error, becouse I have some HTML code commented. I need to remove it completly . Why is that?
anyone have a good example how to connect postgresql with aiohttp
Is there any type of framework that makes front end development easier(using markdown or something)
@native tide commenting the HTML out would lead to it not being shown, not it not being processed
Sorry for the excessive use of not
Did I understand you good? The good should not been processed?
I noticed I must but Django expression in {# code here #}
so my code: {%url 'polls:download' 1 %} should look like this {#%url 'polls:download' 1 %#}
Do you know the way to comment it in PyCharm?
CTRL + / is taking block of code and commenting it like HTML tags. How to comment Django expression with it as well?
so that 1. <a href="{%url 'polls:download' 1 %}">ISO</a><br>
will look like this:
<!-- 1. <a href="{#%url 'polls:download' 1 %#}">ISO</a><br>-->
OK, i have turned on Django Support in the settings window and now it works well.
anyone know how to do an input and an anchor, i wanna click an anchor and access a hidden input in a flask route
Does anyone here know how to make a search filter for a list of data?
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_filter_list
I'm trying to make something like this but instead of the list showing by default it's hidden and shows when user enters something
Does anyone have any info or suggestions for reading material / tutorials for learning about bugs and vulnerabilities for django 1.10 and how to patch them? Or insight into why Github tells me 1.10 has vulnerabilities and if I should be concerned? Just finished a bootcamp and they taught 1.10, so i'm rolling with it for now, but I want to make sure of what I'm doing if I build any websites and for my portfolio
my bootcamp is covering general security vulnerabilities, and maybe they cover this in a part I haven't reached, but it doesn't seem like it gets that specific.
where does it say that in github
on the repo page. "We found potential security vulnerabilities in your dependencies." If I click through to see the vulnerability, it gives me more information and directs me to the nist.gov page. I guess I should read more about that before I follow up with this line of questioning.
it basically just tells me on github to upgrade to 1.11 lol
actually, I think I may have just answered my own question. I guess the last time I looked I didn't find as much info, which was probably just my fault. lol
@quick spruce not sure what it's called but probably
i think thats what you want, you want to be able to have it recommend as you go right?
yeah
yo, im trying to get data from html to a wtform than be able to pass that data to a flask route, any ideas on how to do that
im trying to pass it when i click a anchor href but its going bad
that or i want to be able to click and anchor tag and have a hidden input but can't figure out how
do you have to use an anchor tag? I'm not sure if that's possible, but i'm not exactly super experienced with flask.
you could always use a route variable
darn and my team is really loving the anchor tag and it sucks lol
and with route variables you have to use them all right?
im trying to use 1 and pass the other
yeah, it's an parameter that you have to meet, unless you give it a default in the route
depends on the specifics of what you're doing whether or not it would work though lol
@app.route('/user/string:title', methods=['GET', 'POST'])
#@app.route('/user/string:title/string:bookid',methods=['GET', 'POST'])
@login_required
def user_book(title,bookid=None):
i want user/title but have to give it bookid somehow
couldn't you just query the title with just the book id?
also as an aside, i love projects with books ever since i misread bookid as boo, kid once and laughed for like 30 minutes
๐
either way, I think it's better to pass as little info as possible through the route, plus, if you pass only the id, you don't even need it to be a post route
unless there is a reason you don't want to query in this function.
lol boss just wants it to return user/book_name_is_cool
and i wanted an input so i can just grab it that way
it searches for books than you select one through the href and it brings you to a page
having it in a for loop is rough man
are there entryways to this route that won't have access to the book title?
Hello, what are the best resources for learning Django?
I am making a Flask application and i have writen out the code, i have flask_login downloaded but when i run it says module not found
im fucking losing my mind over this
Are you sure you are running it with the right interpreter/enviroment
@hollow flower You can check out the official tutorial https://docs.djangoproject.com/en/2.2/intro/tutorial01/
The official tutorial was not really anything I wanted.
Then what are you looking for
How do I build a simple site in Django.
Without the need for databases at this point.
DBs are very important in web development regardless, and the official tutorial doesn't only cover that
Regardless, I currently only want to build a site with the help of the Django's templating system.
@floral seal i am running it through the built in terminal in vs code and i tried normal terminal and nothing :p
try pip list
what
pip list to show all packages installed
it says its installed but its not in pip list
how did you install it? Just pip install flask-login?
i tried pip3 list and its there
aight
pip3 install flask_login
how are you running the script?
in vscode going to terminal > new terminal inside vscode
what are you typing
FLASK_APP=hello.py flask run
in pip3 list it says Flask-Login instead of flask_login but when i try Flask-Login in vscode it says syntax error
try to also install it with just pip
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/rl/cxf2wzwd78g98bnzljwfpqbc0000gp/T/pip-install-2LJHaE/flask-login/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/rl/cxf2wzwd78g98bnzljwfpqbc0000gp/T/pip-record-zP0tKD/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/rl/cxf2wzwd78g98bnzljwfpqbc0000gp/T/pip-install-2LJHaE/flask-login/
Idk how to change python interpreter that flask uses because I just use a venv, so can't help you with this one, sorry
wait i tried sudo pip install flask_login and it worked
it is running but when i go to check it it gives a 404
That went well. http://dpaste.com/3D476BB
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
How do you control or keep count of API requests your app have made in the past hour?
trying to make a website with aiohttp but i cant find how to make get and post request
how do I convert my session based authorisation app to token base authorisation? I use flask. my endpoints render templates
Hi guys
What is the best way to show a youtube-dl video download progress on a web page (flask)?
Per PyDis' Rule 5, we are unable to assist with questions related to youtube-dl, commonly used by Discord bots to stream audio, as its use violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2018-05-25:
4A: You agree not to distribute in any medium any part of the Service or the Content without YouTube's prior written authorization, unless YouTube makes available the means for such distribution through functionality offered by the Service (such as the Embeddable Player).
4C: You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate.
Okay
fortget about youtube-dl
How to display a progress bar until a function runs..
the products links doesnt work what do u think the problem?
im sure about the links
I have a div with max-width:30em and min-width:100%
How do I default it to 30em? and shrink when it hit's below it
(Need this for mobile/small screen friendly when it shrinks small)
how to do while with ssl_sock recv for multiple recv data?
without the timeout error
@lost saddle call distinct on your queryset?
still duplicate entries
>>> from mainsite.app_models import *
>>> Title.objects.count()
105
>>> Title.objects.order_by('entry__date').distinct().count()
105
>>> t = Entry.objects.last().title
>>> [*Title.objects.order_by('entry__date').distinct()].index(t)
2007
>>>
that's odd
@lost saddle does this fail?
a = Title.objects.order_by('entry__date').distinct()
b = Title.objects.order_by('entry__date').distinct()
assert a.count() == len(list(b))
@lost saddle yeah that is mentionned in the note here https://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct
you either have to drop the ordering (and order it with sorted or something like that) or deal with it
what are you trying to achieve exactly?
order titles by their entries date
if a title's last entry is the last created, that title is the first
So entry__date is a bit wrong even
should be somehow last_entry__date
@unborn terrace
@lost saddle why would entries have multiple titles though? ๐ค
Title's have multiple entries
I may have confused couple things here
Entry model has a foreignkey to Title
I want to order Titles in a way that
All the entries are ordered by date without titles involved
and take the ordered entries' titles
and distinctify them
so the first title in the ordered queryset has the last entry entered into the database
the second title's last entry is the second last entry that has been entered
yeah looks like you have to do this processing by hand
like
- get all entries
- filter out entries that are not the last one of their title
- query associated titles
or
or
have a property return the last entry date
and order by that
>>> Title.objects.annotate(last=Max('entry__date')).order_by('-last')[:5]
<QuerySet [Title(
creation_date=2019-04-10 09:54:48.623112+00:00,
creator_id=1,
id=105,
text=abc,
), Title(
creation_date=2019-04-22 00:36:19.977737+00:00,
creator_id=1,
id=107,
text=dasdasdsa,
), Title(
creation_date=2019-04-16 12:52:02.092744+00:00,
creator_id=1,
id=106,
text=vdczx,
), Title(
creation_date=2019-03-19 12:10:24.704826+00:00,
creator_id=65,
id=35,
text=Author public together land size thing,
), Title(
creation_date=2019-03-31 22:42:06.458405+00:00,
creator_id=1,
id=102,
text=sfdsdas,
)]>
>>>
@unborn terrace explain this
lmao
Okay yeah apparently this is my answer and it works with above config
One of the title's above didn't had any entry which made it error but overall it is what I need to do apparently
Is it possible to modify a Flask session inside a Flask SocketIO event?
@socketio.on("signup req")
def signup_req(json):
print(f"Response! {json}")
socketio.emit("signup res", "RECEIVED!")
session["user"] = {"name": json["name"]}
Someone used Scrapy (python library) to crawl websites?
How do I have an empty div at 500px x 1000px and when the screen is too small, it shrinks width
Either use a percentage based width, or you'll need media queries
note that CSS pixels are not screen pixels
Basically they are a ton of divs
That need to be wrapped if they cannot fit into the screen
this is what flexbox is for
set up a flex row, have them wrap when there isn't enough space, set a minimum width
bingo bango bongo
If you resize the screen, they stay the same width until it is smaller than the size
Then it smooshes the width down and makes the height larger
Hmm
use flexbox
I tried them yesterday to no appeal
Also do you set flexboxes on the divs themselves or container?
this is the problem it exists to solve
the link I gave you separates container vs item properties
so basically
flex container, flex direction row, flex wrap set to wrap
then set flex grow on the children as required
and that's about it
flex-basis can be used to set the width
did you solve it?
in bootstrap you can also set column sizes that changed based on the size of the viewport
Ok
each row is composed of 12 units and you can divide them based on what the viewport is
I done flexbox with no effect on anything
I need all items to be 30em, shrinking down to 100% if it goes below it
highly recommend looking at this if you havent already
it will automatically reposition your elements
when the viewport changes
Seen it but how do I wrap them
do you have your elements in rows/columns already?
@brave mantle I can't get flex-basis to set the width
It's a big for loop of 15 cards/divs
Set a minimum width as well, a min-with
I have like the container
Then an outer div for the card for margins
Then an inner that defines size
okay that won't work
Yep
you have the flex container
and then you have your flex items
and that's where the sizing goes
I'm not sure why you need a margin
So divs don't touch
Nvm I don't
.jilk-card-inner {
border-radius: 0.5em;
padding-top: 1em;
padding-bottom: 0.333em;
padding-left: 1em;
padding-right: 1em;
min-height: 13em;
flex-grow: 1;
flex-shrink: 1;
flex-basis: 30em;
position: relative;
margin: 0.75em;
}```
That's a div
.jilk-card-container {
clear: both;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: flex-start;
align-content: flex-start;
}```
This is the container
Can't get width working
you don't need to add an attribute just because it exists
for example, those two aligns
the position also will mess things up
It is needed
then you're doing something wrong
you also seem to be using floats
you should never need floats in a flexbox layout
Normal:
Without:
Not the width of the cards
I basically need it to align some items inside the div
align-content to start
er, flex-start
my question is why on earth you're using floats at all
I should also point out, you don't make a new flex container for each row
Hmm lemme see
you literally put everything into the same container
you do
But the rows will have 1-5 flexboxes on them
that doesn't matter
one container for all your rows
let the browser deal with positioning
That's what I done
also seems like you should be setting a max width
<div class="flex-container">
<div class="flex-box"></div>
<div class="flex-box"></div>
<div class="flex-box"></div>
<div class="flex-box"></div>
</div>```
yep
Done
But now things that are smaller than the max width are still smaller
That's the only thing I need to fix
Right is normal, left is too small
Nope
also, use rem instead of em
Bit too late for that one
ctrl+r
:P
I'm not sure what the problem is entirely
mess with it, see what you come up with
you can straight up set a width on them if you need to
use your browser's inspector
It makes everything a tad bigger
Yeah it messes with some bits
Basically, everything is fine with it but I just need empty divs to expand to max-width by default
If you define a specific width and smoosh the divs/flexboxes down smaller than width: Xem;
flex-basis is doing litrelly nothing
are you using some CSS framework?
Bootstrap with a lot of shoddyly written but working custom css
:/
when i try view a product it appears this error
All 270 lines of it
bootstrap is the IE of CSS frameworks
@honest hinge if you look at the page, it says "page not found"
you don't have a matching path in your urlconf
I would use a weird grid but how does that resize/wrap
they don't, really
i know but i couldn't find the problem
You don't have a matching URLconf
tha'ts the problem
it's not that you tried to write one and it was incorrect
you haven't written one at all yet
I'm not in a position to watch videos
๐
I will say though
bootstrap is not flex based
I believe they are mostly float based
so you're going to have a hard time doing this with flex
FYI the website works without bootstrap
I just use it for fonts, some easier aligning and navbar
generally I like to recommend flex-based frameworks
like bulma for example
because they make this kind of thing so much easier
ยฏ_(ใ)_/ยฏ
you can still do it with bootstrap, I just can't think of an elegant method
Weird that there isnt a 3rd option with min-x and max-x
If there was just a default-x it would fix this
Just make an empty div the default-x
Go to max-x if content overflows bounderies
sounds over-complicated
min-x if it underflows (?) bounderies
Well this is annoying
Only way to fix it is to add a ton of non-breaking spaces that sometimes ruins the formatting
There are light frameworks out there that only give you a grid or whatever
:/
im a biggnner
Max I could do
trust me, if I had a dollar for every time someone was screwed over by bootstrap
I'd be a rich man
I just need to expand that left card to full max width :(
I don't think its even bootstrap
It works the same but just looks stupid
do you only have 2 cards?
On the main website I have 15 per page
you're sure that your class is also applied to the first card?
If you had a 100" tv it would have like 8 cards in a row
It is
They are made by a for loop
and you can verify that in the inspector?
You can verify it in source code
{% for listing in listings %}
<a href="/server/{{ listing.guild_id }}" class="no-highlight">
<div class="jilk-card-inner darker-back">
<h3>
<div style="max-width:0em;min-width:100%;">
<div class="jilk-card-cutoff">{{ listing.name }}</div>
</div>
<img src="{{ listing.image_url if listing.image_url != '' else url_for('static', filename='img/no-listing-img.png') }}"
class="jilk-card-thumbnail card-custom dark-back">
</h3>
<p class="lead">{{ listing.description if listing.description != None else 'No custom description' }}
<div class="inv-widget-outer">
<div class="inv-widget members-special inv-widget-border">
<img src="{{ url_for('static', filename='img/member-icon.png') }}"
class="inv-widget-img inv-widget-border">
<p class="inv-widget-text">{{ listing.members }} Members</p>
</div>
</div>
</div>
</a>
{% endfor %}```
Oh discord did not like that
use your inspector
It is the same
there is a reason I'm telling you this
Anything I apply to it, also applies to the other
your inspector is not just for inspecting
you can modify the CSS rules to the right
allowing you to quickly mess with them without reloading the page
it's shorthand for grow, shrink, basis
recommended because it intelligently sets the others
Yeah
Is it possible to modify a Flask session inside a Flask SocketIO event?
@socketio.on("signup req")
def signup_req(json):
print(f"Response! {json}")
socketio.emit("signup res", "RECEIVED!")
session["user"] = {"name": json["name"]}
I tried this, but it didn't work.
I did that already before I used the actual session...
I thought it'd be a problem to do app.session
I'll just overflow my question in stack c:
Seeing that the stack is essentially an ordered heap where you can only take off the top, a stack overflow would basically be a ram overflow?
Nope, it's when the heap and stack collide
So basically I guess?
r/woosh
You don't know what stack overflow is?
The meaning of stack overflow
Not the website
@brave mantle I kinda ended up redoing the entire card system
Did it help?
Flex is easier to control
I am having some trouble setting up a cutoff with .. if text goes past a certain height though
hmm how to use asyncpg with aiohttp, should i just call it each time i need like linked in basic usage, i need it for web server
https://github.com/MagicStack/asyncpg
hmm i think i should mix them together in loop right? anyone have an example?
Cannot get Resizing things work for python3.7
xD
I am kinda use to things not working
So what am I doing wrong?
Template error:
In template D:\Programming\Websites\Python_Websites\Aava\templates\footer.html, error at line 2
Invalid block tag on line 2: 'blocktrans'. Did you forget to register or load this tag?
1 : {% now "Y" as current_year %}
2 : {% blocktrans %} Copyright {{ current_year }}{% endblocktrans %}
Help would be much apperiated. https://paste.pythondiscord.com/icehevured.py
Continuing tomorrow.
hey all, I have a pretty simple queryset that I paginate. Its about 500 records right now and I filter about 50 at a time. Is there any built in or packaged search options? Just looking to search on a field, provide any potential matches with a link to where it is on that page/table row
Hey is anyone around that knows how to close connections for a postgres database. Currently using Flask/sql-alchemy/marshmallow/postgres
anyone know how to send email with from aiohttp server, am trying to port my flask server to aiohttp
aiosmtplib to the resque xD
hmm jwtoken should i put in auth header or where? and what format should it be Autorzation: token-"dadsADsddfdsfds" or Autorization: "dasdsadasSADasd" or what ๐
what is the easiest way for a non developer to just get a template of a website that I can upload to my repository and then host on Netlify?
A gui
so polling a aiohttp server via browser theres an additional request to/for /favicon.ico whats the best way to handle/shutoff
@strange hollow try this ```python
@socketio.on("signup req")
def signup_req(json):
print(f"Response! {json}")
socketio.emit("signup res", "RECEIVED!")
session["user"] = {"name": json["name"]}
session.modified = True
Is there a limit to how much flaskrestful can send as a response?
Well, don't i feel silly now. I set the statuscode to return 204. Which i guess Flask is "smart" enough to not actually send anything then
I swear to god, I can never get CORS to behave 
Can someone give me a rundown on CORS with flask-restful
Cross posting from #help-chestnut
Can anyone help out with comparing datetimes in flask-sqlalchemy
entry = Entry.query.filter_by(user_id=current_user.id, timestamp='2019-04-13').all()
Its a sqlite database so I know the timestamp field is stored as a string but I'm not sure if sqlalchemy turns them back into datetimes when filtering
Also the timestamp field has seconds, 2019-04-13 16:36:15.592823
@honest flower This isn't the place for database help
#databases is where you want to go
Ill post there too but I figured this mostly revolves around how flask-sqlalchemy behaves
Thanks ๐
Anyone with good microservice knowledge ?
hi guys. I am having a problem lately
i have updated code on the waeb-server, and tried restarting uwsgi, nginx, and rebootet the whole server, i have also tried deleting the .Sock file
It doesn't register the newly commited code, even though it is right there
anyone use D3.js and Flask before?
I'm not understanding the django documentation on this. Does django come prebuilt with a working email backend?
Yes
I'd you have smtp server up and running or using one online, you just put your credentials and use something like
django.core.mail.send_mail
Maybe I didn't ask what I meant then, because that's pretty much what I meant. lol. So without an smtp server, it would fail. Thanks for the info! ๐
is there a best practices way to setup an smtp server on an ubuntu 16.04 server? everything I've searched so far points me towards postix.
Also, is there a good way to setup a localhost smtp server to use while I'm developing my site?
Papercut seems like it might be a solution to the second part, but I haven't looked too deeply into that yet.
trying to run flask on AWS EC2 but having some issues: [Thu Apr 25 06:07:58.106087 2019] [wsgi:error] [pid 4377:tid 140349786134272] [client 112.136.200.14:64526] from flask import Flask [Thu Apr 25 06:07:58.106113 2019] [wsgi:error] [pid 4377:tid 140349786134272] [client 112.136.200.14:64526] ModuleNotFoundError: No module named 'flask'
Did you install flask?
You can try to do:
import sys
print(sys.version)
That should show you the python version
Did you use the same python command to run the app as you did to install it?
trying to run it as a wsgi application which i dont have experience with
i think that it is launching python although im not sure how it is doing it
Do you have a shebang inside of your Python file?
If so, does it point to python or python3?
points to python3 if you mean #!
Guys, what happened with the Django discord group?
Hello
http://prntscr.com/ngqzkh
i run the flask app
but when i go to the browser
it won't work
i tried port 5000 and 4670 (random)
any output from flask terminal
just this
and is that localhost or '0.0.0.0'
np, that opens it up so other devices/ips can see it
To anyone familiar with django's simple_history:
Whenever I have a foreign key in a model as well as the history enable on it, I get a stacktrace as follows:
File "/usr/local/lib/python3.6/dist-packages/django/db/models/query.py", line 413, in create
obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python3.6/dist-packages/django/db/models/base.py", line 656, in save
if field.is_relation and field.is_cached(self):
AttributeError: 'IntegerField' object has no attribute 'is_cached'```
I stepped through this, the field it's referring to is the is field of the model.
Here is the model in question giving the above error:
```...
class SimpleTable(models.Model):
some_value = models.IntegerField(default=0)
some_foreign_key = models.ForeignKey(Asset, on_delete=models.CASCADE, blank=True)
history = HistoricalRecords()```
I'm a little stumped as to what is going on here, why adding a `HistoricalRecords()` field would cause this error.... 
Looks like the you may be either misspelling the method name (is_cached) or using the incorrect object (IntegerField). Check the docs again or use dir(field) to see what types of methods are available
It is clear from the traceback it is a method that django calls, not themselves
Maybe I'll get better luck here:
I'm looking to automatically submit some forms for what essentially is a calendar. The main webpage displays the events as a calendar. When I hit "Add an event" a popup window comes up asking for start date, start time, end date, end time, title, and description. This is all the processed by clicking submit, which adds the entry onto the periodically refreshed main page.
I'm aware that this could be handled using javascript, however:
1โฃ I'm trying to broaden my horizons in Python
2โฃ I am more proficient in Python, as I use it daily.
Essentially, I am wondering if someone can point me in the direction of a particular library, or perhaps combination of browser extension/library (to avoid having to store auth etc), where I could ultimately achieve the same results as javascript.
The end goal is to be able to run this each day and simply have it auto-populate the calendar since most of the events are the same every day. Unfortunately they don't provide a way to simply copy from the previous day and
simply adjust minor details to the day. Instead, they expect us to fill this out event by event every single day.
So I want to fire up my calendar for the day, run my python script and send a bunch of form submissions to populate the calendar with a bunch of preset events. Then I can restructure/add things that matter for that particular day manually throughout the day.
Please @me if you respond
@finite wren you could use selenium or figure out how they submit forms and use just http POST/etc requests
@opal leaf thank you for replying, I'll look into selenium. Appreciate it
Ah, seperate application, I'll look into http post requests via python then
I FINALLY figured out sendgrid integration! I feel like my progress is at a snails pace though haha.
finally found it this morning with a fresh mind
it was an outdated package...
I pip'd simple_history instead of django-simple-history.
how to create a cookie
on flask
- how to transfer data to html
to use
{{username}}
what diffrence bettwen make_response and Response
in flask, how do i send things to validate from the route.py than back once validated
Anyone here used restplus?
And I get this error:
https://cdn.discordapp.com/attachments/424345505607319569/571439012783587330/unknown.png
I'm new to flask so ye. (Did everything exactly the same as tutorial)
i keep getting this
on flask app
no errors
and it take like a minute of waiting to get this Time-out
what issues will i have if i directly run flask as production server?
Security
ok running it through gunicorn now is that any better?
Uhm so for a database (Before starting to learn web development), I usually use motor.motor_asyncio. Is it a good idea to use it with flask? If not what should I use for a mongoDB with flask?
what is your usecase?
Well right now as I'm learning it will be blogs and user logins/signups. But I have a discord bot that stores data into a mongodb, and I want to have my website pull that data from it and display it. And I don't want to use 2 different DBs for that. (Like SQLAlchemy for users and blogs and mongo for my bot data etc...)
I hope that made sense ๐
I don't see why it wouldn't work.
Might need to raise a 404 when you can't find a collection.
hi so i've got a bit of an issue with flask. i'm using uikit css for my frontend design and i have a form setup. it wont pass through as a POST request to my flask app, and I can't proceed with my register/login stuff. my app won't even load my database. im basically using the same code from another base script of mine, which works fine... please help. here's my full sourcecode, url-removed
i also have a models.py but im not sure how useful that will be
these are my requirements from a requirements.txt I froze https://pastebin.com/BiRwdcYu
I think I may have resolved it. I didn't add method='POST' to my form, haha, but db.create_all() still doesn't seem to work
do I need to create the tables and such myself?
fixed it all
thanks though ๐
please help xd
hello,how to make cml in correct path of app models cuz i made tow apps then i changed somethings in a its models how do i make migration for that in correct path?
Hello, I am having trouble getting Vue.js to render in my Flask template
This is my main.js https://pastebin.com/c2bGc6kt
Figured it out
Relatively new to web programming. Any recommendations on how to add TLS to flask
And roughly how much time it would take
i don't think you add tls to flask,i think you add it to the web server...
like dat
Thanks do I need a domain to use real certificates
yes, you need to purchase a domain name
or obtain one some other way
checkout namecheap
Oh thanks
GoDaddy says $1 for first year. Do you know if it works with AWS EC2 servers?
I don't see why not, But I have not done it myself
Ok thanks I will try it out
don't use go daddy
they're a terrible organization
i personally use ghandi.net, they're a french org.
Terrible like customer service or just bad people?
all of the above
You can check out AWS Cert Manager https://aws.amazon.com/blogs/aws/new-aws-certificate-manager-deploy-ssltls-based-apps-on-aws/
You still need a domain though
I was wondering why you recommended that site when it looked so bad lol
so, y'know, they don't give a shit about the interwebs and are only interested in turning a massive profit
Oh yeah SOPA
yeah, boycott go daddy
I was remembering all the stupid GoDaddy ads inatead
gandi.net has a great ui, a great privacy policy, and their shit makes sense and even if you get high traffic and a good domain name, they're not gonna charge you extra if you somehow let your domain lapse like go daddy has done
they've been my registrar and the one i've suggested for years. no guff, no bs, no ads woven into their site like go daddy does... pretty awesome. ๐
Hmm wonder if I should go with cheapo site with strange extension
i mean, what is it you're trying to do?
Personal site maybe show off some code projects
if you're going to use it professionally as a portfolio/live cv, top level domains like *.com's are penultimate usually and make you seem extra real
Hmm true
I'm not web designer if it matters
But I can see how com is just easier to read
i know this isn't super pythonic, but if you're just looking at showing off code, take some time and figure out how to make a mark down site on github to just show off codes
but if it's you selling yourself, .coms make you seem more professional, like you're there to do bidness
Oh yeah I have tried some MD with jekkyl but got confused by the framework
Have since done some basic stuff in Django and flask
Was thinking of adding them to a website to show off even if it isn't what I usually do.
@alpine oak have you ever tried Pelican? I am using it now. I was wondering what others thought
i haven't. nerver heard of it, but it looks alright. it definitely seems like a back end dev's ease of use cms w/o any of the bulk
It's like Jekyll, although I've never used Jekyll
It's for static sites. You can host it on Github
I just mentioned it because you said something about static Markdown sites on Github
yeah, i'm seeing that, super interesting. i'm reading the docs now, makes super good sense if you're not doing anything bananas and hosting up anything too big
book marked to revisis later
how does linking and css/js work on md sites
md doesnt have classes for tags right?
so would it be a bit hard to adjust your look?
that uses jinja, so it'd just be like using the flask templates when you're building it out
oh I see
yeah, and classes and other tags for css/js are kinda dirty
some of it i'm kinda down with, but css3's semantic tagging makes most of it kind irrelevant
css3's semantic tagging?
yeah
so back in the day everyone used tags to classify shit
w/ html5 and css3, you can just call article, aside, figure, footer, header, nav, section, summary
oh
yeah, html5 css3 and JS are freakin' amazing, and it's a travesty so many people lean on the old school methods so much, but old habits die hard.
nine it depends on your desire for security
i use my non shared email address for that
hmm thanks for the tips
bought a domain from gandi.net hopefully it finishes up pretty soon i want to set up site before finals lol
I need to learn how to make decisions faster so i stop wasting so much time lol
hello it is okay if i emulate a whole project from github?
With flask-restful, how would i get the body content on a request?
Hello everyone, I have small problem with Django. I am new to Python and Django. For my project I install virtual environment with python 3.7 and then install django version 2.2. Problem is when I create new django project the version is 1.11 and not 2.2. Could someone help me with that?
How do you create your Django project? Are you using an editor/IDE with virtual environment support built into it?
Alternatively, do you activate the right environment when running the project?
No I am using terminal to create virtual env I tried with two commands and the result is the same one is python3 -m venv env and second one is virtualenv env -p python3.7 . I am pretty sure that I was activated that environment.
Okay, can you do pip list for your virtual environment?
Just to check what's going one
Can you type in pip list with the virtual environment activated?
I'd like to see what it says
Okay, so it looks like it has the right version
To check, open the Python REPL (just type python with the virtual env activated) and type:
import django
print(django.VERSION)
That means it is using Django 2.2
I'm not sure why that docstring says otherwise
Maybe someone forgot to update it
Are you working with an existing project?
I am just starting from scratch.
Right, so, I'm a bit confused as to why that file seems to be in an older version
You did install django 2.2 in your virtual env and the import shows that you are using it
Ok thank you very much for your help. I will try something else. If I find a solution I will tell you. Thank you again for your time.
Hm weird. When I just deleted project and created it again now it says version 2.2.
hey folks. is it possible to write a python app that acts as an intermediary between an https connection?
I have a webstore that is blocked in a few countries due to their own firewalls (china), and heroku's hosting isn't blocked in those countries. I don't want to move my whole store to a new provider. I am wondering if I can just set up some https forwarding or something so I can reach these customers.
I found this post, but I'm not sure if it's what I need to do. https://stackoverflow.com/questions/28759915/python-simple-https-forwarder
I'm pretty sure what I'm trying to do is similar to what VPNs do. the customers that I currently have in those blocked countries use a VPN to purchase.
I know i'm not the first person to try to do this. hopefully someone here has done something similar to this.
Hey. I would appreciate if anybody could help me with my stackoverflow post, people there seem to be a tad bit slow. Thanks! https://stackoverflow.com/questions/55908295/modulating-my-code-with-python-flask-doesnt-seem-to-work-very-well
how can i use something like opencv with heroku
hey guys, has anyone ever used Jinja for their webapps before?
i need some Jinja help
https://github.com/alanhamlett/pip-update-requirements (fixed link for you)
@long zinc I've tried this library and it works exactly as advertised.
It depends on your workflow, but it could be worthwhile; I ended up not using it, but that's just because of personal preference.
It seems convenient. I just was wondering what others thought
Hello,
i want to fix a bug on my website the route is
@app.route('/say/<string:word>')
def say(word):
return word
if i go to
http://nice.domain/say/hi
i works
but if i go to
http://nice.domain/say/hi/
it says
Does someone know how to obtain the liveChatId parameter of a livestream that is not mine so I can use it in the LiveChatMessages method list? Context: https://developers.google.com/youtube/v3/live/docs/liveChatMessages
did channels just die?
Its so hard to find stuff on it other than "Build a chat room"
ugh
it was a 3rd party project
got into django roof
and now it is maintained but not developed any further
what version of django did you install?
2.2.1
Your error says the feature you are using was removed in django 1.10
python -m django --version
when i run this its showing 2.2.1
need to make a virtualenv?
You need to change the code where you are using django/templatetags/future.py
That hasn't been in django since version 1.10
Try deleting all django files manually and then reinstalling.
It might still have some files from a previous installation
And yes, I would make a virtualenv for all projects, precisely to prevent problems like you are having now.
@ancient zinc those are different routes. Iโd recommend against it as itโs confusing, but you can use the path converter instead of string to achieve what you want
So I want to build a micro social network for gamers. I'm talking a web portal to discuss ideas, but one that integrates with the Discord, Teamspeak and game servers. Would anyone else be interested in a project like this? We'd be using Python of course, as well as Nuitka for compiling it down to faster speeds. I'm thinking a community could spawn out of this, and api's be developed for game servers as well.
I forgot this was more than a help channel lol and Jack if they can integrate
Do you mean like use teamspeak and discord or just have it be intractable with elements from them?
Anybody got any advice/go-to libs for someone looking to implement a dashboard to a webapp running on Flask?
Hey guys
anyone here know django rest framework?
class IsAscomOrReadOnly(permissions.BasePermission):
def has_permission(self, request, view):
if request.method in permissions.SAFE_METHODS:
return True
else:
if request.user and (request.user.groups.filter(name='ASCOM') or request.user.groups.filter(name='Administrador')):
return True
return False
i'm trying to make a set of groups to have a specific permission. I make like this, but now i need to add more groups to this permission.
@chrome river Check out eel library. See if that helps.
just built a small app using eel. It is shown in UI section of this server
I was looking at Dash but that already runs on Flask and rewriting what I have to keep using Flask whilst also using Dash is a pain so, I'm kinda just stitching bits and pieces together. Hadn't heard of eel, I'll check it out, thanks ๐
It is a really small library. But I did build an app in a day using it..
and I am no developer... I am on the web side of things.
Look at Electron as well @chrome river
Concept is the same. But I noticed most people who use Electron, still end up using Flask... for python boilerplate.
Also not a developer, I work in information security but I need a webapp to frontend my botnet monitor, still searching for the ideal solution ๐ hopefully either Eel or Electron will work. I think I'd actually settled on using Flask with everything bootstrap'd and Bokeh for data vis. The rest I would do from scratch D:
Would like to see screen shots if you get it up and working @chrome river
class Perm(BasePerm):
def has_permission(self, request, view):
return all((
request.method in permissions.SAFE_METHODS,
request.user,
request.user.groups.filter(name='ASCOM'),
request.user.groups.filter(name='Administrador')
))
Same code but I think this is a bit better way to do it than all the if elses
Actually
not the same code but
class Perm(BasePerm):
def has_permission(self, request, view):
return request.method in permissions.SAFE_METHODS or all((
request.user,
request.user.groups.filter(name='ASCOM'),
request.user.groups.filter(name='Administrador')
))```
Now 't 's the same I guess
hello guys, i'm looking for help . My problem is, when i click on delete, nothing happen
this is my view
def delete_row(request):
mydata = DataItem.objects.all()
if request.POST.get('submit'):
mydata.filter(id=request.POST.get(mydata)).delete()
return render(request, 'datahistoryrefreshed.html', {'mydata': mydata})
my html :
<tbody>
{% for item in mydata %}
<tr>
<form class="form-inline my-2 my-lg-0" method='POST' action="http://127.0.0.1:8000/blog/delete-row/">
<td class="text-primary"> {{ item.name }} </td>
<td class="text-dark"> {{ item.lastprice }} </td>
<td class="text-dark"> {{ item.sinceclose }} </td>
<td class="text-dark"> {{ item.sinceopen }} </td>
<td class="text-dark"> {{ item.isin }} </td>
<td class="text-dark">
{% csrf_token %}
<button class="btn btn-outline-secondary my-2 my-sm-0" type="submit">Delete</button></td>
</form>
</tr>
{% endfor %}
So I feel like I'm overthinking this and would like another opinion if someone out there is so inclined. I'm building a site with django (1.10) and trying to build a gallery app. I want the owner to be able to upload files only from the admin side to specific category folders, then I want those pictures displayed on the gallery template, split up by folder/category. I don't expect more than a few hundred pictures over time as it's intended to be a personal portfolio for an artist page.
I have looked at actual django apps, but considering the size, I think that may be overkill. If I think smaller, would that be as simple as using something like pathlib to pull the files and then adding the relative paths to context? It's weird, I've gone through a bootcamp, but they couldn't cover everything so I have all these not core things I've yet to learn that are tripping me up.
How to pass variable from jinja 2 to python?
can you explain your usecase
@deft lotus i suggest some changes , first you pass id into your html page and then get id in delete_view function and get this delete delete data by id ,
Try thid hope you delete item
@halcyon ridge ty for your answer, im new to django, how can i pass id through my html page ?
I can get this
print(DataItem.id)
<django.db.models.query_utils.DeferredAttribute object at 0x103cb7ef0>
@deft lotus DataItem.objects.get(id=id)
could somebody check my html code? i cant figure out where there is that space you see in the picture
i want to get rid of that space basicly
im probably missing something but i cant figure out
@deft lotus also you pass id into your html page like this <form action="{% url 'cart:cart_add' product.id %}" method="post"> you can make your action like this
from blog import views
urlpatterns = [
path('', lambda request: redirect('blog/', permanent=False)),
path('admin/', admin.site.urls),
#path('accounts/', include('django.contrib.auth.urls')),
path('blog/', TemplateView.as_view(template_name='home.html'), name='home'),
path('blog/templates/mydatahistory', views.get_data_db, name='mydatahistory'),
path('blog/templates/refreshquotes', views.refresh_quotes, name="datadbrefreshed"),
path('blog/delete-row/', views.delete_row),
path('blog/add-isin/', views.add_row),
path('blog/add-place/', views.add_row),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) # for the static files
`from blog import views
app_name='blog'
urlpatterns = [
path('', lambda request: redirect('blog/', permanent=False)),
path('admin/', admin.site.urls),
#path('accounts/', include('django.contrib.auth.urls')),
path('blog/', TemplateView.as_view(template_name='home.html'), name='home'),
path('blog/templates/mydatahistory', views.get_data_db, name='mydatahistory'),
path('blog/templates/refreshquotes', views.refresh_quotes, name="datadbrefreshed"),
path('blog/delete-row/', views.delete_row,name='delete_blog' ),
path('blog/add-isin/', views.add_row),
path('blog/add-place/', views.add_row),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) # for the static files`
Change your urls.py like this
ok
@deft lotus then you make form action like this <form action="{% url 'blog:delete_blog' item.id %} ">
path('blog/delete-row/', views.delete_row,name=' 'delete_blog), or ' delete_blog ' ?
ah ok
@deft lotus yes
no method = post ?
add all remaning
@deft lotus i give solution for this
@oak niche change in p tag style like this <p style="margin: 0;padding: 0;background-color: rgb(25,25,25);margin-top: 6px;padding-left: 40px;color:white;font: 18px/1.5 'Ubuntu', Arial, sans-serif;">lesson name here</p>
@halcyon ridge thank you so much! i actually asked this question on another server, and i tried to add margin-bottom:0 px and it worked. thank you again!
@oak niche ok welcome
So I feel like I'm overthinking this and would like another opinion if someone out there is so inclined. I'm building a site with django (1.10) and trying to build a gallery app. I want the owner to be able to upload files only from the admin side to specific category folders, then I want those pictures displayed on the gallery template, split up by folder/category. I don't expect more than a few hundred pictures over time as it's intended to be a personal portfolio for an artist's page.
I have looked at prebuilt django apps like photologue, which is cool, but I think that is probably overkill considering the size of my project. If I think smaller, would that be as simple as using something like pathlib to pull the files and then adding the relative paths to context in my views? I've already got the model with an ImageField and i'm importing the model into the admin panel via admins.py. Any opinions are welcome and appreciated!
how can i make ip lookup web application , I get all the ASN ip ranges, is it enough to build ip lookup application datasets
https://iptoasn.com/ is it enough to buid a IP look up application
Free IP address to ASN database
in a flask app, is there a better way to pass variables to an html file than piling them into the render_template('whatever.html', var1=1, var2=2) etc if you're using 20+ variables?
render_template('whatever.html', **context)```
also 20 variables sound a bit much, you probably can reduce it
not really, I'm printing sensor data and user-specified parameters
I'm just googling what you wrote, am I looking for flask context stacks?
not related to flask what I wrote
def view():
context = {
'var1': 1,
'var2':2
}
return render_template(template, **context)
it is just regular python unpacking
so basically writing a dict and passing it to render_template
can that dict be in a separate file, to keep routes.py cleaner?
Do all views share some of these variables?
no, just the one. it's a password-protected control page
I see
I mean you can always put that dictionary anywhere if it doesn't require the query parameters from the url
but I'd try to put it in the view
unless they are some constants
nah, it's all either sensor data or user-generated limits
my next step is to act on sensor data exceeding limits - without getting into js, is using a db the best way to store 'heaterstatus=on' or a similar toggled flag?
i mean if you want to store something per user I'd imagine yeah
fair enough. thanks for your help!
Anytime
hey, folks.
I'm a C++ dev, and am working on my heroku site. it's running python and i'm working on it locally. Going through the tutorials has me to this code snippet
def index(request):
r = requests.get('http://httpbin.org/status/418')
print(r.text)
return HttpResponse('<pre>' + r.text + '</pre>')
obviously, this is the code that's executed when I visit localhost://5000 and the browser requests index.html
I have some HTML that I need to be added to this page and I'm not sure how to set up the HttpResponse
ok lemme look
for this line:
return HttpResponse('<pre>' + r.text + '</pre>')
do I just put whatever html I want returned from the server in there?
as a concatenated string?
you wouldn't want to put your html as a string tho
That's why I showed render
but yeah response is basically that
What Python modules would be good for creating a web app that provides driving directions using Google/HERE apis
User goes to website. Types in Origin, Destination, and departure or arrival times. it will then provide a weather forecast along the route so you wont be hitting storms while driving
Would that be mostly frontend?
I think so. But I would like all requests to the APIs made by the server
so the auth key isn't exposed
Django seems to complicated for this task.
What do you mean by API route? Sorry im relatively new. And I just need to send requests to a weather service and directions api
My idea was to combine that information using leaflet
like /maps/routes
/directions/
Honestly got no idea how many are needed. I am just trying to grasp the concepts of doing this
Most of it will base on the maps api you want to use
is there a channel for finding a python dev for web backend?
@odd locust that's more of a question for #community-meta which is for questions about the server
Answer is no though, we don't allow advertising or recruitment in the server at this point in time, sorry.
ah. fiverr it is lol
i always say it is upsetting it these cases so that people who actually search for coders for hire can find me and pm me
but it never happens
how upsetting :(
@outer lynx there are a ton of other places that allow you to post or find job postings, and this is the wrong channel to continue this discussion as was already mentioned above.
haha fiver. for a backend
hi everyone - does anyone know if model methods automatically save in django models or do I have to manually call self.save()??
for example:
def subscribe(self):
self.subscription_status = 'subscribed'
self.save()
# versus:
def subscribe(self):
self.subscription_status = 'subscribed'
I'm assuming I have to self.save() since when you override a save() method in a model you always have to still call super(MyModel, self).save()
nevermind - I found it is required. thanks!
anyone know why /var/log/nginx/error.log would be "unwritable" according to nano and blank? raspbian stretch on a pi
nginx 1.10.3
def test_create_multiples_articles(self):
url = reverse('article-list')
created = datetime.now()
published_date = datetime.now()
expires = datetime.now()
data = {
'title': 'Titulo Teste',
'subtitle': 'Subtitulo Teste',
'created': created,
'published_date': published_date,
'expires': expires,
}
response = self.client.post(url, data, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertEqual(Article.objects.count(), 1)
for key in data.keys():
self.assertEqual(Article.objects.get().key, data[key])
Hey guys
any help?
the error is:
`
Traceback (most recent call last):
File "/www/fapitec/api/tests.py", line 85, in test_create_multiples_articles
self.assertEqual(Article.objects.get().key, data[key])
AttributeError: 'Article' object has no attribute 'key'
`
maybe a __getatribute__ ?
Hello everyone
I'm stuck with Django + Tailwind + PostCSS. Any good working example ?
Webpack is very obscure to me
Hey
Anyone know a good wordpress plugin for accordion menus?
I am trying to get them to look good so I can fit command boxes into them
I think this is more of a python web dev channel
Ah
I was trying to build a Django server , and I recently came across attacks like xss , (tried to try my hand at some hacking challenges and failed miserably), so I was wondering if there was any system in Django to prevent it
So uhh
If you use django.forms yes
On a form object you have to validate it. (form.is_validI())
This will create a new attribute on the form called clean_data
This cleaned_data is santized
On top of that the django templating systems has features for preventing rendering raw string unless it
is marked safe
While this does guarantee protection from XSS it does help a lor
You would have to spefically prorgam to allow for an XSS
but if plan to pass it as a json, I won't have that advantage ehh ?
Pass what in as json?
If you are using the django forms you should be good
as long as is_valid is called and data from cleaned_data is used
Are you just using django as json rest api
?
Yess
None of this matters then
XSS can only happen if your server is rendering html
At least from django's eye
As long as your frontend is locked down you should have a problem
No problem mang
(Well ,now to figure out those hacking challenges xD)
You doing a CTF?
Best of luck to you
Thanks
Quick question: looking to input data on one flask tab and process it on another
how would this be done?
Hi,
I have some script used for text recognition in pictures.
I want to make some apis or web application, that used that script.
So I will upload a zip with images, but i dont want to store this images on server i only want to process them and return result in json.
Do you know how to do it? Maybe you know some free servers? I think about heroku, but they only offer 500mb storage, so I can upload only ~250mb zip file
Hello, I'm following a flask tutorial, I'd like to know what would be the correct approach to handle the database being off (project wont start if it isnt on), I'm using flask_sqlalchemy
Is there a way to get missions info from https://api.stormshield.one/missions
Can anyone point me in the direction for how to print out the returned data from an HTTP request?
That depends on how you're making the request. Which module/package are you using?
@patent cobalt i don't even know where to start
i want to see what gets returned from the server when i connect to my site
@north swift what do you mean
try using postgres database somewhere from heroku, they give you free postgres db
i don't know where to start for opening http connections on the web in python @patent cobalt
You can use something like requests to make requests to your server and inspect what comes back
it's fairly easy to use, @odd locust
requests is really easy to use as well
I wrote a pretty simple thing to test our API endpoints
import json
import requests
auth_headers = {'Authorization': 'Token [removed]'}
site = "http://api.pythondiscord.local:8000/"
endpoint = "bot/nominations"
end = ""
r = requests.get(
f"{site}{endpoint}{end}",
data={'active': False},
headers=auth_headers
)
print(f"Status code: {r.status_code}")
print(json.dumps(r.json(), indent=4))
This just uses the json module for pretty printing, but I could have used other options for that
cool thanks
maybe a touch off-topic, but I want to run two nginx servers on two separate computers from behind a single router - how do I set up the right port forwarding for that?
(no flask experience)
i'm making an API with no frontend, I just need to know how to send data to a route and make that variable usable by a method in that route
@old ether what kind of data, and where is it coming from?
it's coming from a .net desktop application, it's a string @junior lintel
define the variable in the route def, and then include it in your render_template statement. i forget how to paste properly in here, I'll send you a message
Hi, coming from a JS background and starting to dive into python for a role in backend. Iโve learned python basics and bought a Django udemy course, but Iโm not sure what a good โ0 to job ready pathโ is like in python.
For JS it seems a bit easier for specifically front-end.
@vagrant adder My app uses data stored in a mysql database, but I cant run the app if mysql is offline, my question is how can I get the app running even if that's the case
Then first spin up your db, then your app
@velvet sluice i'm no experienced person in python, but in order to know how to do things you have to start somewhere, so make a small forum/blog type thing with user registration in order to get familiar with the structure of django, whenever I start using a framework/language, a user database is the first thing I do
function stream_write(elm, input) {
for(let i=0; i<input.length; i++) {
sleep(5000).then(()=> {
elm.value += input.charAt(i);
console.log(input.charAt(i));
}
)
}
}```
It writes the whole thing in one go
Instead of sleeping between letters
send help
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
};```
nvm
The CMD is set FLASK_APP=FILENAME then flask run --host=0.0.0.0 --port=1234
How to deploy flask applications in heroku, or anyother free hosting site please
Anyone have exp with flask/sse and session. I'm trying to send out a message via SSE to every client based on the permissions controlled and managed in flask_session
this is apropos of nothing, but in case anyone comes here and does what i did a few months ago and search for graphql hoping for something useful... after banging my head against a wall trying to get graphene to work correctly and in an otherwise fully async backend, I rewrote the entire thing in a few days using Ariadne: https://github.com/mirumee/ariadne
I'm using javascript to do a post to my flask app, is there any way to avoid the web client waiting for a response on a really long process?
does it need to know the response?
@north swift yes
yes?
none of my calls waits
cuz i dont need the fuckin response
and i know it got there, cuz that's how TCP works
actually... now that i look at it
i might just be plain wrong
actually I just added a one sec timeout and looks like its working fine
know is a wide term considering I'm asking this kind of stuff
why can't I pass session like this? https://pastebin.com/HVEtPJpP