#web-development
2 messages ยท Page 45 of 1
Just put the file into a temporary directory and show a download link
and redirect the user to it
that is the easiest method
Well, I love simplicity
I love making things work
I learned python, js, css html, etc
4 months ago
and now I am building websites every week
it is amazing
I know a bit of that
Haha ๐
If you look at my status, I've made that in ~2 hours
In summer I will try to participate into the coding contest here, I hope it is web related!
(using particles.js)
Hey any1 tell me how much estimate it take to run a django website of raw material related businesses any idea?
Do you mean how to make site, or how long for user to load site?
You can make a site pretty quickly. I think it depends on how well you know framework and the specific plan for site.
I just started with class based views. It's amazing how much it can build for you in just a few lines.
TBH, it makes me feel cheap, like its doing all the work haha
is anyone familiar with nadex? or binary options? im trying to figure out how i would go about finding the formula for figuring out the price of the contracts for each strike (without the data being live), previous price history doesnt exactly help
closest ive found is black scholes model (i think this is only for spreads though)
Anybody familiar with send_from_directory I am using it like that:
return send_from_directory(app.config['UPLOAD_FOLDER'], 'accounts.txt')
Both upload_folder and accounts.txt exist, I am not getting errors but the file doesnt get sent from the server to the client
Are you sure the client isn't receiving it in a form it doesnt expect? have you tried checking the network tab in chrome/ff to see what it actually receives
normally these errors are mimetypey stuff
I am aware that there should be some kind of receive function on the client-end but I am yet to find somewhere explaining how I should make it
well, receiving it should just be a normal request
have you tried making it in postman or similar?
You're just sending a .txt right? not a json?
If so, at some point you're trying to parse that .txt to a json
you probably need to fiddle with your fetch function to nor always parse to json
thats what you'd expect I assume?
Yea but I need it to download the file
I understand that the response says everything is okay
I wrote it
But I am not sure on what to do to initiate a client sided download when they click the appropriate button
are you getting the file via ajax?
fetchapi
it seems pretty janky, but apparently this is what you need to do https://stackoverflow.com/questions/4545311/download-a-file-by-jquery-ajax
yeah, the content-disposition is what I've used before actually
I forgot that was a thing
flask's send file has an as_attachment (or something) paramater that you can pass
You will still have to change your ajax function at least a bit
Hmm
I am using fetch not ajax
async function postData(url, data) {
count += 1;
if (!reached) {
const response = await fetch(url, {
method: 'POST',
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json'
},
redirect: 'follow',
referrerPolicy: 'no-referrer',
body: JSON.stringify(data)
});
return await response.json();
I was reading about fetch after our talk yesterday. I used it to grab some json. I need to read a book on JS. That's how I learn. I know some people say that's a waste of time but its not for me. Thoroughly reading books is how I got half decent with Python. If I want to be even close with JS, I have to do the same.
its mainly the HTTP stuff that I need to know better.
Not really, you will find learning js quite easy if you have a good knowledge of python
You dont use python in a browser to do http
WEll I mean
Lately I have been lol
But I dont have a lot of experience with that
You only learn smth when you really need it
True.
^^
Yeah, I get that.
@rustic pebble You are getting that error because the content is either not a json or the variable == null
I know
I am just not sure how to receive that object
I think I got it figured
fetch(url, options)
.then( res => res.blob() )
.then( blob => {
var file = window.URL.createObjectURL(blob);
window.location.assign(file);
});
I will use smth like that
what is a blob?
Yup
Ive never seen that syntax youre using above before but i sort of read it
JS has too many syntactic variations
arent you not supposed to use var anymore?
I dont remember why
let is better
mm
let is function scoped whereas var is global scoped
thats right
yup
So being a part of this greater community before I started focusing on webdev and came in here... I didn't realize that this might be an acceptable place to talk about JS. Is that generally frowned upon here? Or is it accepted as a part of web dev we can't ignore?
Right
I get that
I don't think anyone minds
Anyways do you think what I typed is okay? @tired root
@native tide
You can talk about it
fair
Don't ask me, I am inherently bad with JS
I am planning to get better at it and this community is the best programming community Im in
So... I'll probably be in here with JS problems eventually haha
Haha good, this community is good because the staff is active enough to be able to moderate it
For sure.
I have never even tried reading typescript
it makes things a bit better for me, because it is strongly typed and has a better syntax
It writes like js, but with a more strict typing and allows for oop in classes etc
And at the end, it is only generating js
I've used typescript compiler to get error messages out of my JS...
Hmm, I will give it a shot then. I really like js, it is very amusing when it works haha
But I have never looked into specifically TS syntax
Usually I add way way too much javascript to make everything as dynamic as possible
I am thinking of switching to desktop apps with electron or react
and python backend
be careful that your site still works when the user disables js
That might be interesting. The main reason I decided to make web apps is because I want to make things that people will look at eventually, particularly people who are not programmers.
It just made sense
Who disables javascript? omg
Why tho
A lot of people disable javascript
Because its often manipulative and shitty
Because it can be dangerous
For example, some people disable back in history with js
not allowing you to leave their site
I usually have dynamic elements that are loaded from querying my database through the server
That is an instant blacklist for me
So if people disable js they wont be able to view core functions of the website
That is bad design
Yep. Thats why if you want people to use your site you should use noscript lines
For example say I have a count saying Total Users this means it will send a request on my flask server the flask server will do the calcs and display it to the user
using js
If they disable it its just going to be empty
Sites are moving towards not supporting people who block JavaScript more and more but the reason why is that...
ok barely lol
They are not able to profit in the manipulative ways that they do otherwise
my opinion is F em
How is it manipulative using dynamic elements
Wow you really have got javascript wrong..
There is nothing innately wrong with it. It can be used in a shitty way or in not.
Everything can be used in ashitty way
What is the point of having backend support at all then since the server can see your IP
Yeah, and I exercise control over what I run on my computer to deal wioth that.
Thats why I dont let any webstie I visit execute JavaScript at their whim
Hmm
I dont disable js because I am not really visiting many websites except of stackoverflow, reddit, discord and facebook
And I have a mac for daily use which means I have added security on some parts
Its not dynamic animations and interactivity I have a problem with
Its following me across the internet
Its a personal choice
I dont think everyone has to do what I do.
But you should keep in mind that
there are a lot of people who block JS by default
thats why people use noscript lines
Blocking js is like getting a car and disabling all electronic devices
I have noscript/mock lines in all my websites
but it just doesnt look that nice
I am getting back to python now, thanks for the chat
That's exactly what I do in a car lol.
Nah, jk
But I dont care for smart devices or anything like that.
Basically though, as the type of user I am talking about...
If you have a site the relies on interactivity because its more like a game or something.
You can use noscript lines to tell a user like me what your site is about
And I will very likely whitelist you.
And check you out.
But by defualt
I prefer not to
I have 0 sympathy for people disabling JS - if you're worried about being tracked, block it in more effective ways
honestly I just see it as pretty dumb
most of the modern internet relies on JS heavily - and thats fine
It does and it is tedious. But... when you use the same website fairly frequently.
Eventually you have listed the ones you want to allow JS from.
And its not a big deal
I dont know why people insist on condescending to people for their choices really.
It would be different if I was in here waging a campaign of, "You guys all need to block JS today."
But Im not. I know that what I do is fringe.
And if you don't want to accomodate me thats fine
I see it as akin to someone putting crystals all over their house for the healing power - you can do it, it doesn't harm me, but I still think its silly
Well blocking js is blocking the biggest part of a webapp
Like I have spent around 3 days now building the js relay
If someone were to disable it they would just be dumb asf
I agree with you about the crystals.
I'm not paranoid or anything. I just like to pay attention to what's going on.
Like I said, after look at what your page is, I'd likely whitelist it if there was no sign of something I dont like.
There are often things I dont like in my browser as a result of JS
If you think Im dumb af for changing things I dont like for my purposes....
then fine.
Its an unnecessary amount of "You're stupid" that gets thrown around for things like this.
I almost dont even like to talk about it because of it.
I try to be as, "This is just what I do, I understand that there is no need for you to do this, you dont care about this, that's fine"
No effect
People are equally assholes to me about it.
@native tide When you start spending hours trying to get something to work you will start appreciating javascript, developers spend days trying to create an optimal and secure client-server connection and people who disable js are just straight up shitting on their face
stop crying
right
If they visit my website then it is their choice to use it
I have things to do today.
Like it is contradicting, why visit a website where you only want to view a part of it?
๐คทโโ๏ธ

Has anyone received "WSGI script cannot be loaded as Python module" and "ModuleNotFoundError: No module named 'project'" before? Running Django with apache2 on Ubuntu 18.04. I have spent 8 hours trying to solve this without any luck. Willing to offer a token of appreciation through PayPal if anyone could help me fix this. Worked just fine before a new deployment and sudo apt-get update. Logs: https://stackoverflow.com/questions/60573638/django-wsgi-script-cannot-be-loaded-as-python-module
have you checked the status of selinux?
just type getsebool and it tells you
@marsh ginkgo
Hi again @tired root, as you can tell my wipe of the server as mentioned in DM didn't work ๐
getseebool returns "Command 'getsebool' not found
I will install it
Then I won't ๐
I see
It's basically something like Windows security policies for Linux
WSGIScriptAlias / /var/www/project/myapp/wsgi.py
Yesterday you said it is in /var/www/project/project
Ehm, let me check here. Modified the names just for Stackoverflow lol
yeah, in the logs it also says project/project
Sorry, that was incorrect when I changed the name for stackoverflow. I am indeed using the right one. /var/www/project/projec/wsgi.py
What do you mean by group?
nvm I thought it is something else
but in your WSGIDaemonProcess you don't specify a user. I wonder if it runs with the www-data group by default then
Good point, I will try specifying a user
Well, don't if you don't have to
I am not quite sure
I don't configure apache that often
Worth a try, but Apache didnt like it
Well, the whole process runs as that user then
with the group
I just did it for added security
If this option is not supplied the daemon processes will be run as the same user that Apache would run child processes, as defined by the User directive, and it is not necessary to set this to the Apache user yourself.
so if the the directories are owned by www-data or however the user is called on Ubuntu it is fine
Stupid questions perhaps, but any easy command to see that?
can you check the apache logs?
I used whoami but not sure if that is correct
To see if the directories are owned by www-data
Same error message as in the url above ๐ฆ
nvm I am stupid, that was that log ๐
I mean, I can find a lot of threads about it
Really appreciate it
but no solution
yeah same here...
go to the directory, enable venv
where your project is
then just type import django
I am not using a venv
oh
I tried to before, but thought it was easier to just go global on this VPS
I think it would be better to create one and give apache the rights to it
you can create a venv in the same directory as the project
This is how I do it:
import sys
activate_this = "/home/wsgi/.local/share/virtualenvs/radio/bin/activate_this.py"
exec(open(activate_this).read(), dict(__file__=activate_this))
sys.path.insert(0, '/var/www/html/radio')
from backend import backend```
Maybe try to use nginx
But I run apache for python with a different user
@marsh ginkgo a quick test would be to enable www-data for login, create a proper home, su - www-data, install the files with pip and see what happens.
If you have installed the packages as root, the child process of apache can propably not read them
that is why a different user with a venv would be better
Or only a different user for the wsgi process
install the packages as said user
Aah I see, I Installed everything with sudo
But, weird thing still is that it WORKED before an deployment and an sudo apt-get update...
https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html look for user=name and group=name
WSGIDaemonProcess backend.wsgi user=wsgi group=users threads=1
example
I have been checking some different django applications and I am seeing two different conventions for including an app in the django project.
some add blog.apps.BlogConfig others add blog to INSTALLED_APPS in settings.py.
Can someone explain to me what the different is, and if there is a preferred method?
Does anybody have experience with this?
Dont know if this is the place but
payload = {
"embeds": [{
"title": "Title"}]}
headers = {
'Content-Type': 'application/json'
}
requests.post(url = "[redacted]", data = payload, headers = headers)
``` im trying to post this to webhook, does anyone know why its not sending
if this isn't the place point me to the channel
this is for discord?
yea
go on #discord-bots
its not discord.py
What is it then?
First of all as a url I can see you are sending the string ['redacted']
URL is for sure 100% wrong
The rest should be fine, I have no experience with discord webhook though but this doesnt seem any different from normal requests on python
https://ptb.discordapp.com/api/webhooks/{channelid}/{webhookpassword}
this is what im passing
for url
not really
what you are passing is this: "[redacted]"
Does anyone know how to get over this:
has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
yeah, you need to do a proper cors request
Apparently, I have completely misunderstood its semantics. I thought of something like this:
A client downloads javascript code MyCode.js from http://siteA - the origin.
The response header of MyC...
I am doing this:
def filesendhandler():
file_for_sending = send_file("./uploads/accounts.txt", mimetype='text/plain', as_attachment=True, conditional=False)
file_for_sending.headers['x-suggested-filename'] = "accounts.txt"
file_for_sending.headers.add('Access-Control-Allow-Origin', '*')
return file_for_sending
But this doesnt seem to be working properly
I have also added it as headers on my client side request
let response = await axios.get('/textaccsrequest', {headers: {'Access-Control-Allow-Origin': '*'}});
It would be nice to support CORS [1][2] even static files need to support it [1] http://www.w3.org/TR/cors/ [2] http://enable-cors.org/
Hmm
Question: What should I add between these: ...
app = CORSMiddleware(make_app(...), "http://example.org/")
I know that I'm gonna be in here trying to fix problems withs cors sooner or later. In fact I already know the problem with cors that is waiting for me. I'd love to know what to do about it, personally haha
Well tbh there is a plugin called flask_cors
And you can wrap your app in cors using CORS(app) but for me it doesnt work this time
:/
I have written a script to receive, transcode and send the files to user on js
And it needs cors to work correctly
I'm getting to learning Django's "generic" class based views, which seem a lot simpler and are easy to write and save you a lot of work. But as soon as you want to customize them, it basically a lot of... writing over a parent method or attribute somewhere that you have to look up.
class PostUpdateView(LoginRequiredMixin, UserPassesTestMixin, UpdateView):
model = Post
fields = ['title', 'content']
# write over the parent form_valid method
def form_valid(self, form):
# the form you are submitting takes the instance and sets the author to the current logged in user
form.instance.author = self.request.user
# run the parent form validation with the adjusted form passed in
return super().form_valid(form)
def test_func(self):
# gets current post object -- checks if logged in user is author
post = self.get_object()
# logged in user in request checked against post's author
if self.request.user == post.author:
return True
return False
Obviously its going to save a lot of work for views that involve saving, updating, deleting, listing, etc. Typical posting type stuff.
But I'm not sure I like how much its just a lot of inheriting this and writing over methods that a lot of times its confusing to understand what they are even doing. Thats why Im commenting every line for now until I understand it.
Thats just an example not a question
Ive never heard the word "Mixin" until now
what exactly do you mean? @native tide
well
assuming you want your css to be applied to your HTML
then the user needs to have access to the CSS so its not really possible no
I'm also not sure why you'd want to do that
Its possible in basically every platform
there is no platform
that lets you not have public css
whilst applying said css to html
thats just not the way css works
maybe you mean apps like electron?
If CSS is being applied, then the CSS file has been requested by the client
then the client applies the css rules to the HTML
๐
So theres no way possible at all?
There is no way at all.
Btw
I have a base template in Django for pretty much every page on the site. I would like to have a conditional in that template that is something like {% if <the current page is url named 'this-page' in conf> %}
But I dont know how to say that in DTE
Basically like, I want to have something included in the base page template but only if current url is one of these urls
There might be another way to do what i want to do... But I thought there would be some syntax for this. But i cant find it
nevermind I figured it out. I will have a block that is overridden on the pages I want the content to be different
@native tide nope, even on desktop wrappers like electron or react you cant do it, because it is running a chromium browser on the background. Even on discord you can view the css
๐
0 need to be a dick
??
Hrmm ??
Did I do something wrong?
@native tide I am sorry but I have no knowledge over django
No worries, I figured it out. In Django (and also in Jinja, which it is based on) you have blocks of content that you have on a base page. And you can over ride them on more specific pages. So for example, if you want something to only appear on certain pages, you have the content block be empty on the base template. Then you over ride in the child template. Its weird, but its accomplished the same thing as "if this url is the active url: load this"
Does Flask have a templating engine?
I know nothing about Flask.
ah. They call it DTE in Django and I dont know why. I think they started with Jinja and modified it over time and called the fork DTE
Its basically the same
as far as i can tell
Well not sure, but I dont really use the engines I parse everything using js
right, right. I learned to use the templates because of static page generators like pelican.
I like their effect, although I admit the syntax makes html look a little ehhhh
But its okay. It works
I prefer my html to be cleam
Well, so do I. And I do my best.
I use a seperate js file for each html file I have
say I have the following
file1.html
file2.html
file3.html
I will also have
file1.js
file2.js
file3.js
I definitely separate js from html unless I am just messing around and not sure I will use something yet. It would be nice if the templating engine was not so... directly a part of the HTML. But it is. Its effect is worth it looking weird. And I magine I will get used to it.
The same way I gotr used to every tag having a million bootstrap classes
I am so bad at frontend anyways
So that is why I seperate it because I really despise
reading html
I am a backend developer my styling abilities are very narrow
But I am still way better than some frontend devs smh
Bootstrap is my savior tbh
You're not the only person haha. I have only made one design with CSS that was fully responsive that I was proud of. But it was simple. Its was just... elegant. But bootstrap saves the trouble of focusing on frontend if youre not great at it.
well my latest website although it is barely legal in the context of this server
it has very good design
https://virufac.github.io/ -- that is my non bootstrap static page. I have not updated it since I made it. lol. but its nice for being done without help. I mean, I wouldnt use it to sell a product. But its pretty enough.
Personal Website of Shรฆnแฑ, aka viruFac aka...
Like it is very responsive and has many dynamic elements inside it
Gotcha
Adjusting the css took me way too much time compared to what it took me to create a very secure login/logout system
Yeah, that is the trouble with frontend. It's a lot of moving things back and forth and being like, "No that's not just right, no that's not just right."
And it takes forever.
Yup
But tbh I have chosen a very poor backend architecture as well, I started the project when I was in a plane and I didnt rly think about it
But to be fair
before I knew it in around 6 hours I had written a very solid base
And I was way too bored to change it
I would have no idea how to make a login secure without this framework I use
whereas I can make CSS if I have to.
ITs just tedious
I am not using any of flask's auth framework
frameworks*
I always emphasize on security and I make sure I have the best and fastest modules. I usually use JWT infused cookies to create sessions and I hash passwords with a private key and in order for the user to login I just check the hash I never dehash it using a public key
So every password is stored hashed on my db, and the cookies the client has are also signed meaning that no one can access their contents without both of the keys I have
This how users are saved on my db for example
The ... you see at the end continue for around 150 chars
And this is a cookie containing info like client's username, first name, day joined, etc
But never passwords
Yeah that is the kind of thing that I Django does for me and I dont know how to do any of myself.
I could learn. I mean, I know how to create a hash. So I theoretically could do it.
But it would be an entire thing I had to learn first before I could do this if not for Django is what I mean.
And I admin that it does make me feel cheap, like Im skipping a lot of work that I should know how to do on my own.
But... I also have only been programming for a year so.
Ive come pretty far.
Yeah.
You should look at Django.
Its amazing lol
I will eventually check Flask out. Ive been told it has as use case where it might be better.
I cant comment really on things i dont know though
No, you can change it any way you want to.
idk
Im not trying to sell you anything. You can literally do whatever you want to do.
Yeah chill mate haha
I really want to look on electron as my next project wrapper
And have flask backend
Thats cool. I wouldnt make up your mind about Django though until youve seen it.
You can change everything about that admin page.
It just happens to come with a lot of tedious things done for you.
I literally reinvent the wheel with every app I make so I donโt find what django provides particularly fitting for my developer style
I am going on a trip tmrow
Right.
Ill have a look at it while I am travelling
Its entire design philsophy is to never do that.
I will say that a lot of times building with it feels like
Yea I got that haha
"Okay where is the thing in the documentation I need to write over to change this."
Flaks is almost starting from zero
Yea I gotcha
Its constantly writing over a function that already exists
yeah
I will have to check Flask.
I can see the appeal of that
Like djangoโs literal slogan is โA framework for perfectionistsโ
Meaning it has everything set up for you
You just need to connect the parts
Whereas flask is almost entirely different
perfectionist with deadlines lol
I've got a headnut for your two
{% for key, value in skills.items() %}
<input class="accordion-checkbox" type="checkbox" id="{{key}}" />
<label class="accordion-label background-silver" for="{{key}}">
<r-grid>
<r-cell class="left-1em text-bold">{{key}}</r-cell>
<r-cell class="text-right text-bold">group SP</r-cell>
<r-cell class="text-right text-bold">{{len(skills[key])}}</r-cell>
</r-grid>
</label>
<div class="accordion-content">
{% for skill in each %}
<div class="accordion-item">
<p class="left-1em">
<strong>{{skill["name"]}}</strong> (Rank X)
<span class="accordion-level-square">
{% set empty_squares = 5 - skill["trained_skill_level"] %}
{% for n in range(skill["trained_skill_level"]) %}
<i class="fas fa-square"></i>
{% endfor %}
{% for e in range(empty_squares) %}
<i class="far fa-square"></i>
{% endfor %}
</span>
</p>
</div>
{% endfor %}
</div>
{% endfor %}```
But yeah... You can still build on to it.
This is the jinja template
yea smthing like that
Wow thats cool, are you working a web game too?
Everything that is under {% for skill in each %} ends in the html outside of accordion-content
yes
but why?
the for comes after the <div>
I can see that
I have never used r-grid or r-cell, does it work like table, tr, and td?
oh its an input
it's a custom tag for grids
this is how I make tables
var table = document.getElementById('responsetable');
for (var i = 1; i <= data['accnumber']; i++) {
let tr = document.createElement('tr');
let td1 = document.createElement('td');
let td2 = document.createElement('td');
let td3 = document.createElement('td');
let text1 = document.createTextNode(data['account' + i]['server']);
let text2 = document.createTextNode(data['account' + i]['username']);
let text3 = document.createTextNode(data['account' + i]['password']);
td1.appendChild(text1);
td2.appendChild(text2);
td3.appendChild(text3);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
table.appendChild(tr);
hmm
Yeah. I havent used a table since I was in high school tbh.
What is the problem exactly?
Have you tried switching the {% for key, value in skills.items() %} from the start to right before div class="accordion-content">
@native tide That the <div class="accordion-content"> comes after the for loop
and is empty
ohh ok
everything from the for loop is supposed to be inside that div
Hmm
<input class="accordion-checkbox" type="checkbox" id="{{key}}" />
<label class="accordion-label background-silver" for="{{key}}">
<r-grid>
<r-cell class="left-1em text-bold">{{key}}</r-cell>
<r-cell class="text-right text-bold">group SP</r-cell>
<r-cell class="text-right text-bold">{{len(skills[key])}}</r-cell>
</r-grid>
</label>
{% for key, value in skills.items() %}
<div class="accordion-content">
{% for skill in each %}
<div class="accordion-item">
<p class="left-1em">
<strong>{{skill["name"]}}</strong> (Rank X)
<span class="accordion-level-square">
{% set empty_squares = 5 - skill["trained_skill_level"] %}
{% for n in range(skill["trained_skill_level"]) %}
<i class="fas fa-square"></i>
{% endfor %}
{% for e in range(empty_squares) %}
<i class="far fa-square"></i>
{% endfor %}
</span>
</p>
</div>
{% endfor %}
</div>
{% endfor %}
This wouldnt work right?
no
damn it
Its a dict of dicts and the values are needed on the top
Sure
please no wild guessing around, I am looking for a real answer
Yeah I don't think I can give you one, I am really not sure how jinja works, I always use js for that shit
So... the only thing that I have to say is that
in DTE you dont put () at the end of your methods in templates
Is that the same?
In whatever you are using
like...
You just omit () in templates in Django
Every one I have seen does that
This one I pressume?
{% for skill in each %}
<div class="accordion-item">
<p class="left-1em">
<strong>{{skill["name"]}}</strong> (Rank X)
<span class="accordion-level-square">
{% set empty_squares = 5 - skill["trained_skill_level"] %}
{% for n in range(skill["trained_skill_level"]) %}
<i class="fas fa-square"></i>
{% endfor %}
{% for e in range(empty_squares) %}
<i class="far fa-square"></i>
{% endfor %}
</span>
</p>
</div>
{% endfor %}
yes
and that content ends outside the div the loop is in
and that just boggles my mind
Can you send a pic of how the content looks when it gets rendered?
Damn frontend dude, we are 3 people here trying to solve something really easy I am sure
I am sorry, I don't know if it is something I am missing but I can't find anything wrong with what you have written. I hope I don't face the same problem sooner or later
Because that really makes you rethink the whole logic of that when it could be one tiny detail
I'm trying to find wherever I read that you're not supposed to put () on your method calls in a template syntax. But I cant find it.
what ()?
Im not sure if that would help you but its the only idea I have. You might try it
there are no functions here
no that is how it works in jinja
mm
also, if that wouldn't work, there would be no output
because it is the parent loop
console is for js
there is no js
Well, it was the only idea I had because Django has me omit them. Unless Im crazy. Good luck fixing it. I'll look out for the answer
Assuming your problem is still this https://discordapp.com/channels/267624335836053506/366673702533988363/685996454976028709 then I'm pretty confident the problem is elsewhere in your template. If you're 100% sure its in here, I'd suggest stripping away as much of the HTML as possible to try and debug it
go back to just divs and ps, then colour the different levels with css
pycharm has pretty good jinja support and tells me when there are unclosed tags, even for parent templates.
but I try
is it possible that you can just share the entire template via paste.pydis.com?
hold on
What's the problem ?
link above should take you back to it
Yea I clicked but all I see is html, no question
Scorcher's next few messages explain
k
The screencap shows it.
I'm interested in the answer but I only just started using these templates.
So, to be sure I understand it, everrything is present in the generated html but is outside of the accordion-content div, right ?
I've solved that, not sure how, but I did. Apparently jinja does some weird things when there is an error in your for loop
but anyway, it is a dict of dicts
first loop: {% for key, value in skills.items() %}
so, value should be the second dict, right?
for each in loop
wat
in which case, it should be for skill in value
I assumed each was being injected into the template as well
like separately
okay, so if pretty print my loop variable, it shows this: ('name', 'Science')
and all the other keys
but when I do skill["name"] it's not showing up
(also I still don't know what each is, I'm looking at jinja2's doc and I don't see it as a loop keyword, and if it was shouldn't it be loop.each ?)
At this point I'll take Charlie's suggestions for the whole template code ^^'
okay I am stupid
I had rewritten basically the whole project,used the old template, but didn't think
I only need one loop
Sorry for interrupting, does anyone know how to change the input field's background color?
input[type=text]{
background-color: red;
}```
@bleak bobcat @rigid laurel Thanks for trying to help though. Appreciate it
@rustic pebble You wanted to know how it looks
no js ๐
css not jinja
even worse for me haha
cool
clicking the "label", that is where the arrow on the right is, changes it's children from display: none to block
Well the whole silver bar is the label
disadvantage: you cannot animate from none to block and vice-versa in css
with keyframes
https://jsfiddle.net/sop0fwdh/ @rustic pebble @native tide made you a fiddle with the basic code
it's missing some formatting, but the principle should be clear
Thank you.
I feel like you are torturing yourself haha
Go into .accordion-checkbox and set the display to block
then the magic becomes clear
I am a fan of CSS checkboxes.
This is cool. I am planning a game that I am not as far along in as you. So I'll show you my stuff if i ever get around to having anything worth showing lol. Right now Im still drawing out my database and trying to make sure its perfect while I finish touching up this blog app. But this blog app is really only intended to teach me as many Django basics as possible. I ultimately want to make a web based RPG.
that is good
Have a look at this, if you don't want to use bootstrap: https://rsms.me/raster/
It is a small and light weight raster library
it's really awesome once you get the hang of it
And makes your site ready for mobile
I noticed it and wsa going to look at it later actually.
it was the first thing i noticed ha
I dont dislike bootstrap
But the web has become
There is where the <r-grid> tags come from
It's too big to upload here, but have a look at this screen from my twitter:
https://twitter.com/GothSeiDank/status/1236304340211642369
didn't have to change anything
just works
Can someone help me translate this into js?
/^[a-zA-Z ]+$/
Cool.
Basically what I want is to check a field if the characters from the field are inside this /^[a-zA-Z ]+$/
Nvm I figured it
let regname = /^[a-zA-Z ]+$/; xd
Actually
That grid system looks really good for laying out RPG like stats and info.
And Im noticing that no matter how i zoom on that page
Nothing seems to change
Is that mobile friendly? Im not on a phone
yes
there are different modifiers
so, say you have 3 columns next to each other
<r-grid columns=3>
would have 3 columns in all size
<r-grid columns=3 columns-l=5 columns-s=1>
3 on medium, 5 on large and 1 on small screens
like phones
in portrait mode
They set out to make a grid system perfect for character sheets
can't delete the preview :/
Im definitely going to use this at least for that if not also with oth css
has 2 screens, one nomrla and one for phone
just need to make a button for the menu from the 2nd screen
so it can slide in
on the phone version
my-tag{
}```
Right right
I actually dont have any ideas worth doing with it.
I was just curious
@tired root You making a game?
no
oki :/
I am making a character planner for Eve Online, using their api endpoint to pull the data @rustic pebble
Gotcha thanks for the info! I was thinking of doing the same for league of legends but I got too bored doing the frontend :/
Has anyone implemented Paypal into a Django project? I have a basic buyer/seller setup, but I'm confused on how to implement a commission to the website as well as how to capture the successful transaction data that is sent back from Paypal. It is successful, but I'm not sure how to control/implement these two things on the server side.
Probably the same idea, sure.
I can send you the code block of how it works, I cant explain rn tho
I am leaving soon
Would love to take a look
This has a lot that is unnecessary for you but its for you to tie things together
Take a look on createuserfromregister
This is the core function
โ/atโ
Is to get the access token
/price is the function that fetched the frontend with the prices
So people cant edit the element out
@dense slate
Basically I have a register form, the user fills the inputs and then clicks on the paypal button
After he pays and if the payment was successful they get registered on my db
Let me send you the front end part as well
anyone know how i could level these boxes
* {
box-sizing: border-box;
}
/* Float four columns side by side */
.column {
float: left;
width: 25%;
padding: 0 10px;
height: 300px;
}
/* Remove extra left and right margins, due to padding */
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive columns */
@media screen and (max-width: 600px) {
.column {
width: 100%;
display: block;
margin-bottom: 20px;
}
}
/* Style the counter cards */
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
padding: 16px;
text-align: center;
background-color: transparent;
}
css im using
Potentially obvious question on flask/jinja2: How to import a block of code from another template, but not the whole template? Feel like I'm not doing this correctly:
I've a standalone sub_template.html that looks like:
{% extends "layout.html" %}
{% endif %}
{% block content %}
...
{% endblock content %}```
I only want the block content stuff included in another page, index.html:
```{% extends "layout.html" %}
{% block content %}
...
{% include 'sub_template.html' %}
{% endblock content %}```
But because index.html already extends layout.html, if I import the whole sub_template.html I'd be double extending layout.html - hence the if statement that checks current url in sub_template.html.
Any less ugly ways of doing this?
my hunch is: you factor out the to-be-imported stuff into its own file, and import it in all places that need it
I think I've done this exactly once
it was surprisingly non-obvious ๐
ah yeah, I tried doing that too but preferred the messy if statement over having an additional html file cluttering my templates folder. since jinja2 brags about reusability I figured there's a super obvious way of doing this
Sorry, but you may only use this command within #bot-commands.
How would one go about connecting multiple raspberry Pi's a django based website
simply; why
@lilac root you can use docker => Kubernetes
@restive kindle I'm trying to collect data from multiple raspberry Pi's and then display them on something like a dashboard
@rustic pebble is it possible for me to write a python script on the pi and make it send post requirests to the server
Like their temperature and stuff or collecting data from external source.
@restive kindle GPS data
use database + websockets/post requests
Like the server query the rpi-s individually?
It depends if they move around a lot / are they in distance of the server. Judging by the fact that you are collecting GPS data i'd probably have the rpis send data to the server.
Yeah it is possible
But you would have to run the script on all the pis you have
Basically it will be something in the lines of:
import requests
import time
url=โmyserverurlโ
print(โStats have startedโ)
while True:
try:
response = requests.post(url=url,data=data)
except:
continue
And data is your pi data
Which you can get from a module
@lilac root
If you want to make them an API then you have to create an internal server on one of the apis which you then make requests
It is not that hard to set up actually
Quite easy I must say
So I would have a server to which all the pis would send the data to, and then use the main server to request the data
The thing is the rpis are just for testing, I was thinking of using Arduino for the property deployment
You can do it however you want
Id rather have a network of pis connecting to a local server and then request to that local server rather than having each different pi
Makes it easier to manage and scaleable
@rustic pebble so each pi will talk to a local server, then the main server would make requests to the local server ?, Sorry for reiterating, I just want to know if I got your idea
Yup
Exactly that
Think of the local api server as a forwarding server
@lilac root
Alright thanks a lot @rustic pebble
Np
In my django wepage I want to pass Json data to Javascript, which method is better (or if there is a better way):
1- add the Json data in the Django template, and read it in javascript by searching the DOM.
2- request the data using an Ajax request
The former saves requests and thereby load time if its dependent on the loading of the page. However I prefer the latter as it gives the backend lang and the frontend independence from eachother.
This was what I was talking about the other day when I said it seemed strange you had () in your code @tired root -- just so you know Im not crazy ๐
I believe you
๐
It disturbs me a little bit to think that DTE is that different from jinja. It looks so similar.
Hey I'm building an app in Django and I have a question. I have a Abstract Model with common fields and methods. How do I access the child model in the parent class?
@stark yarrow I'm not sure if this answers what you're asking, but you can do something like :
ParentClass(models.Model):
ChildClass(ParentsClass):
and that inherits all the parent fields.
If you are creating two models inheriting from the models.Models class and you want the second to be related from the first use ForeignKey, if you want to declare two models inherit from the models.Models class do what Damian mentioned.
I've done this
Building a Reddit clone.
class Post and Comment inherit from Votable.
In the Votable methods I check for the type and do something based on the type
My only issue is with the class Vote.
class Vote(models.Model):
UPVOTE = "UPVOTE"
DOWNVOTE = "DOWNVOTE"
UNVOTE = "UNVOTE"
VOTE_STATUS_CHOICES = ((UPVOTE, "Upvoted"), (DOWNVOTE, "Downvoted"), (UNVOTE, "Unvoted"))
user = models.ForeignKey(UserProfile, on_delete=models.CASCADE, verbose_name="Usuรกrio")
status = models.CharField(max_length=10, choices=VOTE_STATUS_CHOICES, verbose_name="Estado")
post = models.ForeignKey(Post, null=True, on_delete=models.CASCADE)
comment = models.ForeignKey(Comment, null=True, on_delete=models.CASCADE)
I don't want to use ContentType, so I declared both fields and set them to nullable
Or should I use ContentType? I feel like it's too messy
def get_vote_object(self, user: UserProfile):
qs = Vote.objects
if type(self) is Post:
qs = qs.get(post=self, user=user)
elif type(self) is Comment:
qs = qs.get(comment=self, user=user)
return qs
The problem with the way I'm doing this is that I have to type check everytime I use the Votable class.
Yo
@polar nova python on godaddy is probably not your best choice. I tried previously to no avail and since moved away from godaddy. I was using shared hosting so I'm pretty sure you have a lot more control in a vps.
hello @rustic pebble
I've used GCP for a couple of django sites.
Can you get custom dom
i believe it's relatively easy to deploy to digital ocean, pythonanywhere and heroku as well.
yeah, of course.
Yes i think si
you just have to pay for it ๐
what are you building?
A web site for my electro mobile team
nice. i'm not sure I know what that is. what framework did you use?
Django
Awesome.
Yes
is it ready for primetime?
i've use a VPs (google compute engine) and the sAAs (app engine) and found the latter to be far easier to maintain.
I have a question. About frontend, i know js and jquery basics. But now, i want to choose one tecnology, and learn it well. I've done a quick search on google, it seems that most popular tecnologies are jquery, react and angular. Which one should i learn? Which one is the most used and demanded?
It depends on what you want to do
jquery is very convenient for controlling dom elements, react is very good at creating sleek UIs, angular is kind of the both
I would suggest to also check out electron
I'd suggest that React is the most useful of those
Its pretty nice for a JS framework (I much prefer it to jquery), its quite in demand in terms of jobs, and there's only one real version of it unlike Angular
PS: I suck with css, but I am comfortable with bootstrap. So, since I use bootstrap, my works are not custom, but always with the usual bootstrap components.
I forgot to tell you this
I say this because you say that react is used more for sleek UIs
The sleekness of React UIs is less about them looking pretty - you're still relying on HTML/CSS for that - but about how easy it is to make things responsive
as in responding to data and input
I have a question about getting a gmail account setup to validate accounts and do password resets. I made a new email and tried to go set up an app password but I get
Does this have to do with the newness of the account or... have they discontinued this feature for common accounts?
I'm following a guide that says its as easy as setting this up.
ah, its a feature that only exists if you have 2FA on.
Which I definite would if I was in production. In fact, I'd feel kind of unpressional using a gmail account if I was, too.
But this is just testing
@native tide That feature was entirely scrapped
You have to use OAuth2 to get permissions: https://developers.google.com/identity/protocols/OAuth2
Ahh, okay.
I'll have to look at that but Ive been sort of stopped by another problem
I have a problem on my "staging server" that I dont have on my dev server.
Exception Value: Reverse for 'user-posts' not found. 'user-posts' is not a valid view function or pattern name.
it is though
blog/views.py
class UserPostListView(ListView):
model = Post
template_name = "blog/user_posts.html"
context_object_name = "posts"
paginate_by = 5
def get_queryset(self):
user = get_object_or_404(User, username=self.kwargs.get('username'))
return Post.objects.filter(author=user).order_by('-date_posted')
blog/urls.py
urlpatterns = [
path('', PostListView.as_view(), name='blog-home'),
path('user/<str:username>/', UserPostListView.as_view(), name='user-posts'),
]
there's a template at blog/templates/blog/user_posts.html
I guess I'm going to try searching for every occurance of user-posts in all my files and see if something weird is somewhere but...
The crown wtf is working on one server and not the other.
Every route works that ive checked except for root. /
Which is weird because the home view has nothing to do with that class or that template
I am such an idiot
I've been on the test server so long I forgot I needed to restart gunicorn on the "staging server"
:shame:
okay, lets figure this OAuth thing out.
What do you use for mail validation ?
Not sure yet. Im learning to do it.
Oh
https://www.youtube.com/watch?v=-tyBEsHSv7w&list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p&index=12
This is the guide im following. This is password recovery though. I figured if I can get one set up the other shouldnt be too hard
In this Python Django Tutorial, we will be learning how we can use email to send a password reset link to a user so that the user can reset their password. Users will be able to fill out a form with their email and have a unique token sent to them, and if their token is verifi...
Oh sorry not a django guy i just know if u are going to use google smpt
If an app or site doesnโt meet our security standards, Google might block anyone whoโs trying to sign in to your account from it. Less secure apps can make it easier for hackers to get in to your
Good luck either way
Yeah, I have to admit that turning that option on doesnt make me feel great or anything. Im pretty sure Id never do that in production. But im no where close to production anyway so..
In general u dont do that in production if u are going to handle some amount of mails like welcome mails pass reset and all that
u dont want it to end up in spam
right.
so sendgrind , mailchimp and so on come into the game
But is setting those up similar to setting up one in gmail? Because at this point I just want to know how to make it work.
Its fairly similar in flask you need few env varibales like mail_server = smtp.gmail.com the port, ur email , password
and using flask_mail is quiet easy like 5-6 lines function
Right that part will be easy. The part Im gonna have to learn is OAuth2
Alright dude keep it up sorry cant help u with that in django bet there is someone here that will answer so i wont spam hah
No worries. https://developers.google.com/identity/protocols/OAuth2WebServer Its right here its just a matter of reading. Ive never gotten auth like this from any app so it'll just be new.
Actually it might be significantly easier than that. https://studygyaan.com/django/how-to-signup-user-and-send-confirmation-email-in-django
from selectorlib import Extractor
import requests
import json
# Create an Extractor by reading from the YAML file
e = Extractor.from_yaml_file('amazon.yml')
url = "https://www.amazon.com/RAVPower-Wireless-Charger-Adapter-Compatible/dp/B07SB41DQ3?smid=A2XR0GE58QDDNI&pf_rd_p=57e6c9a8-3db6-4b15-a07a-529e7121a3ab&pf_rd_r=8VD5S1G93G4RTHWJSJJC"
r = requests.get(url)
data = e.extract(r.text)
print(json.dumps(data, indent=True))
I'm trying to scrape the Amazon link for the price. I am not sure what I am doing wrong, this is my first attempt at web scraping. I'm using this .yml file:
Price:
css: 'div.a-section div.a-section span.a-size-medium.a-color-price'
type: Text
Output:
{
"Price": null
}
I'm pretty sure that we're not allowed to help you because it against the Amazon terms of service. But... I will say that if you search a little bit, you will find the answers.
My advice is that if you really struggling to learn to scrape and you want to learn it in a manner that we are allowed to talk about
You choose a project where its not in any terms of service not to do it.
For instace, start with a scraping weather.gov or something like that.
Then we can help no problem. And you can take that where ever you want to.
how can i get a URL to host without a port (using npm start / node). I want http://haste.dragdev.xyz:8080 to be accessable at just http://haste.dragdev.xyz but it wont work
weather.gov has API, don't scrape it
darksky has a decent API too
@native tide I looked it up and it said that it is perfectly ok to scrape Amazon, and that it isn't against TOS
You may use Amazon Software solely for purposes of enabling you to use the Amazon Services as provided by Amazon, and as permitted by these Conditions of Use and any Service Terms. You may not incorporate any portion of the Amazon Software into other programs or compile any portion of it in combination with other programs, or otherwise copy (except to exercise rights granted in this section), modify, create derivative works of, distribute, assign any rights to, or license the Amazon Software in whole or in part.
I would take that to mean that you cant, but I am not an expert in these things. All I know is Ive seen people be told countless times in this community that we cant help with this subject. so...
I'm gonna err on not getting in trouble. But. If someone tells me I can tell you what to do, I will.
@native tide Tried it with weather.gov and it returned what I wanted, which was current temp
So I guess there is protection of some sort
It's just annoying however, as I want to have it check a price everyday. Oh well.
You just need to search man.
LEL
In regards to rendering templates with Flask, is there a way to render included JS files the same way?
Like if I was to write {{myvar.x}} in the js file is there a way for flask to substitute in the value?
Please ping me with any help.
@shy oasis you should just be able to do that in the same way as HTML - just call render_template() in your route function. Jinja2 (the template engine) works for any text document.
@hallow moat so it will work for the <script src=""sdsdsds.js"> tag?
Yes, but if you're including that file it'll need to be a route:
@app.route("/js/mydata.js")
def fill_data():
return render_template("data.js", blah=blah)
In this case you might want to use an inline script tag instead, or pack the data into DOM elements.
Ah I see.
The inline script tag is what I detailed above right?
And when you say include do you mean with the include in js or the inline script tag? And if it is the inline script tag do I have to do the route
@hallow moat
<script type="javascript">
{{ your.data }}
</script>
Oh so just write the js in the html doc
Yeah.
Or, put your data in HTML tags / data attributes and then read those with your JavaScript, if appropriate.
data attribute?
Hi, how can I modified parameters using metaclass?
I wrote this and don't know how my class Meta can change params in init :
class Meta(type):
def __new__(self, class_name, bases, attrs):
a = {}
for items in attrs.items():
key, value = items
if key.startswith('_') or key.startswith('__'):
a[key] = value
else:
a[key] = value.upper()
return type(class_name, bases, a)
class OnlyUpper(metaclass=Meta):
x = 'test'
y = 'second test'
def __init__(self, name, surname):
self.name = name
self.surname = surname
o = OnlyUpper('my_name', 'my_surname')
print(o.x)
print(o.surname)```
Hi
Do you know if there's already an effort to make a TailwindCSS theme for Crispy Form ?
I'd probably go directly to people developing crispy forms with that one
So, I don't know if this will help you because I just started... or even if its the same thing
class UserUpdateForm(forms.ModelForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email']
But this is more akin to examples of the Meta class that I have seen. Maybe if you put that class directly into the other class you will have less trouble accessing its attributes?
Not sure. Maybe someone else knows.
Hi guys
I want to ask a question
I have a project where I need to implement an online store website. My team and I are unsure on which technology to use. We are all familiar with Python, so I suggested Django, but another team member says we should use ASP.net core. what are your opinions on what we should use.
@arctic stag It really depends, ASP.net is based on C# which makes it easy to translate your website into a native application whereas Django is mostly website oriented. I would say you ought to go with django as it is more straight forward making you only have to deal with frontend, especially if you use PayPal's ready buttons to make transactions you can have a complete payment system in under 30 lines
Both are very good though so don't take my opinion for granted
You should really break down whether a WPF or a website isbetter for your needs
hmmmm
so we are expected to communicate with a database and show it on the website live/dynamicly
That is Python territory, you can do that easily
I would suggest using flask/sqlalchemy
and jinja
so if a user would buy an item will i have the option to show the stock goinf down without refreshing the website?
So you want live updates?
yeah
There are 2 ways you can do that, either using javascript or backend using sockets
I would suggest doing this:
create a javascript function that works onclick, so when user buys the product the function makes a request to the server and the server replies with the new data
then the new data is passed to the stock graph
also why flask and not django
for what you want to do it is way more straight forward
well I didnt go into full detail
but I will have different types of users as well, like customers, product managers, sales managers.
they will have different roles and features
ok : D
Take a look in JWT
You can add data into a jwt and then set it as a cookie
That way you can have different jinja renders based on role
oh cool
You can also create decorators, like:
@customer
customer will be a function that is checks whether someone is a custom
if they are everything under it
will be for them
also how can i convince my team members to use django/flask rather than asp .net?
or how can i convince myself to use .net rather than django/flask?
That is pure choice. But think of that: in flask you can have a server up and running with basic auth
in ~1 hour
whereas on asp.net you need more for sure
also this is for a software engineering course, so we do have limited time
and sprints every week
I built a shop similar to your project in about 70 hours
on flask/sqlalchemy
I bet you can do it, especially if you have different roles
e.g.
1 frontend
1 backend
1 supervisor
yeah but we will also be shifting roles so that everyone can learn
That wouldnt be too wise as you will have to comprehend each one's work each time
yeah but thats what the prof wants
I don't know if I would take Kiwi at face value on whether you should use Flask vs Django lol. I think the general consensus though is that there is more to learn with Django. That being said, upon learning it, many things are already done for you. You can modularly pack them into projects and ship out.
I would research into it yourself tbh
I have a CSS question...
I know CSS pretty okay, but sometimes the more advanced stuff is over my head
*,
*::before,
*::after {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
What is going on here
Also, just discovered this..
fun times
Basically, it loads that password update form with any random urlpattern entered after the expected one... without the tokens and stuff but the form is broken
If the tokens are right from the email, it will display the form correctly
So at least no one can change their password this way
But its kind of unprofessional to appear like this
Not only that but if someone manually enter the pages for password-reset-complete it will tell them that their password was changed when it wasnt.
I need to somehow... make those pages only viewable when directed to in the sequence of the password change progression
WEll, read the token from the url and if it does not exist, send the user elsewhere
@native tide
@bp_authentication.route("/auth")
@bp_authentication.route("/auth/<string:permission>")
def initiate_auth(permission=None):
if permission:
return redirect(eveAuth.get_login_url(permission))
else:
return redirect(eveAuth.get_login_url())
``` This is kind of the same. Different logic, but you get the gist
also redirect if it is wrong
The issue with adjusting all this stuff, which I will admit is the major issue with Django, is that I have to write some new class inheriting from another class to do it. And it is kind of more intimidating than just writing the thing yourself. Because whats going on behind the scenes is a lot to learn.
But I can do it.
In Flask it is a simple decorator with a function
I am using BLueprints though
makes this kind of thing a bit more modular
Its not going to be too hard probably. This is the url conf for the classes that you see which are in django.contrib.auth as auth_views. So I just have to find those classes and study them to see what I can add or change.
path('password-reset/',
auth_views.PasswordResetView.as_view(
template_name='users/password_reset.html'),
name='password_reset'),
path('password-reset/done/',
auth_views.PasswordResetDoneView.as_view(
template_name='users/password_reset_done.html'
),
name='password_reset_done'),
path('password-reset-confirm/<uidb64>/<token>/',
auth_views.PasswordResetConfirmView.as_view(
template_name='users/password_reset_confirm.html'
),
name='password_reset_confirm'),
path('password-reset-complete/',
auth_views.PasswordResetCompleteView.as_view(
template_name='users/password_reset_complete.html'
),
name='password_reset_complete'),
hi, out of subject but is tkinter most used library for gui?
I think its possible that I will eventually prefer Flask over Django. That being said, when I know Django well, I might not feel that way.
I'm not the sort of person to start one thing and start over again using another set of tools over and over again.
If I allowed myself to do that every time I saw a new thing, it would be bad.
@native tide tbh for me Django is more team-oriented
Maybe. I don't really have enough experience in either to have a preference. I will eventually take a crash course doing a simple basic project in Flask like I just finished up with Django and see what is better for one or the other. Right now I don't want to have a bias because I just havent used both yet.
I definitely think from what i have seen that there probably is a use case where its better.
But i think the same is probably true for both depending on what you want to do and what you dont want to do.
What I can say about Django is that while it is impressively organized to do what it does, it's overwhelming and daunting the further away from the code that you get.
It starts to turn everything into a short cut
And the way it works is all under the hood.
I dont like that about it. Admittedly.
But once I understand it completely I imagine it will continue to impress me.
I'm starting to realize that the best way to learn Django once you get to where Im at in it...
Is opening up the actual code of the things you are importing and just reading the code.
Then reference docs as it does or deosnt make sense
Is it possible to serve static files using Flask without using url_for in your template? For example, say I download some bootstrap theme/template that includes various static files like images/examplelogo.png or js/starterkit.js. If possible, I would like to update the routing rules in a single place, versus updating every single call in the template to use the url_for function. Any idea if this is possible? I can't seem to get anything working that does not use url_for(or manually adding a static/ prefix to the various calls)
@little steppe Yes you can use /static/js/filename.js
Ok, so I need to update all of the urls, there isn't some sort of routing rule I can add once? Just wondering. In the past I've updated the urls, but I was wondering if there was a much easier way haha
I am not sure
hmm ok, thank you for the link
np
I am sorry I cant help but I usually write my own css,js, etc
So I dont have template problems haha
Yeah I'm lazy and just trying to use a basic bootstrap landing page. In the past I have gone thru and updated every call with the static prefix. I figured it may be in my best interest to try to figure out how to get it working by updating 1 thing (routing rules) versus adding a prefix everywhere I need to
ha
Well I cant help you there bud
Using templates is not "lazy"
Its sane.
That said
bootstrap is kinda lazy ๐
We have sort of reached a point in web dev where if you are creating something for marketing a product, you almost are forced to use some type of framework like that. Because people who are not webdevs see things that are really boot strappy
and they dont think what we think
They think, "Woooooww ooohhh cooool"
And you sort of have to.
Realistically I would have been done by now if I just updated the various .css/.js/image urls throughout, I just figured now would be the time to see if there was a better way to do it. Its literally just a single page
Honestly, it taught me how to organize CSS better for scaling.
Even if I do it myself and customize it a lot
I would not be as organized without bootstrap showing me how to be