#web-development
2 messages Β· Page 109 of 1
Traceback (most recent call last):
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Owner\PycharmProjects\Django\password_generator\passwordgenerator\views.py", line 25, in get_name
return render(request, 'name.html', {'form': form})
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\shortcuts.py", line 19, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\template\loader.py", line 61, in render_to_string
template = get_template(template_name, using=using)
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\template\loader.py", line 19, in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
Exception Type: TemplateDoesNotExist at /hello/
Exception Value: name.html
how do I create a template
use django docs
<input type="text" name="text" width="150" height="50">
shouldn't this be working?
it's been...20 years since I last used html :\
Finally a django community! π Is there a dedicated django server on discord? Would love to join one.
@sacred gull width and height are css properties, either refer to them in a style = height: x, width: y or a seperate css file
so I can't really adjust height/width within the html?
oh, kind of miss-read your answer
I'll try that, thanks
hey i hae a question ^^
So i have a small laptop and i wondered when to set the max-width for my html-tag, so the website doesnt expand to the full screen-size on large screens
@sacred gull yeah np, just look up on the style attribute in html and it'll explain how you can introduce CSS into HTMl
@polar trellis this is way more complex, i didnt realize you needed to do so much security
I am considering using python and django to create an affiliate marketing website
Is this recommended or must I consider other programming language / web framework? Why
python/django will get you the backend you still need a front end language
hello please listen i am making a website project and i need some help in http and css script
Hey, so I am trying to use a bot to post my server member count on my website, using flask and discord.py. Here is my code: ```py
from flask import Flask, render_template
import discord
from discord.ext import tasks
from functools import partial
from flask import Flask
from threading import Thread
client = discord.Client()
app = Flask(name)
members = 0
@client.event
async def on_ready():
print('Ready!')
@app.route("/")
def index():
global members
guild = client.get_guild(id)
members = guild.member_count
channels = len(guild.channels)
print(members)
return render_template('index.html', members=members, channels=channels)
if name == "main":
partial_run = partial(app.run, host="0.0.0.0", port=80, debug=True, use_reloader=False)
t = Thread(target=partial_run)
t.start()
client.run('token')``` When I type flask run in terminal, it works completley fine. But since that is just a developement server, I installed gunicorn and then typed gunicorn app:app in terminal. Then it went into a big loop of starting and crashing. It eventually gave the error: RuntimeError: Event loop stopped before Future completed. but that was probably because I stopped the code. Any ideas on running this?
@polar trellis front end such as JavaScript and HTML5? Is there a preference for django or just whatever Iβm comfortable with?
i have a question about building a website, First; can i build a website using python? Second; im just a begginer to python so i know a little of variables and for, if, while statments (can they be used with building sites?) Third; where can i write my code so it becomes like a website.
Learn python oops concept.
And then give a shot to django framework which is based on python. With the help of django you can build a website
hello please listen i am making a website project and i need some help in http and css script
@zinc sphinx html and javascript are oke
@mental prawn
- Yes it's absolutely possible
- Yes you need conditionals, while loops etc for websites ofc
- In a very basic way, a website is an html file and you can write one using a text editor and open it using a browser.
so then how will i be able to paste my code and turn it iinto a website, and also i can use pycharm right?
yep
but you need pycharm pro for django/flask prebuilt boilerplate
@tribal void so ask your question instead of saying that you have a question 2x
@native tide ok bro can i ask my foubt tomorrow because it's too late and i am gonna sleepπ
@native tide bye and goodnight buddyπβ€οΈ
How do i update a form field on POST request in Flask?
Can anyone give me some direction/advice to best containerize my app via Docker for easy deployment to a remote server. My stack is Flask and Redis which I'm running using python-rq. In order to start my app locally I have to start the redis-server then run "python app.py" (Flask) and then "python worker.py" (Redis worker). I've been struggling to really create a good image for this.
How to i check if the email is already exists in database with flask and sql?
django or flask which one is better?
Gates two separate containers
I just sucessfully set up a microservice using Django
My main focus is on DaaS
anyone familiar with that?
class Meta:
model = User
fields = ['username', 'email'] ```
Someone explain the meaning of the above snippest in django I don't understand their actual purpose and meaning.
@wanton ridge just see if the object is None or not
@prisma jackal if you're using ModelSerializer, the Meta class states its metadata
You state the model and fields it will serialize with model and field variables
I have no idea.
I need help
look like setting meta data at the sub-file level
Yep
You can make a model serializer then in the python console do print(repr(your_serializer)) and you will see its fields. It's just like a model
MVC?
Also the fields that you state will be required by that serializer when you make API requests. But you can set them yourself if you want them to have any extra validation different to your model which it's trying to replicate.
Oh never heard of it
you should get to know that methodology I suppose.
it helps in web dev
it helps you break sub-level objects into components and such.
django handles that already π
that's true...why reinvent the wheel.
If you want to know what the term model comes from.
it makes sense why django has views... I never knew why they used the word "views" when Flask refers to it as a function (I think)
Yea and models
yeah
interesting
it's good to keep up with the terminologies because they are redundant across systems.
cross-platforms
and I don't think that terminology is going to change any time soon.
yeah interesting, I barely know of any theory/methodologies so thats cool
yeah I also know CRUD
that one is pretty helpful as it relates to RESTful API
I just don't like that it spells CRUD like poo
maybe they could of tried harder on that acronym specifically
unless a troll made that specific terminology up which is possible.
maybe the guy that came up with CRUD was getting sick of all the methodologies
well, CRUD isn't really a methodology I'd argue. Create. Read. Update. Delete. Those are the basic functions that almost every single app you use do. Even if your app to your clients only shows a READ state, you probably have a CRUD admin interface. And if you don't you're still doing those actions.
well said...that almost every single app you use do...doodoo
no, with all jokes aside. I think it is good to have in checking states.
why not CRWD
create, read, write, delete?
because writing is updating
i am working with flask and why i have no picture in my homepage, in my homepage.html i have picture but if i start my server then i have no picture. How to insert pictures
because flask is ghetto π
that would be php π³
flask is great, its just no batteries included whereas django is here is everything AND the kitchen sink
lmao
this ghetto...
flask's logo is an old wood carving of a flask
flask doesn't even provide you with the controller, nevermind the batteries
i always thought it was a chilli...
and also please don't use ghetto like this ... ghettos are real things and not the best way to describe something just cause you think it is poorly done
yeah not a chili though I've heard that before
Can i update form on a post request in flask? and update the html?
sorry, I just watched Uncut Gems the movie a couple days ago.
correct flask doesn't give you a "controller" cause it is not specifically MVC .. but you can do MVC as a pattern in flask for sure
Uncut Gems was a really good movie.
@upbeat imp You could render another HTML page populated with your form's input once it's submitted, maybe?
would only take some simple ajax
React type beat π
@upbeat imp You could render another HTML page populated with your form's input once it's submitted, maybe?
@native tide So i need to redirect to another url with a new html?
on post
would only take some simple ajax
No, you can re-render a HTML page on the same URL
Look at what AJAX is
How do i re-render the html?
either by render the page again from the POST request if you're doing it like that
or AJAX if its being POSTed to it like that
AJAX just refers the dynamic re-loading of front end code
So i put render_template inside both get and post?
e.g. sending POST requests without reloading the page, changing html etc...
@upbeat imp yeah ig
Implementing AJAX would just be on the frontend JS though right?
yeah cuz the backend can just interact with it as a api
$("button").click(function(){
$.post("demo_test_post.asp",
{
name: "Donald Duck",
city: "Duckburg"
},
function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});```
simple POST request without reloading the page using JQuery
jquery still used? π³
very much so
i have in my index.html some images. And i have a flask server and once i start it i ave on my site no images, anyone can help me
@wanton ridge do you have a route for your static files?
This does not re-render the html π€
i have a route with render_template("index.html") @warm igloo
right, but flask is now serving and it needs to know how to get to your images/css/etc
@wanton ridge Just do the img src={{url_for}} tag with your image filepath
that looks like it should work...
ah thanks
So you're gonna need to store it somewhere like a static or media directory, I wouldn't know π
@upbeat imp wdym? When the user makes a post request, what do you want to happen? Just refresh the page?
Flask treats static as a special place and routes for it. If you didn't want static as your place and had your own, you'd have to let Flask know that.
Or populate the form with the information that the user inputted?
@upbeat imp wdym? When the user makes a post request, what do you want to happen? Just refresh the page?
@native tide Yes, i want to update a value in the form object and refresh the page with new values
hmm in your if block that handles POST requests, set form=ProgrammingForm(request.POST)
i'm not sure of the reasoning behind such a thing.
Also instead of saying if request.method == "POST" you can use the inbuilt Flask functionality to check whether a form was submitted.
@warm igloo i don't use javascript
I think it's if form.is_valid()? I don't know, I don't use flask
@wanton ridge what u use? bootstrap or Material UI?
You should use JS π
@wanton ridge okay? css is static. images are static. Any file like that.
Python + JS are a killer combo
bootstrap @cold haven
@native tide I get "AttributeError: 'Request' object has no attribute 'POST'"
you can use media queries instead of javascript.
<img src="{{ url_for('static', filename = 'hello.jpg') }}" alt="my image about whatever">
@upbeat imp could you show the code?
@warm igloo thanks
I would probably use Material UI in the future, but have been using bootstrap @wanton ridge
I think request.POST is for django, might've mixed that one up
Bootstrap requires javascript in some cases I believe, but Material UI is completely CSS.
Can't find anything on google about this either.. wierd
Someone must have had the same problem
See here: Bootstrap uses JQuery
but Material UI is CSS only. that's the big difference
try request.form
Bootstrap has a dependency on JS yes
Okay, but how do i change the value in a form field before re-rendering the html?
Material UI However is designed for React and therefore is also pretty JS heavy
it isn't built just for React and you can use it for any framework.
@upbeat imp To access data of the form after it's submitted you can do form.your_field.data
Material UI is pretty big in the react field
never used it tho
bootstrap does have some JS
still dreading on how i can implement bootstrap with it π
@upbeat imp You could get the user's inputs, and then render them somewhere else (it doesn't have to be in the same form).
if you're just using it for css components probably better to use TailWindCSS, Bulma or another pure CSS framework
Or even better do it on the clientside but that is extra.
It does update the form field, but not re-render the site
@upbeat imp Yeah, so you got your data out of the form. What do you want to do again? I'm a bit confused
I use react
yeah, React is cleaner, but it takes longer to set up.
bootstrap is pre-build with lots of functionality that you would need to set up in React.
@upbeat imp You can render a HTML page with the form fields as read-only with the submitted values within them.
I remember I did that long ago
and it was a headache
Do you remember how?
are you using WTforms?
I tried adding an argument to the init function and passing that, but i can't seem to refresh the website
do you specifically need to render it in the form again?
You could just have a seperate hidden div which is populated when the form is submitted.
The value that needs to be in this integerfield will change at every post of the form
So yeah kinda
the default is 00000000, and when a button is pushed, aka a post request, a function is called that gets a serial number from a database, and needs to display this in the field on a refresh
I remember I did that exactly but it was a pain and it took like 2 days
I'm a completely newb at this aswell
Is there a more dynamic way to do this?, like web-sockets or something?
you mentioned something about ajax?
Or
I think I had the form, and if that form was submitted, it would render divs with the form's values to replace the form 1:1. Then at the bottom it would have a button to "submit" again so the user could change those values. I might've been WTForms read-only fields or divs, I really can't remember
i guess i could worst case, redirect to a new url that is identic with a new form π€
Uhhh you could muster something up on the frontend with JS but then you'll have to implement some APIs
anyone π
i wouldn't know
@upbeat imp this is how I handled your issue, with Flask. I actually don't think there's a proper way unless you clobber it up yourself
I just replaced all the form fields with divs with the submitted values
Then at the bottom there is a submit button (of another WTForm) to refresh that form to make it POSTable once again
π
Obviously not the best way around but I couldn't find anything online too, as you said
But it replicates the feel of what it should be instead of a div to the left/right of the form π
You could probably use React for that
So the submit button makes profile_confirmed == true?
Yea in my case
I used that to check whether the page should render divs (with the populated info) or a form (to input data)
and that profile_confirmed is a part of my User model
So you could have something much simpler
a view you mean, but a model in a view ;D
that's where the naming gets misconstrued
I would like to say just another namespace for simplicity sake.
huh?
Really...what you are dealing with is server software that can read multiple file types, you could even call the files as file-level objects themselves.
I mean in reference to server-side and client-side rendering
each and every one of them is a microservice in a server container.
that's why you can render html pages as whole objects so I believe they should be treated as such.
I would call objects of MVC as sub-file level components and should be treated as such.
@normal kite wym
You can refer to objects in scope of the file-level or sub-file level.
@native tide I had a question about heroku local hanging when I'm using waitress-serve
so I'm waiting until the discussion ends
before asking
cool :D
Ok, I was trying to deploy my django app to heroku using waitress cause I'm on a windows machine.
This is my proc file
but it hangs when i do heroku local
and I get this error
why not use docker to test it on a linux env
how do I do that
uhh @native tide , when i changed the form field from IntegerField to StringField, the form.SN_single.data = '123' worked perfectly
it worked with request.post?
https://docs.docker.com/compose/django/ very basic example of docker setup for Django
Docker itself:
https://docs.docker.com/
Download for Docker (Requires virtualisation enabled in BIOS will probably be on by default):
https://docs.docker.com/docker-for-windows/install/
Thanks!
Ok π and that updated it on the clientside after the form is submitted?
Yeah
But with StringField i can't do max min validation tho
But it's better than nothing
ok
So when you submit a normal form in Flask, you end up with that form with the submitted values in the fields?
didn't know π³
I must be out of the loop...I thought the purpose of a form was to receive input.
you talkin like a form is supposed to come with values before putting them in.
I explained it further up in chat. The form comes with default values on first get request, then the user push a submit button, and the website should refresh with some new values in the forum @cold haven
especially when they're for things like settings where they might already have a set option
you probably looking for a read-only form then.
@upbeat imp yeah, I wonder if you can use a read-only form or if there is one that exists?
think he wants it to be editable
Yes, the user should be able to edit the changed value if desired, the new value is only a suggestion
e.g.
Something is originally blank
they set the thing
form is re-rendered with Something pre set
then they can edit it again and repeat should they choose
basically a settings form
which tbf i wouldnt personally use WTForms for but then i dont use that in general, i would just use regular HTML as a block with a fillable pre-set
@upbeat imp that sounds to me like the job of a login page, and not the functionality of a sub-page.
login page? What do you mean?
that sounds to me like the job of a login page
why not make a separate component for that sort of thing? I would
I'm still learning about Django
but yeah i would personally do it raw HTML
I feel like this would be something simple in React
this is Flask just btw
oh, I probably won't try to use flask at all.
you're not missing out on much π
generally its alot more malleable that Django
which has its ups and downs
great if you know what you're doing but generally a pit fall for beginners with poor organisation of files
sounds like Django comes with built in stuff that would do what he is trying to do in flask automatically
you're very knowledgeable mr. CF8
I have experienced many of le framework work
Writing my own but i cant work out why Asyncio is bullying me π©
π³ damn
So flask is shit?
Flask is great
There's really not a big of a difference
you say it doesn't come with controller logic though?
that's a huge deal breaker for me
Django is a full framework
Flask is a micro framework
there is a big difference to distinguish between them
Flask will let you do stuff that DJango will never let you do but that comes at a price of you are expect to setup alot of stuff
Django is more of a batteries included system as long as you confide by there rules
what is it that flask can do that Django cannot?
^
Imo from projects w/ Django and Flask I found django to be much faster to build with. But Flask was an amazing starter framework to learn I guess
- Anything requiring a Custom DB backend generally,
- modifying of rendering engine,
- inbuilt cron tasks (Django has this but can be a pain)
- Flask is alot lighter weight than Django (less bloat)
- You're not required todo things like X and Y like in Django
Django is very fast to setup generally
because it does alot of boilerplate for you
which is fine for alot of people
Yea
hence why it's slogan is The web framework for perfectionists with deadlines.
But equally it is very rigid and rather Slow with how it wants you todo things
Once you step out of what Django offers then it's essentially Flask... with you writing everything that you want from your program
Both are good
Its Django's way or the highway which is the biggest distinction between picking a Micro Framework or a Full framework
But by that, do you mean you have to use what Django offers?
Because you could just DIY it, no?
Make your own auth / models etc
You have to layout things How Django wants, setup the ORM design use the DB's it provides etc...
im not saying its impossible
but its considerably time consuming battling with the system
Django has it's own built in ORM kind of which makes database management easier I bet.
Have you chosen a favorite? @quick cargo
Yea but for flask it's no different, u just import something like SQLAlchemy and get to learn that lib
i think overall Sanic is my favourite or FastAPI with my custom Backend wrapped over it
depends what im doing
le senior dev π³
you guys have jobs in coding web services?
no I'm 17 haha
Django generally isnt used for things which rely on multiple systems combined, say something like Discord. Django would be pretty un-usable due to its nature,
Same
lol
he is chinese...what do you expect because they learn young I guess
Just that sweet sweet boredom of passing time and try everything out π
pst its not Chinese its Japanese but π
I think people from India are even better at coding, or they do start at a young age too.
Cuz i live in the UK lol
my g
India has the biggest tech consulting firms on the planet I believe...
same haha
which is about to go into Lockdownβ’οΈ
Bojo moving mad
@quick cargo U done UCAS and stuff?
yeah bro I applied like 2 weeks ago
especially when i dont plan on going to uni
I would be careful working for a firm that is not based in your own Country.
You can't really file for unemployment if you get laid off.
I mean, I'm tryna get them US big bucks if you know what I mean
yeah, I'm trying to get an IT Consulting job atm.
maybe at one of those big job search firms
Work Experience > Degree generally
except when talking about Big Data or AI due to the nature of how hard the maths is generally
I just plan on going to university, acing them algos/data structures and getting an internship at a big corp.
It's such a bummer though, in the US these big companies target schools for interviews. In the UK not so much
you want to be careful about internships...They go by very fast.
Yah but I'm talking about the ones at faang
US companies target schools because they're not paid lmao
yeah, I think they only hire people that graduate from Princeton or Harvard or Yale honestly
FAANG
Naw the interns get paid
UK Internships are generally Paid aswell while US are generally not
big time
its basically Slave labour US wise
thats google though lol
at least at faang
a lot of the major software corps go ham on the pay
but say you work for google in the UK it's like 60k GBP
if I had 100k to go to Yale or Harvard I would to get a Masters degree in Computer Science.
it's a big difference
yeah I should've applied to US universities, missed a big oppotunity there
i heard their tuition costs are massive though
like $50k a year
i'd rather just go to st andrews or durham
Their system is generally very wack
facts
it's ass backwards
tbh Uni's in general are pretty wonky considering that the UK system has a government appointed 3rd part exam board uptop but not including degree / bachelor level
Uni's self regulate though
they can choose and make what exam they do and what marks they give
two uni's can have entirely different papers or exams and give you the same degree. π
most companies with unpaid internships are doing so illegally .. just not enough enforcement
We don't even mess with the potential of screwing that up so our interns are definitely paid. I think the most recent one I have is $16USD/hour. 20ish hours during school, but he was with us full time during summer.
yeah
yeah but still unis are regarded for jobs. I'm just going to a hopefully prestigious uni for the peice paper at the end with jobs in mind
fairs
I don't see a point in having a short term intern. It'd waste my time and resources. I only want to open intern positions on my team if I get to have the role through summer and semesters. Previous to this one, I had one intern for 18 months and now she's about to get a lead role at a company larger than one I'm at. I'm so proud of her.
otherwise i wouldn't be assed
Indeed is pretty poor for jobs
what would be an alternative?
Seen alot that basically ask you for experience you litterally cant have
it's funny, I get emails from head hunters that ask 5-10 + yrs experience in technologies, and I respond with requesting an interview to be a job hunter at their firm because it's ass backwards. They probably get paid nicely to perform DaaS on different job sites and write emails to people that just get out of college that are looking for jobs.
recruiters get paid nicely when they place people AND the people stay
typically recruiters charge 15-20% of the salary for the placement
Best practice to accept PayPal in Django ? Preferably no libraries outside of Django
@quick cargo have you applied to any software jobs yet? Or emailed any companies? I think you'd have a great chance
but if a recruiter places someone and they leave or get fired in a certain time frame that money isn't paid
which is why it pays hansomely.
or both work full time and do consulting
it just means a job reference to a job.
essentially... freelance?
I do consulting occasionally.
if you know the technologies out you can simply know what to expect of companies requesting them.
er, yeah, basically freelance though I bill as my company and not as myself
it could be on contract or not
we are WAY off topic for web dev though
well, it's all related I suppose
Ah ok, so you'll just do a project for a company, like a subcontractor?
yes but there is a careers channel too
Yeah true. Interesting talk tho π
do a project, or in my case, work with a team who's doing the building and I act as a subject matter expert, architect, principal engineer, or something like that
rarely do I write the day to day code for them anymore
well, let's get off the subject of job hunting then π
I think I write way more prose than code anymore. And diagrams. So many diagrams. π
That's actually really cool
what if we talk about python technologies that are related to certain careers?
I suppose that's fine
I still freelance for some work for KFC which is funny. Like seriously little stuff like fix some html or js, or some data viz stuff. They're one of the few clients I bother with anymore cause my time is limited and I don't enjoy freelance much anymore. But I like the people I used to work with there.
Yeah. I guess. I saw lots of jobs increasing to take up React (w/ Django) as a requirement
Haha wow.
π© Companies becoming too reliant on React
React π It's quite nice tbh
I don't see a point in having a short term intern. It'd waste my time and resources. I only want to open intern positions on my team if I get to have the role through summer and semesters. Previous to this one, I had one intern for 18 months and now she's about to get a lead role at a company larger than one I'm at. I'm so proud of her.
well you dont really give them actual work
I like it too
π³
you more just get to meet them and see if they culture fit, then make them an offer if u like em xD
front end framework (vue, angular, react) plus a solid backend framework (.net, django, etc) is the combo to set you up for success
if I never write front end code the rest of my career I'll be a happy camper
Since you know react, meaning javascript, get node exp because why the hell not its all just javascript. then we are in python so you have two backends and react and you are golden
yeah that's a good idea
if I never write front end code the rest of my career I'll be a happy camper
i actually really enjoy writing in react, but most front end is straight cancer
id rather kms then write more normal non react frontend js/html/css
how do you go about structuring your React page? Do you use bootstrap?
I'm not a fan of css-in-js or jsx syntax. I much prefer the single file component system of vue.
Same
vue might be more than fine ive never used it, i meant compared to like 5-10 years ago old school ways
oh yeah I see ya on that
You can potentially make use of Both Front end and backend rendering should you need it with vue
though I do get lazy and just fuck it I'm using bootstrap and some theme I buy
Ya'll buy themes? π
like I built warcache.com on flask and just didn't want to think about the front end code so it is mostly borrowed/bought and on its own
b-buying a theme?
I am new to Django but I'll catch on quick. I'm also pretty new to React, but I would rather just use bootstrap for now.
you mean just buy a theme and sell it to a firm for a retail price of your salary? Cool Idea.
Lots of people fall into the trap of buying wordpress plugins, racking up literally a thousand or two in costs when it can all be found free
GPL license baby
eh, I own a license to tim's whateveryoucall it and the themes are nice and one cost and I own them all. Plus they're generally offered in plain html, or with vue ANd angular AND react. More than you get from free stuff.
and source files for all the art as well
and since I couldn't design a button to save my life, nor do I want to hire a designer, I'm totes fine with buying a template for my personal stuff
Doesn't it take away from actually coding though?
good?
Maybe that's why it's chosen π
who the hell enjoys coding designs
hmmm is this the right blue
hmmm
lemme slightly change its blue
hmmmmmm
Bro you're unleashing some kraken rn
the bootstrap grid system is pretty easy. I can set up beautiful templates with grid and it's all based on div containers and setting up columns or nesting them.
hey 10 of my friends, what is your opinion on this blue vs that blue shade??
spends 6 hours through the night coding a dashboard
hmmmmm
this is what I've bought in the past: https://www.creative-tim.com/
6 hours? meant to say 60 π
even backend code for a lot of them
oooh yea I saw that before
so you can buy laravel and flask skeleton projects with the html and templates ready for you
so how does that stuff work?
once you buy the skeleton can you like, not post your project on githubb?
I wouldn't buy from say themeforest. But Creative Tim? Anytime.
sure you can, it is licensed for you to use in any project opensource or closed source
in fact, he open sources a ton of stuff too
yup
and if you don't have a license, he can come for you π
but its on github
no
I can put code on github right now that you can read but if I don't give it a OSS license you can't use it
you CAN but then I can sue you
but you will give a oss license
it isn't automatically "free" cause it is on github, even if it is publicly readable
its your code and you want to
I can give it a closed source license
you can trademark code or something?
how do you like oss your parts and not his theme?
I can't take GPL code, change it, change license, and sell it with different license
the gpl code must remain gpl
There are certain OSS licences that require you to keep the same lience
and some licences require X and Y use case
which is the whole point of them
so I can get GPL on my code and people can't use it unless I give permissions?
no, we're confusing some of this with a few conversations
so if you want to build a big open thingy that anyone can take and use and stuff
you are just limited to not buying a theme?
There's one which im a pretty big fan of that basically is OSS and free to users developing or testing but requires a paid licence for commercial deployment
no, buying the theme could allow me to use it .. it'll be in the terms of the license
it will vary project to project, seller to seller, etc
Here you go, read his license: https://www.creative-tim.com/license
I have question. What is complete opposite of GPL? is it the default if you make code?
the default is "no license"
meaning?
you dont have to include a license on github
it asks if u want to and gives you some selections
code by default cant be used or taken at all by anyone for any purpose
you did not grant anyone the ability to, you just posted it online but its still yours
Non-judgmental guidance on choosing a license for your open source project
this goes over a bunch of licenses u can choose to grant permissions
Youβre under no obligation to choose a license and itβs your right not to include one with your code or project. But please note that opting out of open source licenses doesnβt mean youβre opting out of copyright law.
this goes over if you dont have one
I do most of my stuff MIT now
but I also work on a lot of closed source stuff with no license at all in private repos
MIT is pretty decent yeah
MIT is simple and clean and no ambiguities imho.
Most of my stuff is open even if the code is truly awful because im too lazy to deal with login into git on every machine when i deploy π©
GPL2 is complicated. GPL3 is problematic cause it tried to fix for "saas" usage of GPL code but I think it got it wrong.
i use gnu gpl3. because if im coding something and you want to use it, fuck you i dont want you to close source it im sharing now you share
!

