#web-development
2 messages Β· Page 73 of 1
I have just started to learn programming...
can someone help me with giving me information about the job market
is that possible to find a remote or freelance job in another country ?'
is this the right channel for this type of help ?
so i have a website and discord bot using the same database, and lets say i want the discord bot to cache anytime it gets or updates a document in the db. How do I make it so whenever the website makes changes to the db, it update's the bot's cache as well? Btw the bot's cache is currently bot.db.guilds_info (a dictionary). The database I'm using is MongoDB.
not really 100% web dev related but i think it fits more to this channel than #discord-bots
So you have an API right?
how does that fix the issue tho
the bot has to query the website not the other way around
right
i want it so when the website changes something it lets the bot know
So it uses an API
Oh
So you can check every like 5 seconds or 1 minute?
Like requests.get or urllib
your website and bot should share the cache and whenever the API gets new data, it should bust the cache so the bot has to get the new data
also btw the reason im caching stuff in the bot is so i don't have to request the DB on every message that someone sends
Basically what rdbaker said
how would it share the cache if they're run separately
i mean they're already shared in mongodb
but i just don't want to request mongodb on every single message
You need somekind of mechanism of invalidating the bots cache
can someone help me check if my flask website login/registration works? I just deployed it to heroku... U can use fake logins if u want
For whenever the website updates the db
its a simple QnA website
So you want to update it on message and not sending a request when EVERY message comes?
@distant trout Can't you test it? Like a logout functionality or so?
nothings being updated on_message, only fetched
Oh I see
but the problem is when the website updates the database, the bot's cache is outdated, but the bot doesnt know that
Yea, some kind of signaling would be ideal
A shared cache would be the simplest solution
@distant trout Yep. Until you hold your data in flask session . Or if you are using flask_login then I'll assure you it'll work
Yeah, i am using flask-login π
Then it must work . Or it'll give an error or something
And you can view if it gave an error by running heroku logs --tail
If you didn't know
Yeah, it hasnt given me any error. Everything seems to be working fine
I had problem with gunicorn at first but now its fixed
π awesome, thanks
XD I didn't do anything lol
u just reassured me π
XD lol
but the problem is when the website updates the database, the bot's cache is outdated, but the bot doesnt know that
@brave karma perhaps set a short countdown on cache invalidation
Depends how often the db is updated
yeah that seems like the "best" solution i could think of
Definitely the simplest
I'd say some from of Redis cache the bot checks
when website updates, it just updates Redis cache
and Redis cache could be a simple as <user>:<true/false> for been updated
alternatively, you could skip using a cache at all, databases are generally made for fast reads and cacheing should be used as a strategy when it's expensive to read from the db
Im gueesing hes using a cache for a reason though
sure, everybody uses a cache for a reason- @brave karma have you seen such a hit in performance that you'd be nervous using your both without a cache? What's the 99th percentile API response time?
Then again, a production cache like redis will do you better
generally all databases do, but yeah, I'm pretty sure mongo allows you to specify caching the results of a query
not atm i dont think, just thinking long-term :p
Has anyone here made a website using file manager in cpanel?
implementing and managing a cache is usually expensive enough that it's not needed until it's really needed (e.g. 1s response times from the API)
True ^
true
and by "expensive" I mean having the think of and implement caching strategy problems that you're currently asking about
if anything ill just make cache disappear once or twice a minute or something , definitely not anything too long
ill think about it
sometimes it's worth learning new just for fun even if it's not required
I already got my webasite lmao
I didn't even need help since the website already worked
I just didn't type www
Look at the favicon and name
haha, I figured, thought I'd make sure though
Idk if this is because you are still working on it, but none of the styling/images/etc are there
also: I need like 33% of a circle 3d modeled at like 3mm for 3d print, how much? haha
Also, last comment: I see someone made the blender guru donut π
Anyone got the js discord invite, if so dm me, its for a friend π
@acoustic oyster Yea I'ma modeler
Hello,
I am working on creating a backend script for social media blog letter(like news letter) and email it to myself daily.
I want to gather top 10 or 20 posts I see in my Overview section of Reddit and send email them to myself. I am working with Praw (Reddit API). I tried to find some function or method which will give me these overviews. However I didn't find anything. I checked dir(redditor(username)) or dir(user.me()) to see if anything works but didn't find it.
Does anyone know how I can get this working?
Thank you
I need to write a fairly long html code inside inside a var, in javascript. When I hit enter inside the quotes they return a syntax error when I run the code.
Example:
var item = '
<div id="data-row-${i}" class="task-wrapper flex-wrapper"><div style="flex:7">
<span class="title">${list[i].title}</span>
</div>
<div style="flex:1">
<button class="btn btn-sm btn-outline-info edit">Edit </button>
</div>
<div style="flex:1">
<button class="btn btn-sm btn-outline-dark delete">-</button>
</div>
</div>
'
Returns a syntax error because I entered a newline. How do I fix this?
Im using atom as my text editor
hi i have a question about wtforms. this doesn't work: (i'll send the form code in the next message)
what am i doing wrong?
hey everyone
I just wanted to ask that is it better to use django than using flask to make websites in python
well I don't know anything about django
I just asked my buddy who's into web dev and he said he used flask when he started and then transitioned to django
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:sqllite?
I just asked my buddy who's into web dev and he said he used flask when he started and then transitioned to django
@faint dew ohk thanks bro
Why is my django stuck on watching for file changes with statreloader?
@azure saddle you can check out the django official tutorial on the website, to see if you like it.
How are you running it?
@native tide check out jsonwebtoken. It's for JS, but you'll find something similar for flask
How are you running it?
@atomic marsh what??
That was for mechonis, @azure saddle
ohkkk
I hope this is the place for Django questions. Suppose I make a model, migrate it and then add data to it using shell. I then change column names/data types and migrate again. When use the shell again I get an error saying that the data previously there doesnt follow the new schema changes. What's the best way to deal with this?
Should we drop the entire table and start over?
I changed column type from charField to IntegerField
if you don't have any important data, you could just drop the table and repeat the migrations
but of course, the problems of the world are usually not this easily solvable
you could for example, add another column, runing a data migration to iterate over all objects, and write to the new column, and then finaly delete the old column
to be honest, im not sure what the preffered method is
what error does it bring up
@azure saddle The bigger the project gets , the better fask is
Since it has much more flexiblity
And Django is black magic
disagree tbh
If you want to get a job or freelance , use Django
flask is perfect for small/mid sized projects
But when the project gets big , it's better to use Flask
Why?
Cause
Flask has much more flexiblity than django
And you understand your code
But
Django has much more less flexiblity
And you don't understand your code deeply
anything you need to do, you can do tbh
But Flexiblity is where flask shines
But you don't want to write black magic code either
"black magic code"?
The code you don't understand ... basically Django
Like you don't understand your code deeply
And that means you have to review your code every once in a while so you can just get what it does (when the site gets big)
as the complexity grows, you won't even remember half the code anyway
abstraction is good
django is tried and tested, you don't need to understand how the low level bits work, to make a good project
I said , Flask is better for YOUR projects and websites made by a group (even big), but django is good if you want a job in a company or freelance
We are all biased , it's undeniable
Use everything you are comfortable with
I am comfortable with Flask , and I use Flask . You are comfortable using Django , and you use Django
I mean , I learned Django first , then I went to Flask
you can say that, but specific tools fit with specific tasks, some better then others
You can make same websites using both , can't you?
you can make websites with C if you want to
They have all features you'll need . Either with libraries , or by themselves
I myself , enjoy using Flask more . I like to understand all my code . And Django is just opposite of what I like/need
Maybe if I was to freelance , I woulde use Django
But if it was gonna be my website
I'd rather Flask
fair enough
well thanks @glass sandal and @flint breach for now I'll go with flask as my project is not much big
Hi everyone, I'm currently having a small problem with bs4. I'm trying to extract the text from a span but it has parenthesis around it and it seems to be an issue.
here is the html code:
<div class="matchTeamScore">
<span class="currentMapScore" data-livescore-current-map-score="" data-livescore-team="10371"></span>
<span class="mapScore"> (
<span data-livescore-maps-won-for="" data-livescore-team="10371">0</span>)
</span>
</div>
here is my python code :
.find('div', {"class": "matchTeamScore"}).find('span', {"class": "mapScore"}).find("span").text
the result is just an empty string (i want to get the 0...)
because there's another span inside that span
soup.find('div', {'class': 'matchTeamScore'}).findAll('span')[1]
of course, the specific case of geting the first nested span would be prefered
it works thx @flint breach
How do I get a flask response to return a json?
endpoints = {
"up": "/up"
}
@app.route('/', methods=["GET", "PUT", "POST", "DELETE"])
def home():
if request.method == "GET":
return Response(endpoints, status=200, mimetype='application/json')
@neon needle I can π
@foggy geyser
Come dm pls
flask probably has some sort of
JSONResponse object
or straight up, json.dumps() the dict and modify the mimetype
got it working with json.dumps() thx
it is my first dabble with API's and web development
Hello guys,
I have made a Flask web app which runs fine locally, but it doesn't work on Heroku. On heroku, it says "NameError: APIservice not defined".
APIservice gets defined in the 'start' view:
@app.route('/start')
def start_teatime(): # Checks auth & builds calendar API (APIservice)
print('stat_teatime trigger')
global APIservice
if 'credentials' not in session:
return redirect('authorize')
# Load credentials from the session.
credentials = google.oauth2.credentials.Credentials(
**session['credentials'])
APIservice = googleapiclient.discovery.build(
API_SERVICE_NAME, API_VERSION, credentials=credentials)
return redirect(url_for('user_input'))
On the user_input view, APIservice is used. Locally, this works fine. On heroku, it throws a NameError and claims APIservice is not defined.
Does anyone have an idea why this is happening?
I found a workaround. I just put all the code above in the user_input, since it wasn't used in the start view anyway
or well, I say that
but it now throws the same error in another part of the script
Why is heroku resetting the APIservice variable...
Cause heroku resets your app every day
And if you want to save something , it has to be either in the database , or in a file
OR as an envronment variable
Like it re-runs it
wdym by blocks of code?
Oh
like :
print("this?")
Do a ```
ββββββ `py
and close with ```
` ` `
ok so i have a question related to models in django
aaa ok ask
so I have this app called " hr_user" it already has its views func to create a new user and all that. And i have a model name Employee. How do I create an employee object under the user that is logged in?
models.py ```py
class Employee(models.Model):
#attributes
hr_agency_emp = models.ForeignKey(User, # this will reference the employees created under the hr company
on_delete=models.CASCADE, # so confusion can be avoided at login.
)
name = models.CharField(max_length=20)
age = models.CharField(max_length=2)
department = models.CharField(max_length=25)
mail = models.CharField(max_length=50)
date_posted = models.DateTimeField(default=timezone.now)
employe_id = models.IntegerField()
class Meta:
verbose_name = 'employee'
verbose_name_plural = 'employees'
def __str__(self):
return self.name
```
views.py ```py
Create your views here.
@login_required
def dashboard(request):
context = {}
employee = Employee.objects.all()
context['employee'] = employee # once the hr user log in, the hr user
# will be able to see the employees on the DB
return render( request, 'user_hr/dashboard.html', context)
def logout_view(request):
logout(request)
return redirect("login")
def register(request):
if request.method == "GET":
context = { 'form' : UserRegistrationForm }
return render(request, "registration/register.html", context)
elif request.method == "POST":
form = UserRegistrationForm(request.POST)
if form.is_valid():
user = form.save() #save/create user in the database
user = form.cleaned_data.get('username')
messages.success(request, f'Account created for {user}!')
# if user was created successfully then,
return redirect('login') # take client to the loginpage
hey i am new to kivy-python , so can any one guide me...please dm as it would be make a lot easier for me to create my first app
so i tried making migration and this popped up: Please select a fix:
- Provide a one-off default now (will be set on all existing rows with a null value for this column)
- Quit, and let me add a default in models.py
you added a column which was not allowed null and django needs to figure out what to add to that column for existing rows
oh i see, how do i fix it?
im gonna go ahead and select one, tbh i dont know what the heck im doing
hey all, i'm using flask to process data from a post request from ajax in JS script, how do i process lists?
i'm sending the list like this:
weblogs: automodWeblogs where automodWeblogs is an array of JSON objects (because this is in the JS code)
i'm processing the data sent by using request.form but i've also tried request.form.to_dict().
Whenever I print out the data i receive, it prints in a form like this:
'weblogs[0][user]': ['MrHouck#6969'], 'weblogs[0][time]': ['Sat, 25 Jul 2020 17:36:29 '], 'weblogs[0][action]': ['automod.bannedWord.remove'], 'weblogs[1][user]': ['MrHouck#6969'], 'weblogs[1][time]': ['Sat, 25 Jul 2020 17:36:29 '], 'weblogs[1][action]': ['automod.bannedWord.remove']
How do I fix this?
@obtuse garden This channel is not suited for that topic
Hello, so I am using django to make a website for my client. And I am pretty new to Django, so I wanted to ask a question. My website is getting a date.now and converting it into hours and saving it on the Postgres database. I would like to make a sum of those numbers and then send it back to the database. And I wanted to ask about in which file I should put the python code that I will be making. Thank you for your help guys.
So that's like a main file for the type of code I am making right now?
@glass sandal
Django and flask work like this :
When client enters a URL , a specific Python code will run . And it could return templates/HTML files which are website pages if you are not familiar
And views.py is where you make the functions you want to run when someone enters a specific URL
But keep that in mind : Url's should be defined in urls.py
And if you have an app , then you'll need to make one for it
Oh, so I will have to have an app for each functionality and then I can link the button to a certain url which will then run the function.
Just go through the documentation or Youtube tutorial
Oh
And apps are basically mini-projects
Like when you create a project , you'll have an app by default
And that's your app then
I have two apps, the default one and another one I made.
But you can do everything in one app
Unless your project gets big
And you want to organize it
Then you'll better have an app for accounting (signup , signin) , pages (blog , tutorial etc.) and...
But I myself do all in one app
Ah, that's cool.
Could you please show me how the function linking works, so I can make sure I know how to do it.
As this is my first project alone without anyone else looking and giving me help.
I have it I think.
And urlpatterns is where are your urls will be defined
In an array
And if you wanna add new urls , first make sure you imported path from django.urls
Then add a line like this :
urlpatterns = [
path("urlPath/",functionToRun)
]
And there is an optional name key argument
That I never ue
I already have this done
That's to html I think.
using django.shortcut's render
return render("file.html")
and you must've defined your template's path in settings.py or it will give an error
Okay, I will keep that in mind.
And if someone presses a button on a website, which will send the data to the website. It's like a login form and you will be adding the users through the django admin area.
And if it posts the data , you need to add a {% csrf_token %} line in form tho
And it will log the time when they submitted it.
Yeah, that's for security I think.
Yep
I am not quite sure how to like link the code that is getting those two times and calculating the amount of hours they were in office from it.
I have the python code nearly done outside of django.
As I am still awaiting html from a colleague.
Could you send me an example on how to apply it (just an example.) I would really appreciate it.
Ummm i mean like :
#this is a code not in django
user_logged_in = False
if signed_in and username == username_entered:
user_logged_in = True
time_logged_in = time
#So now you want to apply this in Django :
#Views.py
def login(req):
if req.user.is_authenticated:
User.objects.filter(username=req.POST['username']).time = time #Replace this with current time
#Urls.py
urlpatterns = [
path("login/",views.login)
]
Wow
It's completely different code ;D
XD maybe
But this is the case with the default user login system with django
And it does not have a time attribute
So you have to make a login check with your model
And it's not that tricky
You just need to check the session
I was thinking that it would be cool to track the time of when the button was pressed
Because now what we're thinking is that we would let our employees enter their id, and they will simply press a button
and the time would send automatically, or we can have them click it themselves.
But I would put that on the front-end, not the django admin area.
That can be used by managers to see how many hours each employee had.
I already have the models ready.
Yeah
So when your friend sends them , you'll be done
You mean changing an object?
And np
You have to object.save()
After you edit attributes
Object.save and pass out a value?
do you need to pass the name of the object
You have to find the object
Model.objects.filter(username="Something")
will find an object with a username something
Is it all listed on the django project website, so I can check some more details if I am not sure?
And np
So if I understand correctly
can we make a user login using an id.
without password
So we can do an error message if that happens using an if statement.
Yeah
Thank you so much for your help, I really appreciate it π I will go take a look at the documentation to get a better understanding.
Ah np
Have a great day!
I think I can do it, as I was making C# apps before. This is just a bit different π
Oh I see
different language and different environment.
XD yeah
But thank you really.
Nah np
I myself struggled while I was learning Django
And you know , you have experience on C# . Back then I only knew C++ and JS and Python
And you are not struggling so much as I see . And it's great
GL on your journey th
tho*
Oh, thanks π
I appreciate the feedback and your help again.
Good luck on your journey as well!
Thanks! And why are you thanking so much? That's a nice of you tho! Like everyone I help thanks me once , and I don't have problem with that tho
I am just so grateful that you helped me out.
As I was struggling today.
Trying to figure it out.
Oh np
I'm getting this error when I try to run my code, how do I fix it?
This is the code btw
how do I fix that?
You don't have that html file
i dont know Django's template layout :/ but i imagine you dont have the file in the right place
Or your settings.py has problems
Did you define your templates folder in settings.py?
@olive egret
no
I'll do that
For djangos template system when using a variable when do you use a . and when do use a | when trying to access properties of that variable
e.g. {{name.count}} to get the length of the name , {{job|pluralize:",s"}} to add a nothing or an s when there is more than one job
@glass sandal no it didn't work
hi all, what would be a better content-type (considering both would work) to post object with text fields, image and array of objects, application/json and raw data or multipart/form-data? Or maybe something else?
atm I'm using multipart/form-data and parser_classes = (MultiPartParser, FormParser) in my viewset and while it uploads data and image fine I can't upload the array of objects
evenin' all! i'm attempting to create a login page for a CMS i'm making and i'm having trouble understanding how to pull a hash from the db, and compare it to the pw input by the user from the login form. can't seem to wrap my head around the step by step in pulling the hash out, comparing it to the input, and then saying yes/no for logging in based on if it's correct or not. using py3.8, tornado and argon2id. if i should add more to my question, pls let me know. c:
you hash the pw entered by the user using the same hashing algorithm as the hash you have stored in the db was generated with
if the two hashes match the pw is correct @native tide
ah i see, that makes sense! i'll give that a shot, thank you!!~
@olive egret
create a new folder
name it whatever
and in your settings.py in the dirs
put ['name of what the folder is']
@stray sorrel you're going to have to learn models and forms for django
I already learned how models work, I was just making sure I understand the topic correctly π
What is the best way to Limit what kind of url goes into a URLField? Like I only want Spotify playlist urls to be allowed. Would I use regex and create my own validator or would i look for certain keywords when saving the model?
hello i try to run server in one of my projects and command in terminal runs fine but it doesn' execute anything
Hi everyone, what has been the most comport css framework for you when you worked with templates ?
im trying to do somethink cool with my life and not be depresd like some peapole with jobs that they work for and i wanna find someone that cloud like invest some money and we cloud make a buisness and like i would work for free cuaze im young and i stzarted to do somethink soo i started like this:
-first i started game development with c# for a month but then i quit becauze i didnt like it
-second i did Html,Css,Java script
-then i did python and now im doing Copywriting
thats perfect for selling and online sellling and yeah
hey guys is it bad practice to serve static files in a docker continer for django?
ehhh yes and no
you shouldnt be serving static files from a python http server
thats the job for the Production server like Nginx todo to relieve load
How come you shouldn't?
load
Python is pretty slow when it comes to http server speed
and if you imagine each page has a set of static files each request can easily turn into 5 or more static file calls
which will just eat your server up
ahh interesting
do you know why it is slow?
but it is okay with dynamic pages? or it just doesn't matter as much?
its just because Python is interpreted
It is always going to be slower than Compiled langs
yeah fair enough
so what would you reccomend I do?
upload them to a CDN?
or have a static file nginx container?
you normally serve static files with Nginx or apache or what ever prod server youre using to deploy with
but yea in general what ^ said, delegate the handling to some other entity
either a proxy like apache/nginx or to a cdn
so don't use whitenoise?
it looks nice and easy π
the most painful bit of this is
(whitenoise) Itβs designed to work nicely with a CDN for high-traffic sites so you donβt have to sacrifice performance to benefit from simplicity.
collectstatic is just one command, specially in a CI isn't really a hassle, is it?
well when do I run it?
make sure I run it every time I push with some githook?
painful
ask the CI to write the output to github?
how is it painful, it's automized?
bit messy
you can run it before starting the server, it is really fast when it has to do no changes
but the server and the nginx container are seperate
one Dockerfile runs manage.py the other nginx I just need to connect a volume
FROM python:3.8-slim
COPY . .
RUN pip install -r requirements.txt
RUN apt update && apt install -y curl
HEALTHCHECK CMD curl --fail http://localhost:8000/ || exit 1
CMD [ "python", "./manage.py", "runserver", "0.0.0.0:8000"]
I just have this currently
docker compose the badboy
btw do not use the development server as a actual server
that development server should never be used for serving files to actual users
gunicorn or alike are recommended
yeah
was worried this was going to bite me in the ass
okay so what should I be doing sorry?
and why is this bad?
because it's not meant for being used in production
it has little secuirty and optimisations
security and performance wise
the development server shipped with django itself
runserver launches an instance of a django development server
not meant to be used in production
look into gunicorn, or some other wsgi compliant server
okay sweet thank you
do you have any good tutorials?
man this is brilliant
literally answered everything we talked about
the trick seems to run collectstatic in the django container
and then create a volume to that static folder that is also a volume to the nginx container!
basically you have to share the collected files with the proxy yea
You have a ci, just run it in that step for production
Thats why you keep 2 enviorments (or more), one where you develop and test things out using the local server, where changes are made fast yet not meant for production, and a production enviorment
Imagine I have a user who is in the group "free" I wanna make a condition that checks if the user is "free" he sees in the home page "upgrade to premium" but if he's premium he doesn't see it
so basically you just need a simple check if he exists in the group
he exists in the group because when he signs up he will directly be in the group free
group_members = Group.objects.get(name="free").user_set.all()
and then if
if user in group_members show premium etc
thanks, I'll try
basically you just need to get the group you want, get the members of that group, and check if the group contains him as a member
perhaps not the most efficient though
if user.groups.filter(name=['free']).exists()user.groups.filter(name='free').exists() perhaps something like this, so you don't check for all members
thanks
got it
how long have you been using django
in the name=['free'] why do we put brackets
I mean these []
is it because we can put a list and it will filter them
parodn, it's without square brackets
you can put user.groups.filter(name__in=['free', 'some_other_group']) that works like that though which is basically
groups = ['group1', 'group2']
for group in member.groups:
if group in groups:
...
i've been using django for about a year now
still preety clueless, don't worry, django is massive π
thank you
can you further elaborate? stick what?
the end of the button
i used the background-color thing
and it spans to the whole website
so what should i do
======fixed========
has someone hosted flask app on a custom domain using Apache ?
can u show me the steps
that i cannot do, i got a ton of help myself and remember little 
kk
hey guys has anyone setup opentelemetry with django?
has someone hosted flask app on a custom domain using Apache ?
@mortal socket Please, use Heroku.
can you please guys tell me what the difference between authenticate and login
and what happens when we login a user without authenticating him
@mortal socket Please, use Heroku.
@left jungle "how do to A" - "Use B" π³
Heroku isnt even the same thing
like
Heroku is just a free host
not a actually deployment
To sucesfully login, you have to authenticate the user
authenticating means prooving you are who you say you are
if you don't authenticate your users, anyone can claim they are someone, without prooving they are
@mortal socket https://www.youtube.com/watch?v=goToXTC96Co
In this Python Flask Tutorial, we will be learning how to deploy our application to a Linux Server from scratch using Linode.
If you would like $20 of free credit towards a Linode account, then you can use my link here to sign up:
https://linode.com/coreyschafer
We will be ...
at that point, don't even use user profiles
if you're using django, authentication is built into the framework π
got an idea, still don't get it, anyway, thanks
basically, a login attempt is basically just a delivery of username&password from client to server
the server attempts to authenticate the user based on the credentials the client has sent
if the login attempt succedes (the username is found, the password is hashed and checked for equality with the one in the database, and if the check succeeds - maybe a bit more complicated but that's the jist of it) the client is authenticated. if it doesn't, the server sends back some kind of message that the authentication has failed, and that's where you need to input your credentials again, or recover a forgoten password or whatever
once you succesfully authenticate you usually get some sort of session/cookie being sent back to the client, where he sends said cookie in all upcoming requests to the server, implying to the server that they have sucesfully authenticated in the past
did that help?
feel free to ping me here if you don't quite get it
once it sinks in, it stays π
if you're interested in more, IAAA (identifcation, authentication, authorization, accountability)
If I want to deploy my Flask app to Heroku do I need to commit my .env file to Git?
It contains my secret_key as well as my email and password....
sensitive data should not be commited to version control
Exactly, but how can I deploy to Heroku then?
I'm following a tutorial from this guy but he commited his .env file to Git...
An easy way to deploy your Flask apps is by using Heroku. In this I show how to deploy your Flask app to Heroku and how to add a Postgres database on Heroku for your Flask app.
Get the code here: https://prettyprinted.com/l/DmA
Join my free course on the basics of Flask-SQLA...
basically you enter your env variables, secret keys and such, where only the vm or container where you run your app will have access to them
yea
Ahhh makes sense thank you!
And if I want to create an admin user
Do I have to change the code to create an admin user, commit that, then create an account, then change the code back to a normal user, then commit again?
you're using django?
Flask
aha, then im unsure, but you shouldn't need to hardcode any username/password
Okay!
Also one last question sorry - I'm using dotenv and its load_dotenv() with os.getenv() to load environment variables, but is that okay? Will Heroku be able to use the Config vars I inputted in the settings instead?
yea, it should be fine
heroku on container setup will inject the enviorment variables into the container
where in your code, you will be able to retrieve them
concerning the superuser question
in django you would something like this
heroku run python manage.py createsuperuser```
perhaps a flask equvilent shell command exists?
unfortunately not versed in flask so i can't tell you more
Okay, I will look into that, thank you
goodluck!
hey guys I am getting a 500 behind wsgi for django
bt it isn't logging anything
to the console
if I had in debug it would throw a stack trace
how should I handle this?
just when you setup wsgi, before it worked?
sorry
I don't mean the whole of my app is now throwing 500s
I just mean when it does
I want gunicorn to log it to console
/django
so basically you're using gunicorn now, and it doesn't log into the console like the regular development server did?
What does bs4 mean here?
bootstrap4
;P
looks like this
how could i send this text to below the image and the form below the text
when the screen is small?
is there anyone who is really good in JS and HTML??
if you work with node for too long I think I start considering "no" for js
Ask your question
me?
well I need to built a website login page that takes just the username and then puts that user into a random page
gud evening gentlemen,hope you r doing fine,I have a question that I did some research on but failed to find accurate resources,I'm creating a following system,and I was wondering whether I should cache the followers and followings for each user(if possible) or would it be just sent whenever the front-end needs it?
Basically you wanna avoid the n+1 problem
@flint breach i'll read more about it,thank you!
Anyone here willing to lend me some quick help with React? Their discord is not as awesome as this one xD
lolol
im trying to run my slenium code on a VM,chromedriver gives the error:Getting Default Adapter failed. i tried gecko it faied:gecko unexpectedly exited
im on a vm hosted on aws
its a windows vm
Hey guys, new here. I want to ask does anyone have experience deploying a django app with dokku http://dokku.viewdocs.io/dokku/ ? is it worth learning? does it help make ops easier? what are the performance implications? thanks!
i have the proper versions @acoustic oyster
Sorry, I cant be much help, I just know that was a re-occurring error I had.
well @green snow maybe you have downloaded the wrong version of chromdriver or maybe the version of chrome you are using is so new that it is not supporting chromedriver
well i launched my instance yesterday
and downloaded chrome yesterday itself
i got the apprpriate driver
that suits chrome version but no luck
what about gecko?
ok ill wait
exactly
ohk
Have you setup GeckoDriver properly? You need to provide the GeckoDriver location in System properties, as well as Firefox binary if you are using the latest versions.
Please check out this article for setup. The code snippets are in Java though.
http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
stacks overflow is helpfull for that
i had simply downloaded gecko,and put it in desktop
give the exact path for it
the thing is all this worked perfectly on my home pc
like you give in chromedriver
i didnt have to give a pth or somehin
i never gave any path on any of them in my home pc
ya ill share my code
gimme a sec
ohk np
Hey @green snow!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
β’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
β’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
i donno its not allowing txt file,this does?
well I think the problem is with just the driver and all yes?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import pyautogui
chrome_options = webdriver.ChromeOptions()
prefs = {"profile.default_content_setting_values.notifications" : 2}
chrome_options.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.implicitly_wait(45)
driver.get('https://accounts.google.com/AccountChooser/signinchooser?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&flowName=GlifWebSignIn&flowEntry=AccountChooser%27)
account=driver.find_element_by_xpath('//[@id="identifierId"]').send_keys('')
nextbutton=driver.find_element_by_xpath('//[@id="identifierNext"]/div/button/div[2]').click()
pswd=driver.find_element_by_xpath('//[@id="password"]/div[1]/div/div[1]/input').send_keys('')
nextbutton2=driver.find_element_by_xpath('//[@id="passwordNext"]/div/button/div[2]').click()
time.sleep(15)
meet=driver.find_element_by_xpath('//[@id=":jx"]/div/div[2]/span/a').click()
'''schedule meet'''
meetcode=driver.find_element_by_css_selector('body > div.Kj-JD.YY > div.Kj-JD-Jz > input').send_keys('')
joinbutton=driver.find_element_by_css_selector('body > div.Kj-JD.YY > div.Kj-JD-Jl > button').click()
allhandle=driver.window_handles
size=len(allhandle)
parent=driver.current_window_handle
for x in range(size):
if allhandle[x] != parent:
driver.switch_to.window(allhandle[x])
dismiss=driver.find_element_by_css_selector('#yDmH0d > div.llhEMd.iWO5td > div > div.g3VIld.vdySc.pMgRYb.Up8vH.J9Nfi.iWO5td > div.XfpsVe.J9fJmf > div > span > span')
dismiss.click()
time.sleep(2)
pyautogui.press('esc')
joindir=driver.find_element_by_xpath('//[@id="yDmH0d"]/c-wiz/div/div/div[4]/div[3]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div[1]/span/span')
joindir.click()
time.sleep(50)
driver.close()
on home pc:i installed choclatey then chromedriver,then ran da code,all good
and gecko i downloaded directly and ran alllgood
yep
lemme see
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH
@green snow
now
that part of the code was added to close a chrome notification
so I gave my own path
and it worked
obviously no password and email so it just opened the chromedriver and stoped
could hahe donv directly,driver=webdriver.chrome()
where exactly should i paste in the code which i sent to you
but there is one thing i forgot to mention
anywhere
excuse me for this
when i run the code it works till it signs into the google account
yeh
it stops when it searches the join meet button
mine too
nono u didnt get it
where is join meet button?
chromedriver actually works till there it doesnt gve any error till there]
well
meet=driver.find_element_by_xpath('//[@id=":jx"]/div/div[2]/span/a').click()
no
see
think of it like this
you know when you run the code onn the driver window it says devtools listeniing
which means allgood ,this works till signing in
and when after that it throws the error bluetooth port...
now if it was element error it wuld have shown like that
kk
not this complex
ya
this driver problem was first encountered on aws vm
on home pc this line was sufficient
driver = webdriver.Chrome()
no need for those 3 lines,whihc were added to block notifications
ohk
well @green snow it won't work for chromedriver
im ok with gecko
ohk
aslong as my automation work
well try this
from selenium import webdriver
import time
email = 'email'
password = 'password'
driver = webdriver.Chrome('C:\\Users\\DELL\\Desktop\\python codes\\chromedriver')
driver.get('https://accounts.google.com/ServiceLogin/identifier?flowName=GlifWebSignIn&flowEntry=AddSession')
driver.find_element_by_name("identifier").send_keys(email)
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/div/button/div[2]").click()
I did this till here
I don't have that gecko
well this works
for logining
im a bit confused here
can u put this in my code
and also why it wont happen on chrome
not in chromedriver
and I'm not able to access chrome
yes sure
first just define the variables that you want to input
and then
just step by step find the xpaths or the names for the button that you want to click
ohk
from selenium import webdriver
import time
email = 'email'
password = 'password'
driver = webdriver.Chrome('your path to the browser')
driver.get('https://accounts.google.com/ServiceLogin/identifier?flowName=GlifWebSignIn&flowEntry=AddSession')
driver.find_element_by_name("identifier").send_keys(email)
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/div/button/div[2]").click()
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[1]/div/form/span/section/div/div/div[1]/div[1]/div/div/div/div/div[1]/div/div[1]/input").send_keys(password)
driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/div/div[2]/div/div/div[2]/div/div[2]/div/div[1]/div/div/button/div[2]").click()
this will log you in
yes
well it won't work in the driver cause gmail doesn't allow to login with any automated browser
If you are able to access the chrom by any way then it great
it worked till signing in
yeh IK bro
in home pc it ran full
I'msaying na
joins the meet and leaves
ya
it can't lmao
it worked bro
ok ok
well
so at tha tpart i use pyauogui and press esc button to close that one alert box
wat u r talking about not being possible
@green snow gmail says that it will not log you in cause the browser is not safe
so at tha tpart i use pyauogui and press esc button to close that one alert box
@green snow yeh I got it
anyways thx for your time
no problemo
i have asked for help in many servers utube
ohhkk
ill tell you once i get it sorted out cya
anybody good at front end?
No, what do you need help with?
guys
good night
i'm having problem with pipfile and pipfile.lock
it's not locking
the website was running fine, i added a function and tried to deploy it
it was working fine locally
Hey @wild thunder!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
β’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
β’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
!code-blocks
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```python
print('Hello world!')
```
Note:
β’ These are backticks, not quotes. Backticks can usually be found on the tilde key.
β’ You can also use py as the language instead of python
β’ The language must be on the first line next to the backticks with no space between them
This will result in the following:
print('Hello world!')
@flint breach What I am going to ask is kinda a personal question, but what I wanna know is if you have had any experience with freelancing and do you recommend it. (the personal question: what is the average price of a website you make?)
what do you mean by that
@native tide you are a beginner and you want to find where to learn
@native tide I advise you to go to youtube and search for dennis ivy django tutorial or Corey Schafer's one
!resources @native tide
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
No, what do you need help with?
@acoustic oyster making a webpage lol
how do you guys handle usage statistics for users (in django)
for example you offer several services, for example downloading a file in several formats
and you would like to keep track of how much each user downloads
how would you handle something like that in a generic way
you could for example keep track how many times he sends a post request to that url, but what if the endpoint url chnages for example?
like what, if you have 40 different services like that
how do you tackle something like that
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```python
print('Hello world!')
```
Note:
β’ These are backticks, not quotes. Backticks can usually be found on the tilde key.
β’ You can also use py as the language instead of python
β’ The language must be on the first line next to the backticks with no space between them
This will result in the following:
print('Hello world!')
Hi,
what are some good resources with which i can build costumed html templates instead of writing them manually?
bootstrap
themes
do you mean themeforest?
What service do you guys use for storing images? I was using file system storage but heroku doesn't like that and makes them disappear after a while.
doesnt aws have something for that?
Should I give aws s3 a shot or, is there sth better?
this is quite annoying cause' now I might not be able to compress them and need to change the whole system
Or I might switch from heroku π
what do you mean by "automate all the tasks"
I ve done that
DO doesn't have a cheap bucket storage, so AWS S3 is by far the cheaper option if you're just storing images
Nah..it's not a small project
that's not bad at all.
yeah, it really isn't, but you do need to factor in transfer costs if you're moving data around a lot
but for a few files, it's not bad at all
(plus you'll likely be in the free tier and not pay anything)
What if a lot of people enter the website and all request the data from the aws service?
would that charge the client more?
yes
you pay for three things:
- storage ($0.023 per gb)
- operations ($0.0000004 per GET or other requests) usually one or two of these per request
- transfer ($0.09 per GB but first GB is free)
$0.0000004 per GET or other requests
ugh
that's good :)))
cause' I do more gets than posts
aws s3 is preety cheap yea
if you get a million requests for a 100kb file, you'd pay this:
- storage (not even going to calculate this, it's so tiny)
- operations: 40 cents
- transfer: $9
btw.. the aws bucket, is that like a folder in my filesystem? Can I create a bucket for each folder where I have pictures inside?
I have a folder with pictures for the project page.. then another folder with pictures for construction page
aws buckets live in AWS, while there is a way to mount that like a filesystem, normally you don't
yes, it's somewhat like a folder with stuff in it, and when you browse it on the online browser, it looks pretty much like a filesystem. and the path is separate by slashes, so once you set up HTTP access to your bucket, you can work out the full address easily
BUT
it only looks like it has folders, it's actually an illusion, and there's no inherant folder structure
you can treat it as having folders, but in reality it doesn't, a fact that occasionally comes up in the way some of the functions work for fetching lists of files
is it slower than the file system?
that's a hard question to answer
because in the filesystem you put them once and then you point to the images
I guess.
well, you can't really compare it, too many factors
ok, you can, but this'll take some explaining
by and large..
firstly: speed is one or both of two things: latency and bandwidth
latency being how long it takes before you receive the first bit of data after your quest. and bandwidth being how much data you can receive per second
S3 is generally higher latency, but also medium bandwidth compared to disk running in AWS's datacentre, but here's where it gets more complex: there are multiple tiers of disk in AWS as well
not only do you have the option of selecting an SSD or a magnetic drive; but also AWS allocates IOPS based on not only the size of these disks that you allocate, but also a credit/allowance system that lets them get higher IOPS for small bursts
so in a nutshell, if I pay I ll get higher bandwidth
furthermore, you can choose where the disk is, the default disks aren't actually plugged directly into the same mobo that your VM is on, it's elsewhere on the rack, or even elsewhere in the datacenter, linked by high-bandwidth network; this increases disk latency. You can choose to pay more for a "local" drive that is physically plugged into the same hardware your VM is running on, and this'll get you the best latency
so yes, you can chose:
- local disk vs somewhere else in the rack/datacenter
- disk of various sizes impacting the IOPS allowance
- you can pay to reserve IOPS in addition to the above
- you can pick between magnetic and SSD
the speed and latency of S3 fits ... somewhere... in here
it's definitely higher bandwidth than most magnetic disks; it's probably higher bandwidth than some SSD configurations. It's higher latency than a local disk, it's probably higher latency than default disks as well. But its latency and bandwidth is also potentially throttled by your VM's network allowance, since you're on shared hardware, and if you use more network capacity, AWS may throttle you back to allow other tenants access. This throttling is also usually based on VM size - larger VMs get more network capacity
I hope you can see what I meant by "can't really compare it, too many factors"
and here's another thing, which is more relevant for your use case, is that the S3 bucket can be set up for a direct HTTP access, so you don't need a server just to serve files
heroku doesn't update my github static files whenever I dynamically post images from the website and save them in the file system.
if you needed ultra-high-speed (low latency) access to your files, you'd stick a CDN in front of your S3 bucket. This will cost more, but it'll make your data accessible much faster
curveball: Google also provide bucket storage
prices are similar, but Google's Firebase service has quite a large free tier as well
their free tier is 5GB, transfer 1GB/day, 50k/day ops
pretty cool, I ll look into it
if you do, also consider Firebase hosting as well, it's also quite a good web host and great for static websites (including those built with webpack)
I basically run 90% of my sites though firebase, using the free tier hosting, plus Firebase Functions (equivalent of AWS Lambda) to run any light APIs (often written in Python - like Lambda, they also use Flask as the runtime)
plus serverless databases. It's basically ideal for a JAM stack
do you use flask or django?
flask
I'm not sure you'd be able to fit django onto serverless, you'd probably need to run a server
(the AWS equivalent of Firebase involves AWS Amplify, AWS Cognito, AWS Lambda, and S3, by the way, features are more or less similar, different pricing structure)
I used another service from aws (ses), that's why I keep mentioning it
it was pretty easy to set up
ah ok, interestingly Google doesn't have an equivalent of SES, they make you use Sendgrid
but.... if you sign up to Sendgrid through Google's cloud web console, you get 4x the free tier allowance versus signing up to Sendgrid from their own website
yep, I switched over from AWS to Google a few years ago. They're both good, I'm more familiar with google today, but I don't see any as particularly good or bad, they both have their benefits. I think Google's free tiers are better at the moment, but are slightly more expensive currently (they jostle for price very often)
silly question: you using a loading screen while waiting for requested data?
usually. I build most of my frontends in vue, and I use the vuetify component library, which has by default a :loading property defined for many components, so it's super-easy providing loading bars or spinners on buttons
I see..for this project I used html and sass
so mostly an axios().then().finally() with the loading state unset in finally
:)) that's pretty nice, I mean I think aws s3 has callbacks on its get_reponse method as well.
or try/except/finally for awaits
I'm not a good designer, so I use a component library do all the work for me
vue+vuetify is what I normally use. so all my sites look super-bland, but they don't look bad
vuetify is mostly similar to other material component frameworks, it works well with vue, but doesn't look that much different to material-ui for react for example
but since it defines a bunch of components for you - cards, buttons, inputs, and all the usual flexbox things you'd expect, if you stick to these components, then your site will look like pretty much any other Material UI design site. Which doesn't stand out, but frankly is better than anything I can do
yes
flask is nice and lightweight, good for lots of things that don't need or don't fit into a django backend
and honestly there's not a lot to learn to be able to do useful things
imo the decision point is whether you're using a database
yes, just use django. no, flask is probably better
somewhat complex decision here, I don't think it's necessarily a "use django if you're using a database"
for me, the decision is usually: do I need a webserver that provides API, ORM, and MVC? if yes to all three, use Django
there's a lot of instances where the answer is no. For example, my current preferred stack is Vue (which does MVVM, and doesn't need Django's MVC); graphql (which doesn't make use of Django's API/CRUD stuff), and in fact integrates very well with sqlalchemy (which in my opinion is a better ORM than Django's)
so this particular stack for me doesn't require Django at all, and in fact works quite well with flask instead. the specific stack looks like:
- vue.js (or really any other javascript frontend framework)
- flask
- graphene/graphql
- sqlalchemy
and that's why I recommend learning flask if you're asking about whether you should learn something - it's useful for a lot of things. Django isn't the only way to do backend
looks like you defined user table twice
did you make a copy/paste error and forgot to rename the table you pasted?
What would the best way to incorporate an existing Website into a Django application? I want to basically build a modular frame for a site and implement other functions outside the site - how can I accomplish this?
@fair agate Just move all the html files to templates folder like :
mv website/*.html djangoWebsite/temps/
And do the same with static files , then you have to rewrite the links and hrefs in the templates .
That's how I do it*
what about actually loading up a webpage in full?
say there is an external site I want to build a frame around as a temporary measure until we can rebuild the site in Django
Then irdk
Sure
In my Flask app, I create a folder in static for each user to store their static files for their posts like images
Static/users/{username}
I do this with os.mkdir()
i really wouldnt do that
Will this work if I deploy it to Heroku and host my static assets on amazon S3?
Oh rly? Whatβs the alternative?
Do I store them by file type?
You should remember Flask wont be the thing (Or shouldnt be the thing should i say) serving static files
Any static data is normally handled by the Outer server like Nginx or apache
So how should I be organising files?
an easy method would be have a single static folder, or a folder with categories and generating unique ids
If I have a single static folder and al user uploads go to that folder, wouldnβt it become cluttered? Or is that just the way it is
or a corosponding ID related to the post number or something
Ah ok
I could just hash the image name (e.g user uploads βimage.jpgβ) to guarantee the name will be unique?
if the names are the same and the process is the same the hash will be the same
idk how you have your thing laid out overall but
static/images/post_1_thumb.png or something
like you can always rename the file
that way when you load the posts you dont need some special system to load the images
just get the post number and serve the corresponding image to go with it
What if I want the posts to accept all file types? Like an embedded spreadsheet or a video or sth
i mean you dont have to change the extension
you can just change the name and keep the extension
tho you should have some extension filtering
So in general itβs not okay to dynamically create folders inside static?
otherwise people can easily inject all sorts into your system
Its generally a bad idea imo
So do I like
If the file extension is jpg png etc then store in static/images
If itβs .csv store in static/spreadsheets
If itβs in .mov .mp4 etc store in static/videos
you can do something like that yeah
I tend to have a static file area for static stuff for the site then another static folder for user data stuff
Ah okay that makes so much more sense thank you!
Ah, makes sense
So like
Static/users/images
i tend to have a seperate area entiely
Like my site stuff goes in xyz.com/static
while stuff which is changed or what ever is xyz.com/content or something like that
Question for anyone out here, has anyone successfully written HTML emails out of Django Admin?
I'm working on a site right now that needs to use this feature for something like Newsletters, but I wasn't quite sure how I would implement it in Django. I also was hoping to use something like Vue + CKEditor or something in order to facilitate this
Hey guys, i have one question, is it possibke to create custom overlay in ohotoshoo and apply it over sliders???
no clue
import flask
app = Flask(__name__)
@app.route("/")
def home():
return "Hello, welcome to the Lumber Legend's main page!"
if __name__ == "__main__":
app.run()
I'm using Pycharm and this is returning an error:
(venv) D:\codyk\Coding.Aprojects\Website>python "website.py"
Traceback (most recent call last):
File "website.py", line 3, in <module>
app = Flask(name)
NameError: name 'Flask' is not defined
i have a project design question. i have a flask backend and react frontend. my python file requires an image to use OCR api and parse the image for text on the backend.
So if i upload a file locally, it'd make sense to put it in static/img, but where would i put that image on a hosted website?
Is it possible to store that image where the flask is deployed (say heroku?) or should i explore options to store that image data into mongodb (GridFS)
what image doesn't work?
register.jpg?
try {{ url_for('static', filename='pic/register.jpg') }}
idk flask. sorry. i only know django π¦
Question about AWS S3 and html file inputs: Say I have a form where I take image files from users and then I want to post them to my AWS S3 bucket. I don't want to pass them directly using pre-signed URLs because I'm compressing/modifying the images. Is it okay if I first save them to my filesystem and then use the s3_client.upload_file and get the images from the filesystem? The thing is, I host my website on Heroku which works with ephemeral filesystems and at some point the images will disappear from my folders. However, I was thinking this is an advantage for me since I need the image in my filesystem only as soon as I finish uploading them to my S3 bucket. Is this a good approach, any hints pls?
Hey guys. So I am using the factory approach for my flask app.
There is one problem though.
# database.py
engine = create_engine(f'sqlite:///test.db', convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))```
in their tutorial, they create a database session on the import time.
The problem here is that app.config['DATABASE'] should be probably used instead of the hardcoded value and I cannot access the app instance at the import time.
How should I go around this? Should I create the db_session inside the create_app function in _init_.py?
Please tag me in case you know a solution.
#Flask
this is the response I got when I filtered UserModel by id(10003) --- UserModel.query.filter_by(id=10003)
how do I list users and all info except packages that has state 'delivered' and 'deleted'
user > packages > all except (not deleted and not delivered)
[
{
"id": 10003,
"packages": [
{
"id": 218,
"states": [
{
"created_date": "2020-07-08T07:07:25.661169",
"state": "Declarations"
},
{
"created_date": "2020-07-11T08:01:52.928634",
"state": "Deleted"
}
]
},
{
"states": [
{
"created_date": "2020-06-29T13:52:45.423667",
"state": "Delivered"
},
{
"created_date": "2020-07-07T14:03:11.147933",
"state": "InternalStorage"
},
{
"created_date": "2020-07-08T06:06:08.517589",
"state": "Delivered"
}
],
"product_category": "BagsAndLuggages"
}
]
}
]
I am working on djnago forms, so what I want is, I have a form choice field city when user selecet it, and there is onther field named radius automatically filled. How cann I accomplish this?
how do i load a stylesheet from a child template onto the parent template
ive tried this: in the parent template <head> <meta charset="UTF-8"> <title>{% block title %}{% endblock %}</title> {% load static %} <link rel="stylesheet" href="{% static 'base.css' %}"/> {% block additionalStyles %}{% endblock %} </head> and in the child template {% extends 'base.html' %} {% load static %} {% block additionalStyles %}<link rel="sytlesheet" href="{% static 'rants.css' %}"/> {% endblock %}
this doesn't seem to work and im not getting any error can someone please help me out
@modest scaffold you need to put both files in file called templates
@modest scaffold and in that file you should create another file that has the same name of you app ''templates/appname/file.html and that file should be inside that app 'the templates file should be inside the app that you created with python manage.py startapp 'appname'if you are in windows and python3 manage.py ...'
And inside you child template you should write this line in the top{% extends 'appname/file.html' %}
@modest scaffold like that the child template will extend from the parent template, hope that makes sense, feel free to ask more questions, I'll do my best to answer them
ye, you're missing an extend, otherwise it doesn't know which template is the parent template