#web-development
2 messages ยท Page 94 of 1
what does your settings file look like?
Give me a second
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}```
This is the part that you need right?
Nothing
blank file
from django.contrib import admin
# Register your models here.```
Oh I see
I'm dum
I need to register the tables
You'll need to register the models you'd like to see in the admin side, yeah
Last time I did this my file looked like:
from .models import Room, Player, Server
admin.site.register(Room)
admin.site.register(Player)
admin.site.register(Server)
Ah ok thanks
@simple sentinel
still doesn't register
from django.contrib import admin
from . import models
# Register your models here.
admin.register(models.DescriptionInfoBox)
admin.register(models.InfoBox)
admin.register(models.ProfileImageBox)
No tables
Or am I doing something wrong?
It should be admin.site.register(models.DescriptionInfoBox) and etc
Hello everyone. I've been trying to find out this error I've been stuck with. I got a RelatedObjectDoesNotExist at /add_student_save error for my student management system. Its supposed to have students as a custom user while going through a MySQL database.
The database records the student's info, but cannot store them as a CustomUser class.
This is what I get here RelatedObjectDoesNotExist at /add_student_save CustomUser has no students. Request Method: POST Request URL: http://127.0.0.1:7000/add_student_save Django Version: 3.1.1 Exception Type: RelatedObjectDoesNotExist Exception Value: CustomUser has no students. Exception Location: C:\Python38\lib\site-packages\django\db\models\fields\related_descriptors.py, line 421, in __get__ Python Executable: C:\Python38\python.exe Python Version: 3.8.5 Python Path: ['C:\\Users\\X\\Documents\\Projects\\student-management-system\\student_management_system', 'C:\\Users\\X\\Documents\\Projects\\student-management-system\\student_management_system', 'C:\\Program Files\\JetBrains\\PyCharm ' '2020.1\\plugins\\python\\helpers\\pycharm_display', 'C:\\Python38\\python38.zip', 'C:\\Python38\\DLLs', 'C:\\Python38\\lib', 'C:\\Python38', 'C:\\Python38\\lib\\site-packages', 'C:\\Program Files\\JetBrains\\PyCharm ' '2020.1\\plugins\\python\\helpers\\pycharm_matplotlib_backend'] Server time: Tue, 29 Sep 2020 23:36:48 +0000
hey!
does anyone know how to resolve the WebSocket connection error in Django channels?
(anonymous) @ app.90585323ed6e.js:105
mightThrow @ jquery.js:3762
process @ jquery.js:3830
this is the error
fyi, I've deployed the app on Heroku so no, I don't have an nginx config.
How would I create migration? Was going to through terminal I am using pycharm, which i believe is running in a virtual environment.
How do you use the post-method to login to a website when the html is full of java scripts?
@willow iron Did you see this? https://stackoverflow.com/questions/50265590/heroku-app-error-during-websocket-handshake-unexpected-response-code-200
I followed a tutorial on how to make a multiplayer tetris game, here is the repo:
https://github.com/Leftier/tetris
It worked just fine on localhost so I tried to deploy it in heroku (https://tetr...
damn just noticed the subtle 200 vs 500 too.
Do you get anything in heroku logs on the server side? 500 is internal server error, so you might see more on that side?
yep I tried, it the problem lies regarding wss
have a look :
oh wow seems like a new error now
503
:))
Unavailable. Interesting.
I need help with DTL
How would I load in a variable into a static call
for example
And I want to add the "gun"
but I don't know what the file name is
I have this going through a loop which provides information needed (the file name)
"context"
no that's wrong
what's the field which has your image?
i believe it is project.description_image?
@surreal whale
is that what you wanna pass?
well yea
you gotta do project.description_image.url
instead
u knew that lmao
this is my app's routing
@willow iron anyone knows what's up w this?
sure
everything works in dev environment but well, in production, it just fucks w me. the problem is somewhere in wss and ws connections and I've been scratching my head for the past 7 hours :))
hmm does your admin work?
ofc yeah
everything works
but chat
chat works too in a sense
the thing is that when i message a user, there's an error in the console which I've noted, it's due to the wss/ws shit and when i reload the page, the messages are right there ( the ones i sent ). so basically, POST works, GET doesn't due to which I'm not able to get the data right then and there
which is actually the whole point of channels and yeah, that just doesn't work in production
oh it's you
wdym
nth, i have just seen u post ur project in showcase channel on django server
ah okay
this is my first time trying channels in production too btw so yeah, I'm probably making a noobish error that I'm not aware of OR...something else idk
I mean websockets on heroku can be kinda tricky
also didn't know until recently that Heroku disables workers by default so had to enable my worker just now, if I hadn't, my response times would've kept deteriorating lol
nope
i've got credits
student pack
just gonna exhaust those and move on to digital ocean, once those are exhausted, i'll just switch to aws xD
which version of channels r u using?
and django?
3.1.1
use re_path
...
url is deprecated in 3.1 i think
yup
django.conf.urls.url()alias ofdjango.urls.re_path()is deprecated.
lol okay but it's not remotely related to the problem
i'll fix it too in the meantime tho
I'm working on a API using Flask-Restx
I want to send a message with the edited user when the request was made using PATCH
How can I do that?
Thank you in Advance.
Trying to get helped from yesterday Night
something like this
{"user": {"id": ...}, "message": "user updated successfully"}
help
projecticons/ ?
just put : src="{{ project.description_image.url }}"
show project config man
make a media root
please?
is bad for production
ok then
I'm working on a API using Flask-Restx
I want to send a message with the edited user when the request was made using PATCH
How can I do that?
Thank you in Advance.
Trying to get helped from yesterday Night
something like this{"user": {"id": ...}, "message": "user updated successfully"}
@elfin tinsel
people use media root with AWS S3 Bucket all the time