after years of using git, I finally learned how to use it properly.
I took the time to learn finally because I was too busy trying to code.
Git is great for versioning
i dont know how to git but github gives me a gui
bloodly annoying though if your branches get desyncd
They should have professional jobs that hire you for managing git code.
but why
I use git CLI
my IDE gives me all the info i need
lmao knowing VSC is a practically under most Developers stack
because you might be at a job that doesn't use github
i can even have the IDE give a git blame for every line
or imo should be under most developers stack
because VSC is incredibly important in the real world
or doesn't give you a gui
ill build a react gui then
I use VSC
you wont apricate it until you have a rewrite branch of code going - > make a error and need to roll back
vscode lets me view the rollback inside of vscode though
sure, I'd like to see your react interface to git that covers merges, rebases, cherry picking, etc
left to right seeing both versions
sure, I'd like to see your react interface to git that covers merges, rebases, cherry picking, etc
@warm igloo nvm
haha
the CLI isnt even very hard to use
you have way more control with the git CLI, it is less prone to errors over using the GUI git version.
im not saying cli is hard
the guis are good for the simple stuff
im just saying vscode and pycharm have alwasy let me do what i want
including seeing git blames, versioning, rollbacks, etc
I should get a bit more comfortable with Git Kraken but its a bit of a monster on larger projects
not like you need to memorize all of it .. there are hundreds of commands and most people use like ... 10?
π
I liked gitkraken till they went subscription model
most common are probably
pull, clone, push, commit, stash
I think I want to try git in VSC next.
it lets you see a shitty coded line
I think it would be easier
and you go this is garbage what idiot wrote this
and then you look at the name to the left on your editor
and its u
π
pycharm has a pretty nice system (with Git integrated)
in my last project, someone yelled at me for not creating a new branch and instead I forked the repo. He said you shouldn't do that, but I caught him not knowing what RESTful API is so...
it was some trolling
uh
I was invited to a project on discord at a discord server.
well that depends
you can create a branch w/o a fork
you can git checkout -b <branch name>
and it creates a new branch out of master
you don't push the branch to master though
I would rather just make a fork of the repo
generally you can fork it -> do the edits as a contributor -> make a PR and a branch will created
i know you could clone > branc > edit > but how do u pr???
how do you upload? you dont own the repo
its a weird system
you get your own copy of the code on the server
Best practice in implementing PayPal in Django without the use of libraries outside of Django?
Hello, does anyone knows how to upgrade your pandas to the newest version on python anywhere?
@karmic egret pip install -U pandas
@quick cargo It does not work on python anywhere website
the version still shows 0.24
Get Started
Before you can integrate a PayPal product or solution, you must set up your development environment to get OAuth 2.0 client ID and secret credentials for the sandbox and live environments. You exchange these credentials for an access token that authorizes your REST API calls. To test your web and mobile apps, you create sandbox accounts.
Logging into the Developer Dashboard to get credentials and create sandbox accounts requires a developer, personal, or business account. Each account provides different levels of access to PayPal functionality.
this is where I would start
Oauth2.0 yeah
If you're not massively familiar with Oauth2 Directly i'd probably say to use a 3rd party lib for now
Its not necessarily hard but its a bit awkward todo if you're not similar with the flow
cya
@karmic egret do you have a requirements.txt
if you dont have one i would worry
im not familiar with Python Anywhere so i dont exactly know what you can do
you could try force a update
doing pip install pandas >= latest.version.here
do you know anyother website that will also do the same thing for free?
I tried the repl.it
But seems like repl.it does not work anylonger
Most things that are free are generally not great
I am only doing a student project, so
you could try a free google cloud or aws teir
what is an api request?
hello
Does this mean I am not receiving the object back? I used $('#id') to get the object
$.each(data.responseJSON, function (key, value) {
var id = '#id_' + key;
var parent = $(id).parent();
var p = $("<p>", {id: "error_1_id_" + key, "class": "invalid-feedback"});
var strong = $("<strong>").text(value);
console.log($(id));
console.log(parent.id);
console.log(p);
console.log(strong);
p.append(strong);
parent.append(p);
p.show()
});
That is the jQuery
It does not seem to be returning a value for the parent
Anyone have any idea?
no idea
$.each looks like a for each loop, no?
I would convert the response to a json object first. I think you are missing that part
you need to make a controller for it.
you need it to pass the model logic to the view.
@devout coral The reason a controller exists on the client is to convert json string to an object
@cold haven That is not the issue as it works on another part of the site.
Also the response is a json object
ok
I have used jQuery a little bit.
I may still have some code somewhere to look on as a reference
nope.
I deleted it.
actually I saw that you were using key as a param.
I think it had something to do with the script that crispy forms uses for file fields when using the crispy tag as opposed to the filters
@cold haven The code I have is working lol. I am pretty sure each is sort of llike a pythin .items on a dict
The each function will return a set of key, value pairs
Yes, that is what I have in the code
It gets passed to the function
Then I use Key and value in the function
ok, so to get #id would be directly from the dom I believe.
@cold haven Yes, the selector looks for that element in the dom with the id. However what I think was happening was that this function ran when the element did not exist.
Not entirely sure tbh but I do know I changed the form definition and it fixed ti
Yeah
The only issue is it does not look as nice
Can you tell which ones are the ones that are working lol
let's see just by looking...
The ugly one's work. The other one does not
Granted it technically isn't even implemented but if it were it would not work
no, I can't tell. They all look good to me.
you may want to put those on 3 separate html files
Lol the left ones are the ugly ones that do not work. The one on the right is what I wanted but does not work.
@cold haven Why?
well, I would put them on separate pages because one isn't related to the other.
I would on submit, submit the form and move on to the next page.
but that's just me
No this is like a import data portal
ahh
oh ok it's a portal
While we are on the topic of all this, Want to give me some feedback on what I have so far?
@cold haven
it's nice, You might want to just create one search by phone number since everyone has a unique number.
then you really wouldn't need to search anything else.
I see where you are coming from but no one really knows everyone's phone numbers
Well no, I mean if someone were to search it is most likely to get their phone number
It is easier to remember a name than the phone number.
oh alright
How about this
the CSS looks nice
Thanks
the first row of CSS looks like it's not aligned on the first page
maybe I would put that in a drop down or hamburger
Which row?
Oh it is centered aligned.
I would try a different UI to search
you could actually put the searching on a sidebar.
that's what most sites do
that would make it look clean
everything else looks pristine
Thanks, I honestly thought about a sidebar. Just my execution of it was bad lol
Could not come up with something that did not look terrible and did not take up too much room
question
Yes?
let me say if I wanted to search a range of employees that work at a company. I could do that?
As in multiple companies?
all the employees that work in one company
Oh yes
I would do a search on a company then
then it would give me a list of all the employees working at that company.
that's cool
Yes the filter company dropdown does just that
@quick cargo @cold haven I'll check into Oath2
Better to learn it now then later, shouldn't take to long for me to get a hang of it
@cold haven On Thursday or Friday I plan to have this deployed and I would like some people to test the site. Would you be willing to be one of my testers?
@cold haven The plan is to have some small instructions on what the site is for and how to do a few things. I will also provide some instructions on how to do certain tasks so you have a starting point. Then there will be an optional survey to take to give me some feedback.
hello
trying to run my app with : gunicorn Appname.wsgi
getting this error :
gunicorn Patent_Trademark_Manager.wsgi.application
[2020-11-03 00:21:01 +0000] [16692] [INFO] Starting gunicorn 20.0.4
[2020-11-03 00:21:01 +0000] [16692] [INFO] Listening at: http://127.0.0.1:8000 (16692)
[2020-11-03 00:21:01 +0000] [16692] [INFO] Using worker: sync
[2020-11-03 00:21:01 +0000] [16695] [INFO] Booting worker with pid: 16695
[2020-11-03 00:21:01 +0000] [16695] [ERROR] Exception in worker process
Traceback (most recent call last):
.....
ModuleNotFoundError: No module named 'Patent_Trademark_Manager'
[2020-11-03 00:21:01 +0000] [16695] [INFO] Worker exiting (pid: 16695)
[2020-11-03 00:21:01 +0000] [16692] [INFO] Shutting down: Master
[2020-11-03 00:21:01 +0000] [16692] [INFO] Reason: Worker failed to boot
I am very confused as to why I am getting this error if I'm only putting in the name of my App.
What am I missing ?
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/media/image/Clothing.jpg
Using the URLconf defined in BolemVenture.urls, Django tried these URL patterns, in this order:
[name='index']
admin/
The current path, media/image/Clothing.jpg, didn't match any of these.```
Storage location is MEDIA_ROOT
but I see that it works the same as STATIC_ROOT it creates a folder in the same location... then what am I missing do I need to classify STATIC_ROOT or MEDIA_ROOT in my setting as I do not see it defined in there
?
does anyone know a good server for questions about HTML/CSS/JS or is it ok to ask here?
@long vale Ask here
I want to include a bunch of text on a webpage, but I can't easily serve it from a text file or something because it's on GitHub Pages... Is there any good way to do it without filling like 99% of my HTML file with text?
I had an idea to do it in a .js file and make a bunch of variables containing strings, then plop them in as needed
But are you using Django @long vale or Flask?
Nope, so I recognise it's not quite on topic
@devout coral why is my image not being accesed? Do I really need to add it into my urls file? For Static files it not necessary
@long vale I mean how would you be gathering this data?
Did you add the routes for static and media for development ?
I'm just gonna type it, because it's a portfolio site
If it's something that you can manually fill in I don't see why it would be a problem to put it in your HTML file, JS is for dynamic content, no reason to place static content in there, as your just going to end up filling the js content with text
@long vale so then you are really not resolving anything
What
Wrong ping mb
A text filled js file would look way worse then a js one
Unless you only wanted them served at a certain time and point which then makes it dynamic
@devout coral will add it
Once you do youβll be good
Ok. I've barely done any HTML before. I have the Python mentality of separating long strings from the logic, but I guess HTML is completely different in many ways
@quick cargo Hmm, but isn't Oath2 a 3rd party package?
is this channel free for a question about DJANGO?
Apologies, Just read the rules and how to get help
This isn't a help channel it's a general help channel
Ask your question @waxen mirage
Context: I have a running API that pulls data from a website and presents it in a template.html in a django web application. This is one application in a broader project and I now need to add the data preseneted in template.html to my database.
Question: where do I need to look in to django documentation to find the process to add this data from the template.html to my database
umm
trying to do this
this portion
filename = secure_filename(f.filename)
f.save(os.path.join(
app.instance_path, 'photos', filename
))
return redirect(url_for('index'))```
f.save(os.path.join( app.instance_path, 'photos', filename ))
and what happens
lmao sry
wormhole
so
@app.route("/uploadusers", methods=["GET", "POST"])
@login_required
def upload_user():
form = UploadForm()
print('hi')
if form.validate_on_submit():
print('hello')
f = form.form.data
print(f)
filename = secure_filename(f.filename)
f.save(os.path.join(os.path.join(app.instance_path), 'update_users', filename))
flash('loaded users')
return redirect(url_for('upload_user'))
return render_template('upload_new_user.xhtml')```
is my views
from flask_wtf import FlaskForm
from flask_uploads import UploadSet, DOCUMENTS
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import SubmitField
document = UploadSet('somestuff', DOCUMENTS)
class UploadForm(FlaskForm):
file = FileField('File', validators=[FileRequired(), FileAllowed([document, 'Only xlsx files!'])])
submit = SubmitField('Submit')
my form
it's not validating on submit
like i get no error, but it doesn not print hello only hi
any ideas?>
nothing appears in my instance file
and it's prib cuz it's not validatin
thanks @devout coral
@swift sky because flask-wtf is an integration if wtforms , i think you can get error(invalid reasons) in your view like so
for fieldName, errorMessages in form.errors.items():
for err in errorMessages:
to check why your form got invalid
uhh stupid question
what do you mean fieldname
@swift sky because flask-wtf is an integration if wtforms , i think you can get error(invalid reasons) in your view like so
for fieldName, errorMessages in form.errors.items(): for err in errorMessages:
@gaunt marlin
and where would i place this for loop
before or after the validation
@swift sky before because you already knew that validation failed
this syntax is kinda weird
@app.route("/uploadusers", methods=["GET", "POST"])
@login_required
def upload_user():
form = UploadForm()
print('hi')
for fieldName, errorMessages in form.errors.items():
for err in errorMessages:
if form.validate_on_submit():
print('hello')
f = form.form.data
print(f)
filename = secure_filename(f.filename)
f.save(os.path.join(os.path.join(app.instance_path), 'update_users', filename))
flash('loaded users')
return redirect(url_for('upload_user'))
return render_template('upload_new_user.xhtml')```
actually you missed the print line
@swift sky
for fieldName, errorMessages in form.errors.items():
for err in errorMessages:
print(err)
so can you explain what you meant by because flask-wtf is an integration if wtforms
oh u mean because it's an integration
you believe you can get the error messages by doing xyz
well yeah it's from their document
Simple integration of Flask and WTForms, including CSRF, file upload, and reCAPTCHA.
you current debug process is :
- you already knew that the validation failed -> now you need to know why the validation failed
the full view
@app.route("/uploadusers", methods=["GET", "POST"])
@login_required
def upload_user():
form = UploadForm()
print('hi')
for fieldName, errorMessages in form.errors.items():
for err in errorMessages:
print(err)
if form.validate_on_submit():
print('hello')
f = form.form.data
print(f)
filename = secure_filename(f.filename)
f.save(os.path.join(os.path.join(app.instance_path), 'update_users', filename))
flash('loaded users')
return redirect(url_for('upload_user'))
return render_template('upload_new_user.xhtml')```
since i can't find any thing related to showing form error in flask-wtf documents
:/
let me look ups more about this package
@swift sky found it https://hackersandslackers.com/flask-wtforms-forms/#building-forms-in-jinja
this is how you display error in your html template
<div class="form-field">{{ form.email.label }} {{ form.email }}
{% if form.email.errors %}
<ul class="errors">
{% for error in form.email.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
wait
let me check
you can test if you want
oh ok its correct
it used flask_wtf
trying
running it now
some syntax stuff 1 sec
1 sec
hmmm
yeah dude but this is for just a fileupload field
hey guyz i want to remove hardcoded urls of id in template
<a class="nav-link" href="#contact">Contact Us</a>
@swift sky the one i posted above just an example for you to implement for your code here what you supposed to write in your templates
<div class="form-field">{{ form.file.label }} {{ form.file }}
{% if form.file.errors %}
<ul class="errors">
{% for error in form.file.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
<div class="form-field">{{ form.submit.label }} {{ form.submit }}
{% if form.submit.errors %}
<ul class="errors">
{% for error in form.submit.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
again this is an example because i haven't see your templates code but this is what it should be
im using flask class based views but in post method it gives error ""TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement."" but im not sure where is wrong because it seems right to me.
class Register(MethodView):
def init(self):
self.form = RegisterForm()
def get(self):
return render_template(
'register.html',
title='Register',
form=self.form
)
def post(self):
if self.form.validate_on_submit():
first_name = form.first_name.data
last_name = form.last_name.data
username = form.username.data
email = form.email.data
password = generate_password_hash(form.password.data)
user = User(first_name=first_name, last_name=last_name, username=username, email=email, password=password)
if form.profile_picture.data:
profile_picture = form.profile_picture.data
filename = secure_filename(profile_picture.filename)
path = os.path.join('C:\Users\Programming\blog\static\profile-pictures', filename)
profile_picture.save(path)
models.session.add(user)
models.session.commit()
return redirect(url_for('login'))
@nimble epoch you have no return on the else statement of
if self.form.validate_on_submit():
then if i do, it wont return wtforms validation errors. i just tried it.
how about using function based views?
or is there any solutions?
Can someone help me with some html and css
https://mystb.in/SummitAllowEfficiently.html
so here why doesn;t it change the header colour and background?
please happen to ping me for an answer
@granite loom # in css is for id attribute, you have class = "main-header" so use .main-header{} instead
glad to help
How can I get empName and Their role from this model
class Employee(models.Model):
empName = models.CharField(max_length=50)
class Role(models.Model):
roleName=models.CharField(max_length=50)
description=models.TextField()
roleReportsTo=models.ForeignKey('self',null=True,on_delete=models.SET_NULL)
class EmployeeRoleMap(models.Model):
empId=models.ForeignKey(Employee,on_delete=models.CASCADE)
roleId=models.ForeignKey(Role,on_delete=models.CASCADE)
I am new to Django that's why I am confused
@static harbor You shouldn't use an intermediary model like you did. There's a field type for M2M relationships (https://docs.djangoproject.com/en/3.1/topics/db/examples/many_to_many/).
I'd create a roles field in Employee of type ManyToManyField and query it directly with my_employee.roles
@balmy stag I need a field like cuz I have to store start_date and termdate for that intermediary job
like he can manager for start_date to end_date
and ceo for start_date to end_date
can you tell how can I quey it?
class EmployeeRoleMap(models.Model):
empId=models.ForeignKey(Employee,on_delete=models.CASCADE)
roleId=models.ForeignKey(Role,on_delete=models.CASCADE)
startDate = models.DateField(default=now)
endDate = models.DateField(null=True, blank = True)
something like this
also that way I will have history of that employee
oh ok, there's an property through where you can set an intermediary model : https://docs.djangoproject.com/en/3.1/ref/models/fields/#django.db.models.ManyToManyField.through. If you want to simply get the roles of an employee you can do my_employee.roles, and if you to get startDate or endDate you can use my_employee.roles.through.objects.all() or my_employee.employeerolemap_set.objects.all()
There's a guide about this here : https://docs.djangoproject.com/en/3.1/topics/db/models/#intermediary-manytomany
@balmy stag can't we join 3 tables on the basis of their id?
You can have a third ForeignKey on your intermediary model and add a UniqueContraint on the three fk to avoid duplicates but I'm not sure if that's what you want to do
Anyone acquainted with django object querys could help me with this? thank you π
I'm trying to make an advanced filter with django objects but I just have no clue of how to do it.
I'll try to explain myself:
I have 2 objects:
Consumptions:
class Consumption(LogsMixin, models.Mo...
i got a ```TypeError: can only concatenate str (not "UploadSet") to str
probably because of this
from flask_wtf import FlaskForm
from flask_uploads import UploadSet, DOCUMENTS
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import SubmitField
document = UploadSet('somestuff', DOCUMENTS)
class UploadForm(FlaskForm):
file = FileField('File', validators=[FileRequired(), FileAllowed([document, 'Only xlsx files!'])])
submit = SubmitField('Submit')```
the article you linked didn't deal with file uploads through flask
Django 3 is too easy llol
What is the data type of the data that is sent through a post request?
Anyone acquainted with django object querys could help me with this? thank you π
https://stackoverflow.com/questions/64662944/django-how-can-i-filter-an-object-filtering-by-another-object-filtered/64663416#64663416
@primal kernel I'd set therelated_nameto "consumptions" inConsumption.clientfield. (https://docs.djangoproject.com/fr/3.1/ref/models/fields/#django.db.models.ForeignKey.related_name) (I've been taught to almost always set it).
Then you can doClient.objects.filter(consumptions__status='pendant', consumptions__access_date__range=(start_date, end_date)).distinct().count()
I'm trying to make an advanced filter with django objects but I just have no clue of how to do it.
I'll try to explain myself:
I have 2 objects:
Consumptions:
class Consumption(LogsMixin, models.Mo...
@primal kernel I'd set the
related_nameto "consumptions" inConsumption.clientfield. (https://docs.djangoproject.com/fr/3.1/ref/models/fields/#django.db.models.ForeignKey.related_name) (I've been taught to almost always set it).
Then you can doClient.objects.filter(consumptions__status='pendant', consumptions__access_date__range=(start_date, end_date)).distinct().count()
@balmy stag YEAH! the distinct is what i was missing! thank you sooo much π
Hello everyone!!
I'm new to web development could you guys suggest the best way to learn web development
I'm sitting home and really want to gain this skill
I didn't try it myself, but this tutorial might be a good starting point https://tutorial.djangogirls.org/en/
The path its pointing to is correct
Thanks:)
Hello #web-development , I am working on a REST API in Flask, now I am on a point where I can post json data, but I want to automatically give every json data post an ID, currently I need to give them by hand an ID.. Is there any logical way to automatically give everytime a post an ID? Thanks in advance.
can I rename the values that I need
for example i.values("id","some_long_name")
this will give json response like
{
"id":1,
"some_long_name":data
}
I want some_long_name to be renamed AS i wasnt
@wanton tulip are you saving in a database?
No I am not. Otherwise I could use auto increment. Sorry for not adding @static harbor
would you recommend saving it in a DB @static harbor ? Like, how are all the bigger REST API's doing this with JSON data? I have been searching on the internet, but a lot don't use an ID.
@wanton tulip yes definetly save it in DB, because if you
're creating an rest api you need data to save and then post it when needed
what do you do with your data if you aren't saving it in a db
if I send your API data where do you store it? If I request data, where do you pull it from?
Hi, I want to deploy my django app on namecheap cpanel. Please help me to learn how to deploy my djanog app
Please
Hello, can you limit the size of an image in django rest framework without uploading the whole file?
Thanks @static harbor for your reaction, it's helpful.
hello
Hello!
How can I have nested data inside my view but not in the serializer in django rest framework? (to reduce db queries).. I have this:```class UserDataSerializer(serializers.ModelSerializer):
transactions = serializers.SerializerMethodField()
class Meta:
model = User
exclude = ('password',)
def get_transactions(self, obj):
request = self.context['request']
transaction_objs = Transaction.objects.filter(user=request.user)[0:35]
return TransactionSerializer(transaction_objs, many=True).data```Transactions model: ```class Transaction(models.Model):
user = models.ForeignKey(User, related_name='transactions', on_delete=models.DO_NOTHING)
//other fields...``` but of course is querying multiple times, I want to use prefetch_related an select_related with all my foreign/manytomany fields is this possible?
Anyone here ever used Sphinx for documentation of a django project?
How I link my django app with cpanel postgresql?
What's easier to setup and use, uWSGI or Gunicorn?
Like Iβm using namecheap to up my django app so how I connect postgres with it?
Hey everyone! Could someone explain what does means and how it use.
STATICFILES_DIRS = [
# ...
("PREFIX", "staticfiles"),
]```
**Prefixes (optional)**
I've tried use how it said in Django documentation. but it hasn't any difference.
As i understand that should create extra folder inside STATIC_ROOT directory as 'PREFIX' but it doesn't
Where do i wrong?
Thanks
@grizzled sand What this basically does is tell Django where any other static directories are. So as the Django documentation states you can do something like:
STATICFILES_DIRS = [
"/home/special.polls.com/polls/static",
"/home/polls.com/polls/static",
"/opt/webfiles/common",
]
Which will tell dajngo that you have some static directories at those locations for when you run the collectstatic command those can be included. If you want additional organization you can provide a prefix for all these files. Following the previous example if I did.
STATICFILES_DIRS = [
("downloads", "/opt/webfiles/stats"),
]
Once you run collectstatic it will put all the files inside of that stats directory into static but now it will put it in a directory called downloads.
Does this all make sense?
hello
Hello!
Got a simple question
I'm using Flask
See when you click on a link and then automatically a jpg file starts downloading?
How do I do that?
I want to learn Django
Thank you very much beforehand :)
does anyone know how to create a pipeline to write to a file in Django?
@devout coral
Yeah but in my case when I try use prefix, it doesn't create any sub directory like downloads in example.
Django just collect all into one folder
@grizzled sand Interesting. Can I see the settings you have
Also, if you do not mind your directory tree for the project.
Good Evening
Hi, anyone know if there's a simple way to handle this scenario in django... let's say model A needs to also have 3 + of model B pointing to model A before users can take some action. model form is great but it doesn't allow this behavior, from what I understand.
OneToManyFields
Or you can make the Model B have a foreignKey to the Model A and make.it run a query to check if there are any pointing at Model A before running any
I think I understand how that is supposed to work, but I don't know how to make them one combined form on creation
@devout coral okay it was my foul i didn't set sub dir for path.
Extra places for collectstatic to find static files.
STATICFILES_DIRS = [
("my_app1", os.path.join(BASE_DIR, 'my_app1/static')),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
But anyway with this settings I am getting two copy of my static files from my_app1, one in root 'staticfiles' folder and second one in 'staticfiles/my_app1/'
So as i understand prefixes doesn't work properly with static folded my_ app?
Sorry already off system, but tree someting like that.
project/
-my_app/static/css
-django_project/settings.py
-staticfiles
@grizzled sand so everything is good now right?
I guess my question is, can I have say, modelA form and 3x modelB forms at the same time, and submit them all as one post?
(still django)
hi @night spoke. If I know anything about this. I would say it is best to bind a specific form to one database query.
I would separate them into different objects
or components
that's what i'd like to do, some sort of post containing form A, and 3 form B's, but I don't really know if django has some easy way of doing that
I don't know because I have never used Django's built in ORM
I would like to learn more on this too.
Sounds like you want to run a one to many or many to many query
you can do it in the Django built-in ORM i'm sure.
For now, I can certainly perform these actions independent of each other.
anyone knowing docker, i am trying to understand the COPY command in the dockerfile.
if the root folder of my app is backend, and I want to copy the contents into the container, I can just do COPY backend conatinerFolderName?
I thought Django sets up a coding environment by default so that Docker isn't even needed
hold up, I'm wrong --- EDITED
I had it backwards. By default it just copies contents. So you're correct, you just do COPY backend containerFolderName and the contents of your local backend folder will be copied to the container.
Sorry, had rsync on my mind and I've forgotten way too many / and had it not do what I was expecting.
