#web-development
2 messages · Page 101 of 1
@vestal hound I don't see what there is to gain from that scenario.
Hey guys, Flask_wtf captcha related issue , when i implement the captcha, it simply gets ignored whether its done or ignored, i can always submit the form
username = StringField('Username', validators=[InputRequired(), Length(min=5, max=20)])
password = PasswordField('Password', validators=[InputRequired(), Length(min=8, max=80)])
repassword = PasswordField('rePassword', validators=[InputRequired(), Length(min=8, max=80)])
recaptcha = RecaptchaField()```
```<form action="" method="POST">
{{ form.hidden_tag() }}
<p>{{form.username.label}}</p>
{{form.username()}}
<p>{{form.password.label}}</p>
{{form.password()}}
<p>{{form.repassword.label}}</p>
{{form.repassword()}}
{{form.recaptcha}}
{{form.submit()}}
</form>
<p class="signup">Already have an account?<a href="#">LogIn!</a></p>```
it lets me submit the form without checking if iv done the captcha or not
Hi
how do you define 'worth'?
Bootstrap. Worth it or no?
@native tide yes
how do you define 'worth'?
@versed python no need to go further if you do front end you need bootstrap
can someone recommend web app projects? i know a little js, i know html, and i know css as well as python, but i want to tie them all together to make a nifty like, social media website, per se
i want a tutorial i can find. i know the code but im unsure of how to structure it and stuff you know?
!kindlings @native tide
Kindling Projects
The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.
quite new to full stacks development: so I have been playing around with django for a bit. Recently, I wanted to do something like
request.restaurant.order_set.all() # get all order
and I wanted to dictionary that so when pass to the front end it would be much simpler to unpack. Once unpack, I made each of the object that was pass a button so when click it sends the object back to View. I used fetch to send a POST to View.
Now my question is everytime the button is click and it trigger the JS, the objects becomes a string and when I send it to django it return as type string instead of the object. I did some reason and found out about serialisation and rest framework. Is this like a good practice to make an API and just have template request the data instead of passing data straight from View to Template?
i haven't learnt bootstrap for one
@versed python You know what a framework library is ? yes
are they useful ? yes
do they work with react-apps and vue apps ? yes
Do most of the projects still use bootstrap ? yes
so MAYBE YOU never used bootstrap, but it is undeniably useful and widely used, ofc you can use another library, ofc you can write your css by yourself, BUT bootstrap is still the most used library today, so why deny the fact that if you want to learn about front-end bootstrap is obviously worth ?
Saying that bootstrap is essential to go forward on your path in frontend is like saying you cannot become a web developer without learning django. Django is just a framework that people prefer to get started with web development but by no means the only way. Similarly, bootstrap is also a framework. The only reason people prefer to get started with it is because it is easy to pick up and widely used.
TBH most frameworks do build upon the basics of bootstrap and extend it so you'll probably end up learning it either way.
But by no means is it NECESSARY to learn bootstrap.
Bootstrap. Worth it or no?
that was the question, notbootstrap is essential to go forward on your path in frontend
and my answer was 'what do you mean by "worth"'
it is easy to pick up and widely used. and it is a huge reason to learn about it, period, jesus Ignis you absolutely want the last word, bootstrap is worth learning about for someone new in front-end, why do you want to start a debate on what does he mean by worth, or the alternatives, it is worth
I am not trying to argue with you. The reason why it's widely used is because it's easy to use. Doesn't mean it's worth it. You really need to know what they mean by worth to recommend something. Maybe they are looking for a reactive website, bootstrap isn't what you should choose to make one.
or maybe they want to make a website that looks like a Google website, ie, a material design one. Again bootstrap isn't the right choice.
So yeah I still stand by it that they need to define what they mean by worth.
I’m getting messed up with rendering data from my views/classes/def. as far as “files” what do I make -in order- to then render it as in “for i in examples”
@frozen python ```py
return render(request,"your_html.html",{"examples":data})
heyyy
i am learning django from corey schafer but when i add his html and css the blog content gets hidden behind the navbar
@winter spindle okay, use z-index:9999 for the header(navbar) in the style.
@nova nacelle heeyy bro the problem is like i want them to come below my navbar
yes that's what it does
why 9999 ?
and i dont know whre
to put
can you tell
i will share my html and css
DM me.
k
Done..👍
Hello
I'm having a problem with django forms validation
postcard_form = PostcardForm(request.POST)
if postcard_form.is_valid():
data = postcard_form.cleaned_data # data is a regular dictionary
return redirect('/form_page')
elif 'date_of_delivery' not in postcard_form.cleaned_data:
raise forms.ValidationError("please enter a valid date") ```
here it's suppsed to tell the user to "enter a valid date" when they hit submit with an invalid date format
but for some reason it returns this error:
So how do i validate the data on the server side in django?
what's onn line 18
[Django]I got 2 problems when I try to use bootstrap, the first one is this. I'm not sure why it keeps popping up but it seems not affecting all the layouts
the other one is here. The dropdown-menu is not showing when I clicked on the profile pic. I have no idea how to troubleshoot this issue.
Please help. I never use javascript or bootstrap before
line 18 is the last line
@crude crane is there supposed to be_()around ur string that Discord might be escaping somehow
no
I'm using wtforms. And i want to check when a file is uploaded if it's of a certain type or not . I was wandering if it is possible to do this check as a validator ?
@crude crane is there supposed to be
_()around ur string that Discord might be escaping somehow
@marble carbon i tried adding it but it didn't work, it's giving me NameError at /form_page
name '_' is not defined
@marble carbon i tried adding it but it didn't work, it's giving
me NameError at /form_page
name '_' is not defined
@crude crane
just remove that _() and pass a simple string
can anyone help me with this django error django.template.base.VariableDoesNotExist: Failed lookup for key [type]
i cant find anything on it
variable does not exist error
sup folks
bit of trouble understanding this 500 error
js:
function knownCard() {
xhr = new XMLHttpRequest();
xhr.open('POST', '/_mark_known');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
if (xhr.status === 200) {
alert('Something went wrong' + xhr.responseText);
}
else if (xhr.status !== 200) {
alert('Request failed. Returned status of ' + xhr.status);
}
};
var k = j % objects.length
xhr.send(encodeURI(objects[k].id));
};
flask:
@app.route('/_mark_known', methods=['POST'])
def mark_known():
return flash('success')
so, i'm sure it's doing something because removing methods=['POST'] returns 405 error rather than 500
mad because it kinda works
In django, how and where is stored, wether a user is logged in or not ß
@vapid acorn it is in request that you get in your view
@humble stump I think because you are passing data to your view but your function doesn't accept any arguments.
@vapid acorn it is in request that you get in your view
@stable kite i think they're asking where the data is stored not how to access it. I think it is stored inis_authenticatedfield in the database
@versed python there is no fields like is_authenticated in django default user database
we can get user requesting a resource from request only
it's a method right?
@versed python yes
we can get user requesting a resource from request only
@stable kite but where does this request get the user from?
Django does it on it's own
that's not really a valid answer
I mean if you wanted to code this part yourself, would it be stored with a session id on the server or in the cookies or on the client side in the session-storage?
@versed python request are objects of classes of HttpRequest so this is where we get user
but it isnt just bound to one request
but it isnt just bound to one request
@vapid acorn wdym?
@vapid acorn the session idare stored as cookies on client
yeah
so you're implying that whether a user is logged in or not isn't stored inside the database at all?
I think that is actually true
@versed python yes
yeah
that sounds logical
the last time of login is stored on database
yep
couldnt you just modify the browser cache on the client side as the client?
@vapid acorn you can
you could. It's called logging out
What do you think is stored in the cache, A session token together with a boolean to indicate if the user is logged in?
@versed python modifying is session id is not called logging out
*boolean is wrong, wouild rather be a user id
@vapid acorn no the session id which is generated by django
@stable kite I just printed the stuff stored in the get-request, and there was no indicator wether the user is logged in or not
just and empty <QueryDict: {}>
oh ok imma try that
If im logged out it's now:
AnonymousUser
And if I'm logged in:
myUsername
That makes sense
yes
https://www.linkedin.com/posts/harshita-raj_aos2020-projectabrlead-participant-activity-6722771055259344896-3Swa
Please visit the above link and register for another open source program AUTUMN OPEN SOURCE 2020 .
The link for the same are given in comments and join the slack channel given in comments of the post in the above link.
Register here as a participant https://aos.sanscript.tech
consider if i have a (small) set of users who create content for my website and the general set of users who can view the content. Do i put both these types of users in the same table in django ?
I have a login.html and a register.html. Anyone can explain me how to put those two html files in a web framework flask? I wanna do if someone register and then you can only login with the registered datas.
do you know flask ?
consider if i have a (small) set of users who create content for my website and the general set of users who can view the content. Do i put both these types of users in the same table in django ?
@red pine ideally no. Separate them.
in /admin i see something called groups, is it useful for this kind of a situation ?
yeah it is. But from what I have heard, these groups aren't really useful and become not enough after you introduce some application complexity. I think there are packages out there which handle this stuff better so maybe you can look into those.
but yeah groups is the way to go
okay thanks
oh wow
haha
i had no idea he was on pydis
i dont think he is active toh
this is one cool guy i like his cotent
@red pine no i am wanna learn flask
see you have to set up routes in flask and then you can manage log in etc after you have some user model
ahh i see
routes > views (models) > template this is basically it. a route is like www.yourdomain.com/about/ the about is a route. once this route is hit flask will check which view corresponds to this route and display that view using a template (if any)
ohh thanks!
i am watching some videos of login®istration in flask and trying to understand it and then doing it myself
try to follow one complete tutorial from start to finish if you see user auth from one channel and models from another you might miss stuff
sure i will. Thanks for your advice
hello
my own css is being overiden by bootstrap
is there a way to fix that
base code
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}">
{% block extrahead %}{% endblock %}
<title>Chatparty - {{Title}}</title>
</head>
<body>
{% block content %}
{% endblock %}
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>
Why is it when you have the same variable and two different values. The first one takes precedence over the other? @obtuse iris
I'm not quite sure that I understand you, @mild helm
I'll repost my original question:
When using wsgi servers like Gunicorn, is it required to both:
- have the actual server installed on your system
via apt-get install gunicornand - have the python package installed via
pip install gunicorn?
Sally = 'pickles' Sally = 'cucumbers' then print why is pickles always print first than cucumbers?
@obtuse iris
Oh, you're asking me an unrelated question
Can you give me some actual code?
You're correct in that the behavior you're saying is happening is strange, but I cannot reproduce it if I don't know exactly what you did
@quick cargo Hmm... That's what I thought. I'm trying to troubleshoot the appearance and meaning of this error when I run a dockerfile (I'll get that in a second)
Dockerfile:
FROM python:3.7
RUN apt-get update -y
RUN apt-get install -y python-pip python-dev
RUN apt-get install -y gunicorn
RUN apt-get install -y python-gevent
# We copy just the requirements.txt first to leverage Docker cache
COPY ./requirements.txt /app/requirements.txt
WORKDIR /app
RUN pip install -r requirements.txt
COPY . /app
# ENTRYPOINT [ "python" ]
CMD [ "gunicorn --workers 3 --bind 0.0.0.0:5000 app:wsgi" ]
do python -m gunicorn
Sorry to be verbose, but to be clear, you mean to replace the last line with CMD [ "python -m gunicorn --workers 3 --bind 0.0.0.0:5000 app:wsgi" ]?
does anyone know how to create a link in my navigation to the django admin page ?
well you should have them as seperate arguments @obtuse iris
idk why you also do apt-get gunicorn or gevent
That's just there because I was troubleshooting why it wasn't working
try ["gunicorn", "--workers", "3", "--bind", "0.0.0.0:5000", "app:wsgi" ]
Give me one second! What would the separate strings accomplish?
well its todo with how its passed to exec
Docker is built off Go and go's exec system requires that they be seperate argument otherwise they get escaped as one lone single command
I see, I did not know this!
Either way, it's still treating it as a file:
I think I'm doing something really stupid here. Should I not have ENTRYPOINT ['python'] in there?
That was it! Now I'm getting a module error I'm going to tackle for a minute or two. @quick cargo , thank you!
@quick cargo It works! That was indeed the gotcha, separate they work
How can I make a form field unique inside of flask? not in the database
how do I parse json objects that keys are index numbers?
like this:
{
"COUNT": "32",
"ITEMS": [
[
"21",
"ar",
"Argentina ",
]
}
what do you recommend for webapps/frameworks
Django or Flask
I want to make a webapp that generates passwords
@summer wyvern Django
I have a @property on my model which calculates a result based on data. If data is not present it raises an ArithmeticError with an error message. In my serializer i put this field in Meta->fields, however when ArithmeticError is raised due to missing data, server crashes and returns 500. I instead just want to serialize the ArithmeticError message back to the user, so that user knows why it cannot calculate. How do I do that?
@summer wyvern Django seems to be the accepted go-to if you want as many features as possible, but its obviously more complex, the file structure tends to scare off a lot of beginners as well but its nowhere near as complicated as it looks
Flask is also alright though

is there a way to get linting to work with transcrypt
how to make a html into an actual site you can search?
?
you mean publish it to the web?
yes
host it and link it to a domain
github pages
then basically wait for google's web crawlers
google picks up github pages pretty well
This is where I started @native tide
https://www.youtube.com/watch?v=UmljXZIypDc&list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p&index=1
I don't know if this question is quite right for this channel, but how do I achieve pretty much the same way to difference between Tor users (.onion) and normal?
Context is a Django application.
Lynxchan (https://gitgud.io/LynxChan/LynxChan/-/blob/master/src/be/workerBoot.js#L109-129) does it with using different port for public facing and different port for the hidden service port.
Hi
How can I make a form field unique inside of flask? not in the database
adding a unique validator to this
I'm making a project on Django.
If I click on a button it is getting redirected to : Request URL: http://127.0.0.1:8000/dashboard//
double forward slash
any idea why would that happen?
How can I do that? I didn't understand?? (Sqlite)
Encrypt the database and store the password on PATH
@radiant aurora I think your name shouldn't contain spaces
My name?
@radiant aurora name in urls.py. It shouldn't contain whitespaces
just use hyphens or underscores
This might sound really dumb but how do you get subdomains that are before the main domain (as in en.domain.com)?
Anyone know how to write tests for django forms, specifically crispy forms? Can't seem to find documentation on it
@worn rapids you could try giving incorrect input to your forms and checking if the correct ValidationError is being raised
idk how to make it specific to crispy forms though
do u have an example for generic form test implementation? @versed python
@fair shale u might have better luck getting help, if u posted ur problem/question itself
@worn rapids i dont really use Django forms anymore, but one of my projects I did, I did test views and their corresponding forms.
you gotta install the thing ur trying to import first
that's really unhelpful information
just post the traceback
bruh
ok
- post your code which gives you the error
- post the FULL traceback
Anyone here familiar with beautifulsoup :\
How do I start web developing with Python ?
RUN
start with learning flask or django
and build up from it I guess
@slender needle ^^^
Hi, I am using FastAPI to develop an API and using postgres as DB. I have to add pagonation any helpful resource?
anyone familiar with the django polls tutorial? I am on part 5 and the admin site does not allow to create choices. i can't tell if i missed something or if you are just expected to command line in all the choices
what exactly are you doing?
@radiant aurora
namein urls.py. It shouldn't contain whitespaces
@versed python we can use whitespaces. But why is the extra slash coming at the end?
i have no idea. And i recommend you remove the whitespace. Use camelcase or just hyphens or underscores
I'm using the space for a reason. If its not fixing the double slash issue then there is no point in removing it for now.
thanks though
Hello, I need to encrypt my SQLite database and store it in the path. Anyone knows how to do it or made this before?
check out sqlcipher
Hello Saitama
yeah
so show settings.py
me will eat popcorn while i watch Soder help saitama
:3
i think this is dejavu
lol
hmmm
yea static isn't configured right
well, i got problems with everything so ur always gonna get deja vu :3
add staticfiles_dir
that link before static_root
open it
lol doesn't matter it's on ur local system
don't be too paranoid xD
lel
oh, i only have static url
yeah also, show tree where ur saving static files
@tame kelp i think django uses pathlib now
it's fine
i still revert back to regular one
STATIC_URL is your static folder . and STATICFILES_DIRS is all directories you have static files in them . So you can load static and use them in your HTML
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")], even after adding this it doesnt work
There is STATIC_ROOT too , for collect_static mostly
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")], even after adding this it doesnt work
@tame kelp what do you wanna do
@tame kelp STATICFILES_DIRS = [BASE_DIR / 'static']
ok I'll let thems take over xD
scroll up my net is slow
@glass sandal he has problems with static files
i think he did what i think it is
{% load static %}
yeah he did that
i did that
i did that
@tame kelp so is it working now?
no, i did that earlier
ah i mean STATICFILES_DIRS?
it isnt :(
You have to do this :
<script src="{% static "file.js" %}"></script>
Example
yeah, i did but not working still
Then
wait
Add STATIC_ROOT
my net is sloww
and set it to :
i think it might be his file structure
STATIC_ROOT = os.path.join(BASE_DIR, "assets")
Add this to your settings.py too ^
And then
weaiiit
run :
python3 manage.py collectstatic
he forgot collectstatic ?
i think so
it gives me file not found error
file not found?
lmao
Then make it lmao
which file
what file does it give error
i dont think my image will upload
MEDIA_ROOT ?
i think i know
i think i know
wait wait
did you only have /static as a folder?
no subfolders with /css/ or /js/?
what?
i sent my folders you can look
/static/css/main.css <~
wait what
Got it
i didnt create a css folder
move it one dir topper
you should do that
yeah trust us
so my main.css will be inside css which will be inside static?
i didnt understand what u said
🤦 Just move static to one directory upper than the current one
Like move it to the directory that manage.py is in
what does that meannnn
holy shit
move it up in the directory
Move it from Web_dev/simple_web/ to Web_dev/
like static will be inside my main web folder instead of my blog app?
yup
Yes 🤦
its inside my blog app
no doubts on that
and should i remove what u guys told me to do ealier?
what remove?
STATICFILES_DIRS = [BASE_DIR / 'static']
STATIC_ROOT = os.path.join(BASE_DIR, "assets")```can i remove this
First of all
Change
STATICFILES_DIRS = [BASE_DIR / 'static']
to
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
Don't
Do
that
please
Just let it be where it is rn
ok
You have to chill a bit lol . Don't just do everything again if it didn't work
no offense just saying
It must work now
├── hypernews
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── manage.py
├── news
│ ├── admin.py
│ ├── apps.py
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── static
│ └── css
│ └── base.css
└── templates
├── base.html
├── create.html
├── future_page.html
├── index.html
├── main.html
└── search.html``` your static should be like this okay? remember that okay? create a github repo for it so you can remember it okay?
Also , every app isn't a project . A project is different , in django at least
A project contains different apps
^
But your main dir is an project
yup
as far as I can tell
it doesnt work
What errors?
ok wait
tell us both the error and the dir tree
Yeah
it says this -```[18/Oct/2020 14:34:58] "GET / HTTP/1.1" 200 3045
[18/Oct/2020 14:34:58] "GET /static/blog/main.css HTTP/1.1" 404 1665
Not found
and it looks weird and not what its supposed to
why is it blog?
Oh my ... why blog
it should be css
Yeah exactly why blog
Change {% static "blog/main.css" %} to {% static "main.css" %}
in your html
okay try it now
IT WORKEED
:3
Idts
he lack a slash
ah okay
idk, i just did it main.css and it worked
mhm . Since you didn' t have a folder named blog in static
And main.css was just in static , not in static/blog or something
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
{% load static %}
<link rel="stylesheet" href="{% static 'css/base.css' %}">``` mine looks like this
hmmm
mhm . Since you didn' t have a folder named
blogin static
@glass sandal ah i see
mhm
imho , saiT should've learned Flask first
Cause he would've understood how things worked in Django better
thanks a lot, tho i have no idea how can i make a frontend like that on my own >.<
I didn't learn flask at first either . But when I did , I understood how django worked better
I didn't learn flask at first either . But when I did , I understood how django worked better
@glass sandal ooooooooooooooooooooooh time to flask then 😮
It helps you , also , flask itself is as powerful as django , easier to deploy
But it needs 3rd party libraries for some things
like e.g , for admin we have flask-admin
Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:
[uwsgi]
chdir = /home/pi/sampleApp
module = sample_app:app
master = true
processes = 1
threads = 2
uid = www-data
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true
die-on-term = true
lazy = true
lazy-apps = true
This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?
but what if i got the hang of django? do i need to?
Lemme check it
Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:[uwsgi] chdir = /home/pi/sampleApp module = sample_app:app master = true processes = 1 threads = 2 uid = www-data gid = www-data socket = /tmp/sample_app.sock socket = 0.0.0.0:3134 protocol = http chmod-socket = 664 vacuum = true die-on-term = true lazy = true lazy-apps = trueThis uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?
@peak meadow try change module toapp:app
I was talking more about
don't quote such big stuff smh
try http-socket first
or what's the best aproach as this one works smooth
I think the one that i got
because I specify protocol = http
it's http-socket
Wish I knew wsgi more
yeah, no worries
Not much knoweledge of wsgi
Well , pretty sure someone could help u . Probably not me since I don't have experience working with wsgi
Np
Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:
[uwsgi]
chdir = /home/pi/sampleApp
module = sample_app:app
master = true
processes = 1
threads = 2
uid = www-data
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true
die-on-term = true
lazy = true
lazy-apps = true
This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?
I put this here so people can see it again. Thank you
wish i can learn how to make this kind of frontend soon, but for now i will just use coreys snippets
this is giving me an error
django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: '-home' from 'blog-home'```
oh wait i think i know
nvm i figured it out
they will be inside quotations
hello
can anyone help me,
I have 90 links, I want to change them to my affiliate link then upload them into my site.
@tame kelp Lol I still use Corey's snippets
lel
Hello,
Anyone would like to make a Django based application for a small amount of money?
e
Basically looking to hire someone for a project though I don't have that great a budget
i would do it for free but i dont know yet how to do it yet i havent got to that part in my school yet sorry
Django isn't taught at school, and I'd have done it myself just if I wasn't facing this shortage of time.
Would you guys please help me? What should I know in Python & Django to create a "Courier Based Web Application" ? Is there any specific to focus on most?
Have you worked on Django before?
No...I'm beginner that's why I'm just wondering to know...😩
this is giving me an error
@tame kelpit should be like this{% url 'blog-home' %}
uh, i fixed that
Hey guys, has anyone know how to use matplotlib's plt.imshow in a Flask server. Using it for a research project to embed numpy arrays for easy visualisations.
Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:
[uwsgi]
chdir = /home/pi/sampleApp
module = sample_app:app
master = true
processes = 1
threads = 2
uid = www-data
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true
die-on-term = true
lazy = true
lazy-apps = true
This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?
I have a question about displaying ajax json content that auto-refreshes, without a data table or full on chart and without refreshing the page. Just trying to get advice on any way I can achieve that. I’m going for a dashboard of sorts where there are “cards” on the page displaying a number that is automatically updated based on the json data retrieved from the Ajax request. Any ideas?
(I’m using Django)
Which Front-End Framework you would prefer to develope a dynamic Web-App? Please Submit your response on https://www.menti.com/fiijarput3
Hi
there is no manage.py file
so I used django-admin.py to runserver with this command
python django-admin.py runserver
but this is the output
Traceback (most recent call last):
File "django-admin.py", line 21, in <module>
management.execute_from_command_line()
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
super().execute(*args, **options)
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\commands\runserver.py", line 68, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\conf\__init__.py", line 83, in __getattr__
self._setup(name)
File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\conf\__init__.py", line 68, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
please help
thanks
Good night, I have a django application, which on a models I have a textfield, on the textfield, I want to render the amount of rows inside of the textfield into an integer, currently I reached to the point where it counts all the chars in the textfield, but I want it to count each row on \n break.
@toxic flame perform a .splitlines() on the text field and find the length using len()
Like you normally would
yeah there are various ways
just use one
you shouldnt require values since that would be db intensive
instance = productsByTheSeller.values('stock')
ree = instance.splitlines().len()
there are other ways to select a particular column using django orm, i don't remember tho
it currently returns an error
re = len(instance.splitlines())
uhh yeah you need to extract the text
i will use google thanks.
Can someone tell me what css classes can I add to make this span look like this?
he's probably importing an external icons library
basically need to add the # in front
you add # in front of a selector and it will become an id, a . and it will become a class
how do I do that?
with class, you can put more than 1 class in 1 'variable'? is that what you call it?
for example
.blue{
color: blue
}
.border{
border: 1px solid black
}
<h1 class="blue border">Hello</h1>```
I think I was unclear expalining my question. bsically I need to add a # inside a <span class="icon icon-link"></span> using only css
you mean hide the css?
@versed python what is your questions
Can someone tell me what css classes can I add to make this
spanlook like this?
@versed python starts here
I think I was unclear expalining my question. bsically I need to add a
#inside a<span></span>using only css
@versed python this is the genral gist @stable kite
you mean hide the css?
@toxic flame Not really. The css is there so that I can target the element. But I can't figure out how to add a#inside the<span>
@versed python just type it
I can't
its generated dynamically
it was originally written in markdown
and converted to html using something
the image does not show any #
what is written in markdown?
Basically it's a blog post
That was written in md files
the image does not show any #
@toxic flame It doesn't have any. That what I am trying to add
can you show me where do you want to add it
just you span as prefix &after # your dynamic content
<span class="icon icon-link">#</span>?
<span class="icon icon-link"></span>but I have
i don't see any reasons why it wont display
just put it
I can't its generated dynamiclaly
which means I have not written any html
what's the backend frameowkr?
vuejs + tailwind css
I applied this
why don't you build your own css? it's alot easier
And got this
why don't you build your own css? it's alot easier
That doesn't answer my question
welp i'm having a hard time still doing my problem
Ok quick question: If I am the author of a campaign, this following code puts a result in my query for every subscriber (not me) that is in my campaign.
campaigns.filter(Q(author=request.user) | Q(approved_subscribers=request.user))```
Why would it repeat for every subscriber? I just want it to show in my list only once per situation if I am either the author, or I am a subscriber in someone else's campaign.
Currently, every person that is in one of my campaigns, causes the campaign to repeat on my list for the number of subscribers that exist in it.
@dense slate that's because of how SQL works
basically, your query as is translates to a UNION ALL
wait, let me look at that again
no, that's not right
I want a campaign to be listed if I am the author or if I'm a subscriber.
yes, and the solution is to use .distinct() at the end
but that shouldn't be happening
approved_subscribers is a M2M field...?
Right
But why would it repeat a campaign I author, for each subscriber that is not me?
I only ask for them where I am the author, or I am one of those subscribers
can you show the result of print(campaigns.filter(Q(author=request.user) | Q(approved_subscribers=request.user)).query)?
I just woke up so maybe I'm on the wrong track but I'm p sure it's because of the join over the M2M field
Not at my pc, I'll try in a bit.
If you wanted to query events, for which you are either an creator of member, would you approach that query this way in the first place?
honestly it feels like it makes sense
I use distinct elsewhere, but it doesn't fix this one.
@dense slate I believe that it doesn't work because the rows returned are not distinct after the join
Why did you add .query? What does that do?
it contains the generated SQL
Ah
so my guess is that after the join, the rows are not distinct because they differ in the joined values, which are not shown to you because they're not part of the Campaign model
which is why .distinct() doesn't work
but if you take distinct over id, it should...?
I'll try it when I can
although I feel like this should work out of the box
do you have like any annotations or something
Hey guys. This is /technically/ a python web question as i'm using flask backend.
I have Access-Control-Allow-Origin turned on on my API and application, but still chrome is blocking my js post requests,
Any idea why ?
idk if it's the same but django has a package called django-cors-headers
maybe you can find something similar for flask
i remember that frontend framework sometime has the settings that block cors too, happened to me before
Hi
So I am having trouble with a redirect to a url in the requestslibrary with python
I try to go to this url
https://<USER>:<PASSWORD>@api.stocktwits.com/api/2/oauth/authorize?client_id=<CLIENT_ID>&response_type=token&redirect_uri=http://<YOUR DOMAIN>&scope=read,watch_lists,publish_messages,publish_watch_lists,follow_users,follow_stocks
Which, when I put into a browser, successfully redirects.
For some reason it fails to do so in my code
I am thinking it might be simpler than I realize
Based on what I've seen online, it seems like my approach is correct, but I am missing something.
response = requests.get(AuthorizeURL, allow_redirects=True)
So I check the url of it, and it's not the redirect url... just the original.
I'm adding a custom action to one of the models on django admin site, and I want to ask for user input for that action. What would be the best way to do that?
using forms
I followed this answer and it works for my custom action, but the default delete action now doesn't work - it opens the confirmation page, and after confirmation it just says that the action wasn't selected
https://stackoverflow.com/a/63644851
Apparently that's the cause, nvm
https://stackoverflow.com/questions/42374193/no-action-selected-says-django-admin-when-deleting-objects
I've created a simple model Product with couple of fields and then went to admin.py. I've registered the Product, make some fields list_editable and created a new action duplicate.
def duplicate(
How do you guys feel about home tests for work interview? I got a hometest, and it feels like a few days worth of work, and thats before an interview with any engineer one on one
Feeling like I should drop the "oportunity" altogether and just cancel with the company.
twilio is the easiest to use afaik
@fathom cradle if you have time and feels like you can do it, we can't know.
apply to any jobs basically
Would you be ok with a job interview that just goes, hi, we looked at your CV and want to waste 2 days of your life?
I think that is a bad custom in the industry.
But maybe im just overeacting.
@fathom cradle I've completed a similar test recently just for the experience. If you have time and think that it will let you learn something new, then complete it. Even if you won't get accepted, let it dangle in your github to show the future employers what you can do
always good to have pre-made project from your own or any past experience
Yeah, so this test assignment may be good enough for other employers
this question is more related to #career-advice
@fathom cradle I've completed a similar test recently just for the experience. If you have time and think that it will let you learn something new, then complete it. Even if you won't get accepted, let it dangle in your github to show the future employers what you can do
@native tide Did you get hired?
please ask in that for advice
please ask in that for advice
@gaunt marlin thanks, didn't see that channel
from django, i got a working Model class that looks like this
however, i do have an issue that the loading time is ridiculously long, probably due to super().save() needs to be ran before, which means i need to save, load then the image again
you gotta wait for them to support, 3.9 came out like a few weeks ago
if you can't then you can downgrade your python version to 3.8
Hey, on django admin I have pretty active model which gets new values every few seconds, and I would to make changelist_view autorefresh model values with ajax every 10 seconds instead of reloading page. Maybe someone could point me to right direction, with some guide on this topic, because so far haven't found anything on google.
Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:
[uwsgi]
chdir = /home/pi/sampleApp
module = sample_app:app
master = true
processes = 1
threads = 2
uid = www-data
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true
die-on-term = true
lazy = true
lazy-apps = true
This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?
how can i retain all the properties of the default progress bar
except for the color ?
like the progress color
?
@strange ocean like what properties?
@stable kite the whole look and feel
ok thanks mate
why are you learning django 2.1?
@tough oxide find a recent one dude
this one is years old
not really but corey schafer was good when I learnt django
ok thank buddy
Hi, does anyone here use either WebFaction or OpalStack for hosting? I'm about to move from the first to the second and am wondering if anyone has any experiences to share about that.
I have a GitHub Pages website and I just created a rest API with Django Rest Framework. Is there a way I can run my rest api with GitHub Pages?
or would I need a webserver
Where can i learn flask for free??
on youtube
@tropic rapids https://www.youtube.com/watch?v=mqhxxeeTbu0
Welcome to the first flask tutorial! This series will show you how to create websites with python using the micro framework flask. Flask is designed for quick development of simple web applications and is much easier to learn and use than django. If you are less experienced wi...
Guys i have a dilemma, to choose either django or flasl
I learnt django months ago, and i'm taking pirple.com classes, and they are teaching flask
ah
Hey my one friend told me flask is good
yeah
I just know django, and i dont think i wanna learn flask cause im satified with django
but i paid for this course so,
but mine told me Django
lol
maybe we should all just learn both
For learning django u should go first with flask
and use the one that we prefer
Than it will easy to learn django
@tropic rapids it's not like i googled for courses on flask,
its part of the full-stack dev course, thats the backend they chose
I just learn flask cause i paid
how can I add a domain to my Django Rest Framework? So I can do something like domain.com/api and get the json data instead of local host
Hey, I'm just new to web scraping and been trying to make a script to get fresh requests on some website. But how do I get the new requests? meaning after re-reading the content of the HTML page how do I determine the new requests?
I tried to do the following:
old_containers = soup.findAll("td", {"class": "details-td"}) #this gets called out of the loop (runs only once)
new_containers = soup.findAll("td", {"class": "details-td"})
containers = new_containers - old_containers
But it showed the following error:
TypeError: unsupported operand type(s) for -: 'ResultSet' and 'ResultSet'
What are 'ResultSet' and how do I handle them?
*I mean by 'requests' just new posts
Hey, who uses slack every day at work?
Anyone know or have a tutorial I could use for setting password requirements with flask? I understand how to use the Validators from flask-wtf, but that only lets me set a min/max length. I would like to learn a way to create requirements like 1 upper, lower, special char, and number. I would prefer to not have to write my own validators, but if I have too then that is fine xd
b
@hallow jacinth Perhaps this package? https://github.com/kolypto/py-password-strength
I will take a look at it, thank you :D
I am using django and dont really want to use the models with migrating the database bla bla bla, is it recommended to just create an own database handler class to do that stuff?
I feel like I have more control If I do it like this with storing password hashes and stuff
btw, could you just use a model-inheritated class like normal with __init __ and will a normal instance attribute also be stored in the db automatically?
if you're not using the ORM then using DJango is pretty pointless overall
at that stage you might aswell use Flask or a micro framework
if I make my VPS a webserver, will it effect the other things I'm running on my VPS?
hey guys, anybody already found this error when using the viewsets of Django Rest Framework?:
Object of type type is not JSON serializable
this error occurs in normal django
not drf
are you sure you are importing the serializer from the correct place?
yes, I have all my serializers placed in one file
also, this is working for 2 endpoint, but in a third I got this error
but I'm doing basically the same thing for all 3 views
Question Model```python
class Question(models.Model):
QSTATUS = [ ('Pending', 'Pending'), ('Accepted', 'Accepted'), ('Review', 'Under Review'), ('Rejected', 'Rejected') ]
question = models.CharField(max_length=140)
improved = models.CharField(max_length=140)
description = models.TextField()
date_added = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
status = models.TextField(choices=QSTATUS, default='Pending')
by = models.ForeignKey(User, on_delete=models.CASCADE, max_length=10)
Following is my Questions formpython
class AskQuestionForm(forms.ModelForm):
fields = ['question', 'description']
class Meta:
model = Question
``` How to i enter the current logged in user to the Question model's by field.? Do i need to change my model's by field ?
could someone please suggest what i need to look up ?
There's not events in django right?
You ahve to do that in js? or react/frontend stuffs?
if i submit this form its throwing a NOTNULL constraint violation
you mean class AskQuestionForm(forms.ModelForm, user): ?
No when you are passing the form with POST
This is another way to do it
Hi guys! Can you suggest rather good example of portfolio site?
I want to create own portfolio site, but I don’t know what to take as the basics. there are many different versions. Also please suggest which section is required for portfolio site which is not.
This is the error i am getting when i start my server: Error connecting to MariaDB Platform: Can't connect to MySQL server on
'192.0.2.1' (10060). I am working on windows. If i want to connect on vscode to the mariadb with "mysql -u root" it says error too. I did "pip install mariadb", I would appreciate if someone could help me out. and i have a programm which called "XAMPP" where i can start mysql, but even when i start it, i am getting the same error
Django: If I want to use aiohttp or another async api. Where should I put the ClientSession to keep it alive during the whole session? And how to close it?
idk if this belongs here, pls lmk:
Hey, so with the requests library You have the post request, Now to send post data with it you have to do {"info": "something"} wich is like the parsed version of the post data, is there any way i can just use the soucre data of a post request?
for once and all, prons and cons of flask and django and what is better?
@native tide generally wouldnt use asyncio with Django unless its specifically in conjuncture with Channels
doesn't it support async views now?
if its via channels
Hey just FYI, I DON'T recommend using SESSION_COOKIE_SECURE = True in your settings.py file for a Django website.
I just spent over an hour trying to figure out why my website wouldn't authenticate on localhost in Chrome
I have read some articles about it https://wersdoerfer.de/blogs/ephes_blog/django-31-async/.. I guess I should just use a semaphore to limit the number of connections
It's possible it's not a problem when deployed--I haven't encountered any issues with my deployed website--but it still produces login problems with at least Chrome and "Web" (formerly "Epiphany") browsers on localhost.
^ maybe because your production uses https and your development uses http?
possibly
It's frustrating spending so much time on something like this.
I was not trying to get deep into backend stuff today.
I just had to create a database model for a frontend project.
It happened to me last week, now I know 
Now I have to go clean out all the print statements in all my various files I was using for debugging. Arghhh!!!
I should probably just create a git branch when doing such debugging so I can roll back with one command.
Hey guys i have a little problem i m learning with flask to make a site but propably i don't have set right enviroment , maybe u asking why i think its enviroment? For example lets say i have port=300 and in previous doc i had there a image but now i changed that and write something else like deleted the image but when i referesh the site image is still there so i had stop trough cmd localhost changed port to lets say to 500 and start localhost again trough cmd and there was no image anymore. In previous project i didn't have this problem , maybe some shortcut missing there or something else idk. Please if u know what to do or u didn't understand what i writed please let me know.
Hello, so I have 2 models, Product and Stock, the stock which each are foreignkey to a product, how can I render out the count of the stock assigned to the product on a template?
Please ping me.
Hello
How do I update JQuery in Django
and how do i see the current version of jQuery that is currently used by Django
update jquery?
you can use the cdn or download the newest packages and replace them in static
Is there a good tutorial on that?
I am not sure that django uses any jquery, I am not 100% sure though.
But if you want to use jquery in your templates, you will need to install it/add it to your project itself. It is completely separate from django
(im not a web developer, just patching things)
Is there a good tutorial on that?
@trim star you would not be adding jquery to django necessarily. You would just be adding it to your html like normal.
oh, if you are patching someone else's code: someone should have added jquery to the static folders, or the cdn links in the templates themselves. If the front end is using templates
if using local files for jquery, it should be in the app/static folder.
or the cdn may be imported in the template or in a base template
yeah i see in a bash script a command for
download https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
yeah, is that in docker?
you could replace those for newer versions (that is the cdn link)
but you will need to do a lot of work fixing deprecated and incompatible code xD
actually, that is a pretty new version. It would not be worth upgrading imo and it should not cause many conflicts to do so.
(current is 3.5.1)
cool, someone was kind to you though, that should be the only place you need to update the install
there is a vulnerability in versions less than 3.5
oh yeah, makes sense
change it and see what happens haha should be fine actually
Haha hope its not too bad..
no question? just dropping a link here? xD@solemn thistle
do you need help or is this just an ad for your project?
!warn 704811801166086165 Every message you've sent so far since joining the server have been self-promotion. Going forward, please use this community as intended.
:incoming_envelope: :ok_hand: applied warning to @solemn thistle.
@acoustic oyster So luckly the project has very good tests and a build system....Seems that all of the tests have passed after upgrading jquery, bootstrap, and quill
niiiice, you are being spoiled by whoever made that LOL.
Way too common for people to get lazy LOL
yeah 🤣
Now I have to go clean out all the
@topaz widget why uselogger
Familiarity I guess.
how and why doesn't the flexbox appear on the empty space?
``` is the current css code
ofc, inside a flex container with flex-wrap: wrap and display: flex
Either way, I need to remove the chaff after I'm done debugging.
Either way, I need to remove the chaff after I'm done debugging.
@topaz widget the benefit ofloggeris that you can have debug level logging
Okay, I'll have to use that in the future in such instances then.
ok i fixed
Okay, I'll have to use that in the future in such instances then.
@topaz widget also, it allows you to defer string formatting
which might be nice...or it might not. shrug
Whatever keeps me from cluttering up my code just to see what it's doing.
That little side quest really took the wind out of my sails today; however, I still managed to get some stuff accomplished.
Man, doing tricky stuff in CSS can be quite a bitch, though.
I have an image gallery with panels that flip over with descriptions on the back. Getting the panels to flip and show the backs properly with perspective as they flip over takes some serious finesse!
New to web development here. I'm writing a handbook for work. I would very much like to have every section be it's own html document, and then seamlessly plop that into the main document. Mostly because that would be easier to maintain and organize. I'm trying out <iframe> but it has scroll bars. I really just want to plop the html page into a <div>. Is that a thing that can be done?
@fallow silo There might be better ways to do this, but I am pretty sure it can be done with a templating language like jinja, which is python based. If you are more of a js guy, then I recommend nuxt-content (you'd need to learn vuejs though).
I recommend the former because it'd be much easier
Yeah, I want to go with as easy as possible. 😄
jinja it is then
Hi There! does anyone help me out how to open modal pop-up in django admin
@untold sluice you need to override specific admin template that you want in django admin, and write modal css and javascript in javascript block
Okay do you have any reference ?
@gaunt marlin Thanks for your help !
@untold sluice each version of django templates is different, if you want to understand what can you customize read on their github codes https://github.com/django/django/tree/master/django/contrib/admin/templates/admin
basically copy paste and customize whatever you want
guys are heroku servers considered "fast"??
or is something like AWS faster?
i am getting 0.8 second response times for querying a read of a json file
with 90mb/s internet
json file is 3 kb lol
how does countdown timer works
guys are heroku servers considered "fast"??
or is something like AWS faster?
i am getting 0.8 second response times for querying a read of a json file
with 90mb/s internet
json file is 3 kb lol
@strange ocean I think most of that is latency vs bandwidth
@vestal hound based on what tier you using, free tier of course not gonna be fast at all
@elder tiger you set an expired time(usually timestamp), and use javascript to do countdown expired_time - now()
@vestal hound based on what tier you using, free tier of course not gonna be fast at all
@gaunt marlin of course that is true, but I don't see how that's relevant to what I said
server spec related to how many RPS it can do, and it's bandwidth speed
server spec related to how many RPS it can do, and it's bandwidth speed
@gaunt marlin yes, I know that
but I wasn't the one asking the question.
and what I was saying was that most of that 0.8s is latency
ohh got it thx
is your expired_time a static variable or from server @elder tiger ? if it's static then it's doable with static site
yeah it is static thx
i.e. how much data can be moved in unit time
i think it's based on the transfer bandwith
3 KB is very small
how i can take variables from url in django
you mean url parameters?
you can access them at request.query_params
ohh
each View takes a request object
and you can get in view by request.GET.get('parameter_variable_in_url_for_example')
you can access them at
request.query_params
@vestal hound oh wait this is for DRF
vanilla Django uses GET
@vestal hound so there is no way to get some kinda faster server??
does anyone know how to get images using flask restful ???
does anyone know how to get images using flask restful ???
@sage bluff you would probably need to serve the files somewhere (as static files), keep a reference to their path in the db, then serve the url in the api, then get the image from that url.
I do django though.
@vestal hound so there is no way to get some kinda faster server??
@strange ocean not really? do you understand what my point is?
@vestal hound yes so is the latency cuz of my internet or the server response times?
you would need to profile that
@vestal hound yes so is the latency cuz of my internet or the server response times?
@strange ocean not physically being where you are, I wouldn't be able to tell
Not Found: /media/videos/2020-05-14_18-13-42_sQMWhJL.mp4
I keep getting an error like this
When I go to check that route everything seems to be there
The same happens if I use the MEDIA_ROUTE instead of the url
has anyone run into an issue with flask_wtf not rendering the <form> tags?
I have a feeling that it wpuld have problems if you had csrf token enabled, but why would you run the form without the form tag?
@paper radish
this is using quickforms, It causes submissions of forms to be 'GET'
csrf tokens are enabled
just disabled CSRF and it is still forcing post requests
Cors or csrf
I was helping a student with some tutorial work and could not find why it wasnt appearing...Turns out he had a nested form in his header that was missing a closing tag..
thanks though
why....
he right tho
Any ideas on why I could be getting this error?
Traceback (most recent call last):
File "C:/Users/sn3ak/PycharmProjects/dominusio-website/app.py", line 21, in <module>
app.register_blueprint(payment_b)
File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\app.py", line 98, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\app.py", line 1168, in register_blueprint
blueprint.register(self, options, first_registration)
File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\blueprints.py", line 256, in register
deferred(state)
File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\blueprints.py", line 294, in <lambda>
self.record(lambda s: s.add_url_rule(rule, endpoint, view_func, **options))
File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\blueprints.py", line 86, in add_url_rule
**options
File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\app.py", line 98, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\app.py", line 1275, in add_url_rule
rule = self.url_rule_class(rule, methods=methods, **options)
TypeError: __init__() got an unexpected keyword argument 'method'
Solved it, I had to swap method to methods when creating a route
Hello guys, I'm learning Django and I would like to know which IDE or code editor is best for Django
pycharm is very good.
Yes, i currently use it, but when i need to edit html, css or javascript the "PyCharm Community Edition" does not support these types of documents, except html files
Yeah I suggest investing in the pro version if you are serious about developing with Django. It is so nice to use
Question, I am trying to find a good way to pass my request object to my clean function in a form. What is the best way to do this?
many people like visual studio code. also vim is also very good.
Actually not my request object. I am just trying to pass an object. I can access request by doing self.request in a form
Pycharm does support them but youll need 3rd party plugins
Invalid Syntax: ) from exec Does anyone know why this happens?
@quick cargo If you use the django framework there is no need for the third party plug ins
It will recognize the DTL as well
ImportError: cannot import name 'Employee' from partially initialized module 'employees.models' (most likely due to a circular import)
Could someone help me out with the above error.
It's possible that after using python -m pip install --upgrade, my uwsg won't run as it did before and it doesn't find any module
Please help me with django. I am a beginner #help-kiwi
and maybe the virtual environement is changed or something ?
#help-chocolate would be appreciated
@mortal mango Have you installed Django?
yeah
@mortal mango are you using virtual environment?
@devout coral can you share your code?
Actually I already got it thank you. I was being dumb. Had a model in a app that it was not supposed to be which caused me to have to do the loop import thing. I just moved it to the app it was supposed to be in and it is good.'
does anyone know how to select a model inside a class in django?
@toxic flame wdym?
You want the user to be able to select a product from a drop down and the dropdown would be populated with all the objects for a specific model?
Lol what
i have a custom product create page
where the only field missing is the dropdown of all the choices the user want the product to be
The choices the user want the product to be? I am not quite understanding what you are trying to do. maybe some more context?
@devout coral @toxic flame wants that the option in a dropdown should come from different model as far as i think so
@mortal mango are you using virtual environment?
@stable kite yes
@mortal mango have you activate the virtualenv?
yeah
can you share a pic of your console
@mortal mango which python version are you using?
python 3
@toxic flame I would suggest you query whatever model you want the info from in your forms and fill a choices variable. Take a look at below
class EditEmployeeInfo(forms.Form):
COMPANY_CHOICES = []
try:
companies = Company.objects.all()
for company in companies:
company_name = (company.display_name, company.display_name)
COMPANY_CHOICES.append(company_name)
except:
pass
company = forms.CharField(label='Company', widget=forms.Select(choices=COMPANY_CHOICES), required=True)
the error's coming from execute_from_command_line(sys.argv)
which django version are you using?
django: 1.11.29
djangorestframework: 3.9.4
@mortal mango upgrade your django version latest realse is 3.1
how do I do that?
type on console pip install Django==3.1.2
How did you get v1 of Django installeD?
@stable kite requirement already satisfied
then how do you tell me that django version is 1.11.29?
pip install Django==3.1.2try this
Yes
it's returning and it's showing nothing
anyone know how to connect vscode terminal to database mariadb in windows
@mortal mango You ran the command from the terminal window that the venv is activated correct?
yes
Sorry, I do not use VS Code
@mortal mango So now install the right django version now
pip install django==3.1.2
I'm trying but it says no matching distribution
just do pip install django
Then do the show command again to see what version it installs
requirement already satisfied
do the pip show
do pip freeze
it's not showing it
and it says requirement already satisfied when I try to install it
which python
Ok, go to a terminal outside your venv and do pip show django
i am getting this error when i start my local server: "Error connecting to MariaDB Platform: Can't connect to MySQL server on '192.0.2.1' (10060) "
how do I disable the venv
Just open a new cmd window
@mortal mango Send a screenshot of the terminal window please
@wanton ridge do you hve a mysql server running on 192.0.2.1?
yep i start XAMPP and run it