wut lol, I mean u usually serve media and static directory through nginx if not using external storage
@marble carbon static is served w nginx, media is generally served w a cdn
cdn like s3
aws s3 isn't a cdn but it utilizes those origins
so in a sense, it functions like one
:incoming_envelope: :ok_hand: applied mute to @surreal whale until 2020-09-30 03:34 (9 minutes and 59 seconds) (reason: burst rule: sent 8 messages in 10s).
Python doing diety work here
i mean he did spam one word per message
@native tide this is a very weird error that I have seen can be solved by deleting the db
or changing browsers sometimes
i have no idea how it is solved
@willow iron the only thing special about s3 is that
bandwidth costs are quite low
yep
Can anyone solve this problem
Yeh it is weird @versed python and I can't delete the db also
export it if you need to preserve data, then recreate db from scratch
Yeh okay I ll try
No
No when I changed the browser it works perfectly
@native tide I think this error raised due to incorrect padding in your admin.py
@stable kite can you explain what that means?
How does one fix it?
@versed python it means it does not have proper indentation
@stable kite that doesn't seem right, would incorrent indent be a syntax error?
afaik it's not an indentation error but some binascii stuff i have no idea about
it's a base64 bug
yep
@versed python do you also have a similar problem?
even I had it once
i did
@native tide this is a very weird error that I have seen can be solved by deleting the db
@versed python i solved it using this
maybe be try clearing the session from the original browser?
ehh that was an old project, don't have any that data now
i'm just speculating here, the session might be storing some incorrect base64 value
well i did encounter it when using drf
ill see if that happens again and try clearing sessions
maybe be try clearing the session from the original browser?
@native tide can you try this?
For me it's not working @abstract kite
@native tide ah, next thing to try would be to truncate the django_session table
it'd reset all the active sessions
probably raise an issue in github with the relevant trace
Haii this isnt really a python doubt that i have its nore of a javascript doubt is this the right place to ask
Its like this, there is a button, when you click on this button i want to tell javascript to turn this button to a specific color but how do i tell javascript that this is the button you are supposed to change there are 12 more buttons there and i dont want to make a function for each of them.
Im new to prgramming peep im sorry if this is a super simple doubt or whatever, im a noob soo yeah 
If your not able to help because its a python server i dont really mind but it would be of great help if i could at least know where i can look for the answer
You can update the style of the button inside it's onclick event
Its like this, there is a button, when you click on this button i want to tell javascript to turn this button to a specific color but how do i tell javascript that this is the button you are supposed to change there are 12 more buttons there and i dont want to make a function for each of them.
@ornate lotus
You can use the for loop in the DOM
Yeah, have them in a common class and use getElementsByClassName() to loop over all of them
Ok if i do loop but how will i tell the loop that this is the button im lookin for
u can always give them an ID and call up on them seperatly
using DOM
as for the color
document.getElementById("button");
let b = document.getElementById("body");
let t = document.getElementById("text");
function myColor {
var i;
for (i = 0; i < colors.length; i++) {
return i;
}
u can simple use something like that
u can always give them an ID and call up on them seperatly
@native tide ya but i have like 12 buttons and i dont wanna make a function for each
@ornate lotus It's a function that includes all 12 buttons
Which?
Are you good at DOM?
@ornate lotus Well, are you good at accessing HTML elements with Id and TagName?
@ornate lotus Well, all buttons can be identified by accessing them with TagName, and only one button can be identified by id
Ya but that would mean 12 different functions for each button if i use id, and if i use tagname then with one button click all the buttons will change their colour
My obj: when i click the button the button that i clicked should change its colour.
Ya but that would mean 12 different functions for each button if i use id, and if i use tagname then with one button click all the buttons will change their colour
@ornate lotus
Yeah yes
But i dont want that to happen ๐
<div id="button-grid">
<div class="row row1">
<button class="box" id="box-1-1"></button>
<button class="box" id="box-1-2"></button>
<button class="box" id="box-1-3"></button>
<button class="box" id="box-1-4"></button>
</div>
<div class="row row2">
<button class="box" id="box-2-1"></button>
<button class="box" id="box-2-2"></button>
<button class="box" id="box-2-3"></button>
<button class="box" id="box-2-4"></button>
</div>
<div class="row row3">
<button class="box" id="box-3-1"></button>
<button class="box" id="box-3-2"></button>
<button class="box" id="box-3-3"></button>
<button class="box" id="box-3-4"></button>
</div>
<div class="row row4">
<button class="box" id="box-4-1"></button>
<button class="box" id="box-4-2"></button>
<button class="box" id="box-4-3"></button>
<button class="box" id="box-4-4"></button>
</div>
</div>
I think there is no way to do this other than document.getElementById ๐
Mhm no probz man thanks anyways ๐
@ornate lotus u kinda have to if u want to do them individually
Hmm ya ig ill prolly search around and see if theres any other way else imma just do it it this way
Btw thanx, you guys were a big help ๐๐.
@ornate lotus hey you can access the elemet calling the function with "this" object
oohhh
<!DOCTYPE html>
<html>
<body>
<button onclick="foo(this);">Click Here</button>
<button onclick="foo(this);">Click Here</button>
<button onclick="foo(this);">Click Here</button>
<button onclick="foo(this);">Click Here</button>
<script>
function foo(element)
{
if(element.style.background == "")
{
element.style.background = "#FF0000";
}
else
{
element.style.background = "";
}
}
</script>
</body>
</html>
sure
!paste
r u using any Framework
yes
react
yes ofc
lmao sry fr that
It's labelled in his file lol
umm...ig i have to bind that with an id but it isnt working
anyhelp pls?
hi
i want to move my links to the bottom and have less spaces between them. how can I accomplish this?
.links img{
width:90px;
height:60px;
}
.links footer{
text-align:Center;
}
.links {
height: 125px;
text-align: justify;
border: transparent;
min-width: 600px;
}
.links div {
width: 125px;
height: 100px;
display: inline-block;
background:none;
}
.links:after {
content: '';
width: 100%;
display: inline-block;
}
<footer>
<div class="links">
<div><img src="https://cdn.afterdawn.fi/v3/news/original/github-logo.png" alt="Github"></div>
<div><img src="https://i0.wp.com/www.cleverism.com/wp-content/uploads/2014/10/Medium-logo-dark.png?resize=500%2C265&ssl=1" alt="Medium"></div>
<div><img src="http://cdn.onlinewebfonts.com/svg/img_24593.png" alt="Linkedin"></div>
<div><img src="https://cdn.onlinewebfonts.com/svg/img_501721.png" alt="Email"></div>
</div>
</footer>
</body>
</html>
if you answer please ping me!!
Good Morning, anyone here to help out with some Django? I am in search of a good DatePicker widget that would allow to pick multiple days, not a range but lets say Monday, Thursday, and Friday.
@native tide Have you ever tried using bootstrap? It will simplify your life 10 fold
I haven't really used bootstrap but since this is a really small project Im not sure id want to use it
Oh ok
Don't. Use flexbox.
Nothing to import.
You'll be able to control the alignment and such way easier.
Learning how to use css flexbox and grid is a must for front end dev. So simple, no external dependencies.
@warm igloo Do you have experience with Django?
here
Thanks, I was looking at this earlier but it seems it only does date ranges. I might be blind ๐
what do you need?
So the user can select multiple days. But not necessarily a range.
Like for example, 9-01-2020, 9-05-2020, 9-07-2020
ohh
I currently have a working date range picker, but I need different functionality (the one i described) elsewhere.
I mean it can be done using the front-end itself
without involving Django in it
this for example, does what you want
yeah
๐
Oh that second one is even better
I guess my googling skills are not as good as I thought lol
I guess you could say I am close
What is the correct http method for a 'like' button? I don't have fb to check what they are using. I know I can't use get, as that wouldn't be safe. Put, but without any payload as I will just be upping a counter by 1?
This channel helps with flask, i assume that includes werkzeug?
I'm unable to print the json data received from a POST request
'Request' object has no attribute 'get_json'
Ngrok tells me I am receiving a valid json request
from werkzeug.wrappers import Request, Response
import json
@Request.application
def application(request):
data = request.get_json(force=True)
print(data)
return Response('Data Received')
if __name__ == '__main__':
from werkzeug.serving import run_simple
run_simple('localhost', 5000, application)
So i got it working the only issue is it llikes to cover the input field. I set the orientation to bottom auto and the off set seems to be off. What would be a good way to fix this?
is there any method to find out the relationship between models...like if my model is related to other model by a foreign key or one-to-one .. so is there any way to get those models from django? (i am asking something like get_related_models() or something...idk if it exists)
Could you say me how can I scrape AJAX data with Scrapy?
@marble carbon my issue got solved yoooo
god
They were mostly server related issues and had nothing to do with most of the code itself
Did have to change my app's routing to wss instead of ws tho
And also needed to configure the correct Redis url but apart from that it was mostly regarding the server
But yeah, finally xD
Hi
Can we create a war file of django project?
How can we do packaging of django project
?
Hi, I'm having some trouble trying to render/redirect from form submissions to other form submissions. I am wondering whether django's render function actually calls the appropriate view function that corresponds to the template you want to render even if its not a redirect
Hi, I'm having some trouble trying to render/redirect from form submissions to other form submissions. I am wondering whether django's
renderfunction actually calls the appropriate view function that corresponds to the template you want to render even if its not aredirect
@surreal harness seems interesting. Can you describe the issue a bit more with your code?
basically, i have the user sign up with a signup form. they get sent a verification code that they have to confirm, but i don't want them to retype their email. so i render a new form and pass email as part of the context. something like
def signup(request)
form = SignupForm()
...
if form valid:
email = form.get('email')
context['email'] = email
...make the user and send them the confirmation email and all that jazz
form = EnterVerificationCodeForm()
context['form'] = form
return render(request, 'enter_verification_code.html', context)
and then there's another view function for enter_verification_code
def enter_verification_code(request)
if not request.get('email')
...don't access this without the appropriate context
redirect(somewhere else)
else:
form = EnterVerificationCodeForm(request.POST or None)
if form valid:
verification_code = request.get('verification_code')
backend_authenticate(verification_code, request.get('email'))
something like that, if u catch my drift
the behavior i'm getting isn't what is expected though
mostly because i'm trying to avoid just doing something like encoding the email and passing it as a url parameter because i wanted to see if there was another way
and i don't want to store an email in the session because i heard that can be dangerous but those are my fallbacks if I can't get this to work
rather, I want to understand why it isn't working I guess
when you submit the signup form and it is supposed to trigger the rendering of a new form, then you submit that form, i'm not entirely confident that the second form actually gets submitted in the view function i intend it to be submitted in
because when I check my django console output there aren't any debug statements regarding the second form (and my account didn't get confirmed anyway)
so essentially you want to have users verify their email they registered with, right?
is that the goal?
basically, i just don't want them to re-enter their email when they verify the code that gets sent to their email
okay got it
because then it would arbitrarily allow anyone to brute force a verification code
with a given email
I think I've read about it somewhere and there's something that can help you, if that doesn't work either lemme know
is it on the level of django form submission? or general authentication flows?
ok ill read through that and see
ah ok, that uses activation code link, but unfortunately i'm using a code instead of a link
maybe need to think about it more. the key difference here is that they generate a link and send it to the email. that link expires and keeps a key separate. in my flow i'm getting some code from the backend and sending it to them with no link, and just redirecting them to a place where they can enter that code in the front end
I want to make a chat app with Django, how do I start and where?
Anyone good with flask sqlalchemy please i need help so
Can someone help me with a bootstrap 4 issue, here is my code for reference. I'm trying to centre the grid row to the middle of the page https://jsfiddle.net/pL2ds4h3/
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
The grid row won't leave the bottom of the nav bar though
I've tried m-5 and p-5 but each won't centre it to the middle of the page
@west hollow ill try my best whats wrong?
is there a way to remove underline from the anchor tag links using html?
that falls under css
aight
@plush leaf Did you try putting the navbar in the head?
Yeah, still the same issue
any suggestions
on what i can place here?
or should i move down the car-showcase and put something else above it such as a search function ?
you could put a big 'ol hero image there with some meaningless description xD
"hero image"
dont do that though xD
xD alright
haha
this is my first project ever
for school
pretty ahead of my course
no one else knows even how to move shit hahaha
simplicity is often better than clutter.
You could style the background a bit with some simple colors, maybe make part of the background darker and center the cars? hmmmm, you could add a hero image, but that would probably make it too busy (this is a plug, but here is an example of a hero image https://littlelupine.us/)
honestly, it looks like your site is pretty minimalistic (which is not a bad thing)
So maybe move the cars to the center and see how that feels? you could maybe add a bit of a banner at the top with a title or something, if you want to fill space
ooo yea exactly moving the cars to the center
is what i though twould be fitting
should i simply just put margin-top to 50%?
or how else would i go for moving it to the center?
added margin-top to 10%
Anyone else hate Html footers
hi, so i am using flask and i am extending my nav bar to my index.html, but the nav bar css code and the index css code are gettign mixed up, anyway to fix this?
ping me if you have a answer
sounds like a jinja2 templating problem
in ur index, just put {% include 'nav.html' %} where it would be
and the nav.html file would contain the html markup. flask will automaticcally just insert the html for the nav into the index (or anywhere where its used)
as for css, just have a single css file that styles absolutely everything. thats simple enough. dont have to worry about if the right css file is loaded or some shit
@ember kayak
you can do that for any chunk of html what will be used accross different pages. you can also do it for ur head. so for example, just do
<head>
{% include 'head.html' %}
</head>
and in ur head.html just put ur linked js, css, and external dependacies and theyll be loaded for each page. example:
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<link rel="stylesheet" href="/css.css">
@tawdry magnet im a bit confused on what you are saying
same
wanna see my code?
i dont understand the problem
one is being open directly in the browser as html the other is served with flask
is there any templating?
there has to be some reason the raw html looks different than what flask servers
oh, or maybe ur problem is its caching
just keep dev tools open and disable cache in the networking tab (just a guess that maybe caching is the problem)
wtf does that mean
UHG IDFK
<link rel="stylesheet" href="static/base.css">
@tawdry magnet thats how i link a css sheet
right
its not showing any css
the site is clearly styled
take a look at your browsers dev-tools Network tab (F12). To see if any resources lead to 404 or some other error when reloading the page.
@tawdry magnet did you try making <div> for each numbers of blocks? or what's exactly your problem
Hi
@tawdry magnet did you try making <div> for each numbers of blocks? or what's exactly your problem
@wanton ridge im not the one with the issue
I want to create a django project on jython. What are the steps to be followed for creating a project, execution and also for deployment..
Can anyone help me please
?!!!
you going for backend or frontend with django?
But actually when nvm sorry.
How to encrypt data in JavaScript & decrypt it in Python using AES encryption?
hey guys I want to build a website that does the following
- Its a plain website with an option to upload a cat/dog image using the upload button
- after uploading it must run a python code in the background and get its output
- and show the output on the website whether the image is a cat/dog
I basically trained a model which recognizes whether the image is a cat or dog with approx 90% accuracy
if anyone is interested please ping me.
btw its an open source project
so your contribution is also appreciated ๐
https://www.edx.org/course/cs50s-web-programming-with-python-and-javascript
CS50's Web Programming with Python and JavaScript | edX
@crude crane here
I'm trying to makea website with Quart, and i'm having problems with using JS functions inside a js file. The file is loaded correctly, but sometimes when I use any function there I get the error funcName is not defined. any idea why that is?
hey discord, i need your help!
so i made this project where its an AI bot playing tic tac toe. but i want to center it to the middle of the page and put the restart game button under the game.
here is my github link, please help โฌ๏ธ
https://github.com/willcanino/Tic-Tac-Toe
TAG ME
Creating a model in Django that has a manytomany relationship with another. I made a CreateView template which has a HTML template to select multiple models. The HTML select tag is populating the options with the model.str() function. Is it possible to override this to another model method?
The documentation on the str describes what is happening: https://docs.djangoproject.com/en/3.1/ref/models/instances/#str
I want to overwrite what is returned to a django template
while maintinging the str functionality
I want to overwrite what is returned to a django template
@solar ridge not directly possible
ok so im trying to make a website where if i fill a certain form and enter a certain word in the search field it runs a python program for me and prints the output in the website how can i achieve that using django?
@proven orchid You can add an event listener on the search form and check every second if the required word is typed. If it is, fire an ajax function. This ajax function will send a request to a django view which will then run your required python program.
Even though I said ajax, this will be easier in something like Vuejs using event listeners and axios.
@proven orchid You can add an event listener on the search form and check every second if the required word is typed. If it is, fire an ajax function. This ajax function will send a request to a django view which will then run your required python program.
Even though I said ajax, this will be easier in something like Vuejs using event listeners and axios.
so no need of a restful api? or such?
there's an event called keyup
that'll tell u when the user has typed anything, but you'll need to add a check in case user has used backspace, so check the length of the input text
@proven orchid the django view that the ajax will call will return JsonResponse objects so its kinda an api but i dont think you need django rest framework for such a small task.
gotcha...thanks
Hey! I need help, would be very grateful if someone can assist
I have to create URLs for resource download, whenever a URL is requested for a resource, it has to be provided.
The URL expires after a certain time, and if requested again after that time limit for the same resource I've to generate another URL, so on.
(Django)
There is a problem in my website with those card elements
the more info btn overlaps a piece of the content
this is the site
when you click inspect it all displays accordingly,
oh hmm
Your logged in right?
Have you found what might cause the cards to display like that.
the Username fontSize could be the problem but I set it like that. The shorter the username, the bigger the text.
it's because of position absolute
where
well, that fixed it
but
I want the more info btn to stick to the btm of the article element
idk what you mean by stick, it is at the bottom rn
@proven orchid wanna create a django project on jython
Would here be the right place to ask a question receiving a Bad Request (400) error from a Django project that is being hosted on an AWS server running ubuntu, with NGNIX as the webserver and Gunicorn as the middleware?
I can seem to figure out why when accessing the site via IP address, it loads the website correctly, but the IP DNS just sends a Bad Request (400) error.
Sounds like an issue on Nginx.. what do your logs say? @slim beacon
Are the logs located in /var/log/nginx or is it somewhere else?
Hello, I read yesterday that Django is the second web framework more used in github, I learned the basics of Flask (which is in the third position) and I don't know if I should continue with Flask or give a try to Django. Maybe learning the basics, what is your opinion on Django being the second most popular framework?
@slim beacon Should be yeah.
I am assuming its access.log since error.log does not have anything relevant
either or. Should have Gunicorn logs too
The Nginx access.log states the following
14.3.22.240 - - [01/Oct/2020:13:36:20 +0000] "GET / HTTP/1.1" 400 154 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0"
14.3.22.240 - - [01/Oct/2020:13:39:40 +0000] "GET / HTTP/1.1" 400 154 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0"
in /etc/nginx/nginx.conf do you have a server defined for the FQDN?
That points to the Gunicorn WSGI that is.
i do not believe so
You will need that..
here is an example of one I have using uWSGI
server_name fqdn.net;
location = / {
root /home/xxx/xxxx;
include uwsgi_params;
uwsgi_pass unix:/home/xxxxx/xxxxx/xxxx.sock;
uwsgi_param wsgi.py /swagger;
uwsgi_modifier1 30;
}
Will you please help me with creating a "snake" ?
Maybe something like that will help @slim beacon
@dawn lark Didn't work. I realized when you mentioned the Nginx configuration file, you were referring to the file in /etc/nginx/sites-available
@marble carbon In the settings file under ALLOWED_HOSTS, both the IP address and IP DNS are set
restart the project? You mean the server?
Or Nginx?
Let me reboot the server just in case
using gunicorn?
doing it now
no not the server itself
yeah then restart gunicorn
i have gunicorn automatically being run when the server is started using Supervisor
OMG IT WORKS
ughhhhhhhhh i spent hours on this....
thank you T_T
@marble carbon Thank you so much
@dawn lark Also thank you for your help
yea, whenever you make any changes to your project
restart gunicorn using that command instead of rebooting the server
Well noted!
๐
is django or flask better to get started?
Both are easy to get started with, but it usually depends on your use case
Hi everyone, I'm using HUG with wsgi but sometimes i get the follwoing error: ** ImportError: Interpreter change detected - this module can only be loaded into one interpreter per process.**
how can i force the hug app to not change the interpreter?
Hi! Anyone who can recommend a "cheap" webhost service? The current one costs me 3x more than 2 years ago and even 6x more from the start. Seems to be too much although I don't have really a clue about it.
digital ocean maybe?
@marble carbon Thanks! I have complained to the support and they are willing to let me pay the price of previous year. I'm ok with that but it's just for one time so I'll be back next year ๐
It's acceptable since I considered Belgian hosting but they are often (way) more expensive.
A quick question, I have application that will have two seperate users lets say admins, and staff. I want them to be two separate models but have them both be able to authenticate. Could I create a Employee model for example that has basic info that both admins and staff share (like name and so one) and also add the authentication stuff to that class. Then have two separate classes for admins and staff to add their specific things. Or should I make a OneToOne Relationship between the Admin and Employee classes and similarly with staff?
here
Now that I am reading it I have already read this lol. Forgot about the nice flowchart. Thanks
Hello,
How can I define dynamic schema with Pydantic,?
Here is example that I want to do like:
from pydantic import BaseModel
...
class SAMPLE(BaseModel):
id: int
name: str
???sample_dynamic_key : Optional[str]
hello can someone help me with css
i have just started css
and i just wanted to know how to put a logo and text in the same line
pls ping me ! thanks ! ๐
any chance someone could please eli5: connection pools?
and i just wanted to know how to put a logo and text in the same line
@winter spindle You must add a <i> or <img> in html + <p> or other and style with the "display:inline;"
Also, for CSS and HTMl, there is a LOT of stackoverflow thread with complete answers
ohh okay i will check that out ! thanks
@blissful urchin I use Digital ocean. great stuff. $5 a month for the smallest box droplet
@white tree I see, I'll take that one in consideration for next time
anyone familiar with sqlalchemy pool_recycle stuffs? Im having a problem where the connection pool is timing out and is unable to reconnect afterwards.
Hey guys, is flask fine for a newbie and should I use Flask-RESTful or some other libs for simple rest api with couple endpoints or just flask is fine?
and what is the file structure with flask? Do I create seperate folders for models, controllers etc or just files? ๐ค
hmm you might need a flask tutorial
one moment pls
sure
https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
The Flask Mega-Tutorial Part I: Hello, World!
here you go
thanks ๐
anyone here who knows react? ig theres an unexpected behaviour occuring but idk why
@proven orchid There's a react discord names ReactiFlux. They can help you with react
naemd*
named* fml
Ive been using regular ol flask to much success @tacit juniper
however I am having trouble with my connections not refreshing/recycling with sqlalchemy.
hm ok
I can ask a question about HTML in here correct?
I think the idea is more about python in the context of web dev
I am using HTML of course, and I am wanting to do a few things.
- When someone redirects to this page, I want to show an
<alert>, then once they click ok, show another and so forth for a few times - I also want to redirect to another page once they are done with those
Is there a way to sanely do this? I am not trying to do anything malicious, just set something up for a friend
ah too late
the answer to both your questions is javascript.
I jsut saw HTML in the description
and I would rather stay with HTML if possible... It just keeps my workflow saner
right, but thats not an option
unless theres something in html5 which now does alerts or redirects
I honestly wouldnt know haha
I am pretty sure there are alerts in HTML
only alerts Im aware of are through JS. alert(string);
I did find this though. https://www.w3docs.com/snippets/html/how-to-redirect-a-web-page-in-html.html
you could also make messages appear/disappear with css, but you'd still need a dom manipulator to trigger class changes
How do I make a Django crispy form mobile reponsive?
well, Im not familiar with django/crispy - but generally speaking you wanna use the right tool for the right job
and when I think "mobile responsive", I think CSS, not python
I suppose you could do some form of user agent detection and then respond accordingly with perhaps a separate form... but I feel like CSS would be the smarter call.
My form completely messes up and my footer too when screen size is changed
That blue bar is my footer
Basically the height of the Django form doesn't change along with it's parent div
imo - the answer lies in CSS.
without being able to examine the dom first hand - it looks like your form isnt a child of the container
Or likely an unclosed container div/etc
that could be it too.
Im by no means a guru.. but theres a lot of things that could be happening
Sometimes you just gotta use your fingers and count open and closed tags. ๐
dont be afraid to take off your socks
I want to simulate an AJAX call to the database in Django using the contents of a JSON file. Does anyone know what the best place to put this JSON file would be? templates or static don't really seem to make much sense, but neither does putting it in the same directory as the views.py file that will be opening the JSON file. Maybe I'm overthinking it, but if someone knows the best way to do this, please let me know.
what do you mean using the contents of a json file?
do you want to use json as a database?
@native tide No, I'm using a JSON file to simulate a database for the time being while I work on the front-end design. I don't want to make database models at this point. It's just a way to make sure the front-end is working properly.
I got it to work, but I'm not sure it's the best way. I just put the JSON file in the same directory as my views.py file that calls it. I use os.path.join(os.path.dirname(__file__), json_file.json) to access the JSON file.
ah ok
honestly I wouldn't worry too much about it, it's just gonna be replaced later
True, thanks for second opinion.
@native tide No, I'm using a JSON file to simulate a database for the time being while I work on the front-end design. I don't want to make database models at this point. It's just a way to make sure the front-end is working properly.
@topaz widget generally I put such things in aresfolder
but YMMV
okay, thanks.
@vestal hound does res stand for anything?
Is there an easy way to just upload an entire django project to github?
umm... use git?
@vestal hound does res stand for anything?
@native tide resources
so like src has code, bin has binaries, test has tests, and res has resources
it's usually something you see in other languages IME (in particular, src isn't common in Python) but well ๐คทโโ๏ธ
@versed python Do I have to commit it to master or could it be to a branch?
either one, it's your wish
My django project should be a repository? its my first git post
Anyone know why Gunnicorn is not working on ras pi?
hey does pygames work on 3.8.5?
My django project should be a repository? its my first git post
@plucky tapir yes your entire project
make sure you add a correct .gitignore this one would be fine https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
๐
Is there a way to view my users through a database? They were submitted through forms. right now I could only see them through admin. For django.
Also when I go through the sqlite3 I only see the models and other stuff entered
@plucky tapir You can use the Django shell. python manage.py shell
Then import your user model and enter the following command: user_model.objects.all()
@topaz widget Canโt wait to try that in the morning thanks
@plucky tapir You can also use python manage.py dbshell which will drop you into the database itself and you can execute SQL queries.
Sounds good. I had done an sql command to get into it earlier. And it had not worked so well. A question real quick I should always be using a virtual environment in django? Does it pick up from where I left off when I leave or rebuilds new every time after deactivating?
does anyone know how to use transitions correctly in css
i know this is a python server, but i need help
@long barn
Let's talk about CSS animations. Movement on the web. In this part 1 of the series we talk about css transitions.
Animatable CSS Properties: http://oli.jp/2010/css-animatable-properties/
Performant Properties to Animate: http://www.html5rocks.com/en/tutorials/speed/high-perf...
here
@plucky tapir Idk what you mean by rebuilding, this isn't node. But yeah, the best practise for ANY python project is to use a virtual environment, but this is for a different reason, not anything to do with rebuilding.
If you deactivate in your virtual env, it does not get deleted and you don't need to "rebuild" it, if I understand the question correctly.
Just call . venv/bin/activate (or source venv/bin/activate, which is equivalent), and you will get back to the same venv with the same packages installed, same interpreter, etc.
rebuild sounds like an npm thing idk
yea that as well
If you rebuild a docker container, for instance, you may reinstall all the dependencies. Likewise, they may have meant recreating a virtual environment when they said "rebuilding."
oh right, in terms of Docker that makes more sense
can web apps (not website) be written with Python through the backend? I canโt seem to find much.
@trail axle python can only be used for backend yes
yeah I know that, but web apps specifically?
Instagram was originally built in python/django, so of course.
Python is a great back-end language.
ah so webapps are part of backend
Web apps run on the web, so they need a front-end...
The vast majority also use a back-end.
would they need JS?
Preferably
Depends what you have in mind. There is no one definition for a web app
But typically, they use: HTML/CSS/JavaScript on the front-end. Often with a JS framework/library (react is very popular, but I recommend Vue, which is simpler and more elegant IMO).
A back-end. That can be written in just about any language, but Django (python) is great for speed of development.
A database (postgresql is very popular with Django. You can also use NoSQL, like mongodb, but not really with Django. Maybe with Node/Express, which is Javascript-based, or Flask, or other options)
And a front-end <---> back-end connection, using REST of GraphQL
Hell yeah Vue FTW
do Django and Google App Engine do around the same thing?
Django probably does more, but for web apps.
never used Google App Engine ยฏ_(ใ)_/ยฏ
just heard of it today
But from what I understand, that is used for deployment, and supports different things, including django
k thanks
do Django and Google App Engine do around the same thing?
Django probably does more, but for web apps.
@trail axle no, they're different things
Django is a backend framework i.e. software that runs on a server that handles incoming HTTP requests by returning HTTP responses.
Google App Engine is a platform as a service (PaaS) offering that lets you host applications
so you could host Django on Google App Engine
Is the web framework 'bottle' similar to http server, i mean they are written in python so. What's exactly the difference?
Is the web framework 'bottle' similar to http server, i mean they are written in python so. What's exactly the difference?
@wanton ridge A web server serves files. Typically static files.bottleallows you to write dynamic web pages/apps in python.
You would normally have a webserver and wsgi server with bottle.
ahh thanks a lot@lethal orbit
Anywhere I can talk about C++?
in #ot0-fear-of-python @wanton turtle
Okay bye.
has anyone used Nativescript?
I just want to get a general idea from people who use it, to be able to decide if I should use it for my next project
Nope.
Why is Vue Js not the main frontend framework
What do you mean by a main frontend framework? There is no such thing as a main something. There are always alternatives.
How could I get the data of my current view in a string format and save it?
I want to somehow set the data from my view into a cache value manually
Does anyone have experience witht hat in django?
Sounds like something you could do in middleware easily enough. Maybe using the Cache framework, too.
I do
but there is a problem with constructing the key when I want to delete it so I somehow need to I guess contr5ol setting the cache manually @lethal orbit
As I try to get the key when I edit a specific model
And I dont have access to the real request
So page_cache doesnt seem to do the trick
That is unless I construct the key and save it in a database together with for example the username when I send a GET request to the cached form, what do you think about that? @lethal orbit
So then I could access that key name and delete a key with that name
Oh and sorry for pinging you twice
Not sure why you would need to save the key in a DB?
Just get the key from a function.
Can't you use the model's pk?
I want to save the key in the DB so I can access the cache key
as I cant use get_cache_key in the model function
So I want to save the key, user, view of the cache so I could using things I can access like the viewname and username in order to access the key I would need to delete
What's better for APIs? flask or FastAPI?
Still not quite getting what you are trying to do tbh ๐
We got any Bokeh users in here? Is it possible to use bokeh widgets on purely HTML tables? Basically I don't want to use a bokeh ColumnDataSource I want to make an HTML table and use the filter widget on it.
Any flask users in here? (Im new to flask btw.)
But is it possible to make a username/password with flask_admin, without flask_security?
Basically, there is only 2 "roles" in my code.
The user and the admin, you're either a user or an admin.
But for some reason i cant make a login to the admin :/
for web development is there a graphics option for python? like processing for js is there a library that works for drawing stuff on the web in python?
Drawing stuff on the web, not really, because python doesn't (really) run in the browser.
You have to use JS, canvas, webgl, etc.
I guess you could use a python back-end to generate a canvas ๐ค
You can also render things on the back-end in python...
Images, charts, PDFs, etc.
So, depending on your needs, yes and no @high jacinth
@lethal orbit I am trying to cache a page, and when I edit/create a instance of my Products model, I want to make that specific cache invalid
And I am trying to achive this in a on save receiver, and I need a way to get the certain key
HELP
HOW DO I PUT AN IMAGE IN A DIV
i have a school project and im running out of time
sorry for caps lock btw
If I have a React Component in my static directory, can I include it in my Django template with a simple <script> tag pointing to its location?
@long barn background image property, just set the size of the div to the image size
anyone have a working django app with aws lambda?
I've found a couple api gateway to wsgi adapters
Looks straightforward but are there any pitfalls?
Api gateway integration
How is Django considered hard....
All Django wants is that HttpResponse. Or an exception.
This is for views...
That a pretty common integration. No problem there
Still on part 3 of the tut, but eh, dont see the hard part in this
What will django give you? Views?
Anyway the main thing about lambda is that its ideal use case is for lightweight, simple use cases.
If you need external deps like django then deployments gets trickier.
My comment wasnt in relation to anyone elses @sage wadi
Just me blabering about Django while reading the tuts
Np. Im still wandering how does django interact with @tepid lark lambda
django returns views yeah
Static served from an S3 bucket
I'm value engineering this really
it's easy to pack all your python deps into a layer
What Django gives me really is an admin interface
I'm making an easier way to update legacy data without hacking on the terrible legacy app that consumes it.
Although with lambda prices the lifetime expenses for this app might be less than my hourly soon
Why is Vue Js not the main frontend framework
@haughty turtle I think React is actually used more widely. Some people, like myself, prefer to use Vue since React is maintained by Facebook.
@haughty turtle Also, there is also Angular, but it is a bit older and I think clunkier.
Yeah Angular is by Google and React is by Facebook, I totally want to stick with Vue as it is Open Source
The huge gap is suprising.
More people use React, but everyone knows Vue is easier to use.
Huge gap?
Job wise,
With React, you have to work with things like babbel (jsx).
More employeers request React.
Right. I just hate Facebook.
Same
Can't agree more
If I can get away with it, I won't ever use React. I don't trust Facebook one bit.
Funny employeers putting their trust on a monetized company, you would think they would prefer open source.
React is cool, really
Except for their release model.
No, functions! No, classes! No, HOCs! No, back to functions.
Expecting a mapping object, as JWT only supports JSON objects as payloads.
Someone knows how to solve this error in PyJWT?
Is the error that you are getting not self explanatory @twin glacier
what are you passing in where you are getting the error
you should be passing in a dict, a mappable object
Hi guys Iโm new on here . Iโm still kinda of a beginner and want to jump into backend development. I was wondering what you suggest Flask or Django?
Cheers I thinking of dedicating a month or two to learn then apply for jobs once Iโve got projects
Do I always have to learn frontend frameworks ?
if you want to be a full stack dev.
Just backend stuff but I thought youโd always have to have a UI to plug into it
someone creates the ui and passes that to you in which its your job to connect it with the backend framework
Ahh but what about when I comes to building projects for my cv surely Iโd need to be able to write my own frontend ?
you should be passing in a dict, a mappable object
@haughty turtle tks man, I solved, I was passing a str, and then i changed to a dict
@plucky meteor yea your going to want to grasp it, as again you will be in charge of connecting the front end with the backend, and for this reason is why you see people with pretty ugly projects in their porfolio, as their goal is to have a working product, not a clean ui.
Ahhh fair enough . Iโm not too good with design . So long as I can get it done with the UI . Iโll be alright ?
What do you guys suggest in hosting your django project, on your own, through port forward, just use a service? Project is still in development. What did you guys do initially for yourselves?
$5 DO server
or Docker image on your server of choice
Makes local testing extremely easy
@plucky tapir Using a hosting service will probably give you the best service for the lowest price. It's probably cheaper than the electricity used to keep a home server running with port forwarding and better than what you will probably be running it on, too.
I personally use Linode, which, for my small website is $5 / month. They usually have some promotions, too, so you might be able to get a few months free like I did when I first joined.
I don't know whether it's better than something like AWS or Digital Ocean, but I haven't really had any problems with it yet.
My server is about 2,000 miles away from where I live, but I can just access it from my local command line using ssh like it's on my computer.
+1 for Linode also
AWS is expensive unless you know how to game the always free offerings.
what about digital Ocean or gcp
You can have CloudFront plus Lambda and S3 hosting an app for pennies
but you have to jump through a lot of hoops
what about the dB
I like DO. It's cheap and straightforward
Run it on a t2 micro!
RDS is you're paying for monitoring and ease of use.
rds or ec2?
or one of the graviton arm instances
does RDS offer more besides setting it up for us and updates and backups and the monitoring?
other thing I might guess is availability?
Key rotation and multi AZ stuff
heh I never had to use those anw
It'd use it for work but at home I'm cheap
ik multi AZ but what does key rotation mean
Encryption key for static data can be updated automatically
Same with accounts passwords if go all in on secrets manager
(It's really SSM but makes AWS more money)
can you give an example of static data?
your database files at rest basically
hey im looking to build a website for a startup im creating
i know nothing about web development and don't know any languages
could someone steer me in the right direction for where I should start?
uh wordpress?
Well it might depend on what kind of product you are going to design?
if It's just a simple website describing your startup, then yeah wordpress
its a bit more than that there is going to be two types of accounts and profiles and an internal messaging system
well yeah then
haha
my hourly was ~50 last I freelanced
do you have an est. for how much entire project would cost
i couldn't really tell you
alright
yeah I have an idea we are planning to form LLC in Florida and we have business strat all planned out
but our startup idea is basically all online
I need to figure out some estimates to get website all set up to see if im willing to take a risk
you just poke around locally
there always seems to be freelancers willing to do that sort of thing
alright will do thanks
it's 2020 and django can't handle proper composite key columns 
yea exactly
Though I wonder if there are any optimisations specifically around a PK that would be more benificial
One thing that comes to mind are clustered indices
Ig?
unique together works just fine
i just had to alter a table to have an id field alongside the composite key
hey guys, im using xampp apache right. in my index.html i have a button. how can i make that button make a request to render another html file
cos i want to make a get request for another html file like change the page which is being shown
Using the documentation to change the attributes of a widget, I can't change the type attribute:
The class is updating, the the type remains the default "text"
I think the widget render call is overwriting what I set. Or is something else at play here?
https://docs.djangoproject.com/en/3.1/ref/forms/widgets/#styling-widget-instances the documentation i'm reading
class MyForm(forms.Form):
# stuff
class Meta:
widgets = {
'date_due': {'class': 'changed-class', 'type': 'date'}
}
This is the better method if you're not doing any special stuff in the __init__ method. @solar ridge
Thanks @versed python I'll give this a try. It definitely overrides the type attribute? On the road right now
@swift wren still need help?
@swift wren what framework are you using?
apache i think ?
im sorry this isnt python, im using html and php
thought id ask anyway
Hello, I am having a small issue I am trying to fix in this code
I would really appreciate anyone's help
I am trying to get the about section to float, but it should be at the top on the right, in alignment with the first blogpost
whenever I float the about section, it just doesn't go to the top
if anyone got a solution, I'd appreciate it very much, thanks
@sage wadi can you let me know what line, what position do I got fixed? I am just learning CSS and HTML this semester so got to be a little more detailed with me
In about css
.about
Then take the about container up in the html markup until its where u want it
@sage wadi so now I moved the container and got that fixed, appreciate the help with that
๐
Then remove the fixed position
Just use a basic table or grid if youre familiar
Give the columns width in %
we can't use table, teacher said grid only
Grid then
so am I not using grid though?
also what do I got fixed? are you talking about the container?
Im no grid expert though.
Use https://www.w3schools.com/css/css_grid.asp
To play and get what you need. Only after it sits ok add your contenr
Remove position: fixed from about
Use the try it
And fiddle with it
You need to first set the cols and then their inner content
that's actually what I did, but as I follow the requirements and try to add different stuff, that's when stuff start to get out of place
are you talking about the width? in about?
Nah. I meant remove what i told you to add at the begining
You probly didnt add it. Nevermind
yeah probably I didn't. I am kinda also thinking about starting from scratch but that's too much at this point
I only got 1 issue now
getting the social media and archives aligned with the about
got that done now finally ๐
now I need to get the greyed about area off the header, anything for that @still palm?
I m trying to build something like Youtube using Django .Can anyone tell how to implement this,efficiently?
The application should enable the admin to upload videos using an array of options such as a YouTube link, Amazon S3 bucket, normal uploads, and a website link.
Website should be highly scalable that is it should handle unlimited users, videos, and categories.
What database to use to make it highly scalable in Django?
@fallen mango Django itself recommends PostgreSQL for scalability.
there's Cloudinary
if you're looking for free stuff
for demo
and an easy option
But is Cloudinary scalable
you gotta pay more
there's Mux too
I mean Cloudinary is definitely more scalable than managing uploads yourself
@fallen mango I would think you would want to know where these normal uploads would be stored.
Amazon S3 bucket is recommended as well, but it offers no transformations and all
In his statement he is obligated to have option for youtube, S3 bucket and normal uploads.
whaatttt,seriously
yeahh...

they don't charge u, it's just to prevent spam
ohk,i'll see to it
Cloudinary requires no card tho
ohh, thanks for suggestion
there a django package for easy integration with it as well
Great
https://github.com/klis87/django-cloudinary-storage
klis87/django-cloudinary-storage: Django package ... - GitHub
this
unlimited videos lol
Hmm unlimited sounds a little far fetched
flask or django??
In my view, Django is good if you're going to generate HTML on the back-end. If you want an API + some modern JS front-end, go with FastAPI ) @muted stump
you can get modern JS with Dango o.o
What are the community thoughts on FastAPI vs Django
hey guys
i'd like to have your opinion about something
i'm currently learning new frameworks and it demotivates me to be honest, the list is too long, i would like to make one "entreprise-level" project by implementing it CI/CD and make it very performant so i chose a set of technologies but now that i have to learn all of this it demotivates me, i came from django and only did a bit of flask and now i decided to go for fastapi, so for the db i have to learn also the difference in terms of syntax between django orm and sqlalchemy, i wanted to make the async request to the db so i could use all the power of fastapi so then i have to learn about encode/databases, and it keeps going like that, because i have only small or no knowledges in a wide variety of tools and frameworks it actually frustrates me a lot to not work on my project and just spend my time reading and testing stuffs to learn
is this the wrong approach ? Should i give up on all of this and just do my project and maybe pick up only one new tool ?
If you have experience with Django, you can definitely stick with it.
It already has async support, async views, and it's getting an async ORM in 3.2
It is also mature, well tested, and well adopted by the industry.
I wouldn't worry about async that much. Depending on the job, you may not work on new projects, but maintain legacy services too.
Why are you switching frameworks mid way...
I imagine Django will make sure to catch up to FastAPI speeds if it is still faster, Django is much more organized from what I have read.
Hey guys, can i get some responses, what kinda project/task management tools do you guys use?
Trello is good
@marble carbon do you use it individually?
and why do you prefer it over a calendar
or over asan or monday?
Calendar?
yeah
Cool
Organize anything, together. Trello is a collaboration tool that organizes your projects into boards. In one glance, know what's being worked on, who's working on what, and where something is in a process.




