#web-development

2 messages ยท Page 94 of 1

surreal whale
#

s

simple sentinel
#

what does your settings file look like?

surreal whale
#

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?

simple sentinel
surreal whale
#

Nothing

#

blank file

#
from django.contrib import admin


# Register your models here.```
#

Oh I see

#

I'm dum

#

I need to register the tables

simple sentinel
#

You'll need to register the models you'd like to see in the admin side, yeah

surreal whale
#

Any easy way to do that?

#

is it this?

#
admin.register(model)
```?
simple sentinel
#

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)
surreal whale
#

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?

simple sentinel
#

It should be admin.site.register(models.DescriptionInfoBox) and etc

surreal whale
#

Oh

#

Ok works

#

thank you

native tide
#

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

willow iron
#

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.

plucky tapir
#

How would I create migration? Was going to through terminal I am using pycharm, which i believe is running in a virtual environment.

visual lake
#

How do you use the post-method to login to a website when the html is full of java scripts?

warm igloo
willow iron
#

yep

#

this doesn't do anything tbh

warm igloo
#

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?

willow iron
#

yep I tried, it the problem lies regarding wss

#

have a look :

#

oh wow seems like a new error now

#

503

#

:))

warm igloo
#

Unavailable. Interesting.

willow iron
#

new log

surreal whale
#

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"

marble carbon
#

no that's wrong

#

what's the field which has your image?

#

i believe it is project.description_image?

#

@surreal whale

surreal whale
#

No

#

Thats an image type

#

but it doesn't display the image

marble carbon
#

is that what you wanna pass?

#

well yea

#

you gotta do project.description_image.url

#

instead

surreal whale
#

Oh

#

OH I'm dum

#

I knew that thanks

#

@marble carbon

marble carbon
#

u knew that lmao

willow iron
#

this is my app's routing
@willow iron anyone knows what's up w this?

marble carbon
#

sure

marble carbon
#

never used channels man

#

sorry thatsokcri

willow iron
#

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 :))

marble carbon
#

hmm does your admin work?

willow iron
#

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

marble carbon
#

oh it's you

willow iron
#

wdym

marble carbon
#

nth, i have just seen u post ur project in showcase channel on django server

willow iron
#

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

marble carbon
#

I mean websockets on heroku can be kinda tricky

willow iron
#

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

zealous siren
#

Free Heroku?

#

If so, Heroku will auto stop your workers

willow iron
#

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

marble carbon
#

which version of channels r u using?

willow iron
#

2.1.1

#

no wait my bad

#

2.4.0

marble carbon
#

and django?

willow iron
#

3.1.1

marble carbon
#

use re_path

#

...

#

url is deprecated in 3.1 i think

#

yup

#

django.conf.urls.url() alias of django.urls.re_path() is deprecated.

willow iron
#

lol okay but it's not remotely related to the problem

#

i'll fix it too in the meantime tho

elfin tinsel
#

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"}
surreal whale
#

why doesn;t it work

marble carbon
#

bruh what

surreal whale
#

help

willow iron
#

projecticons/ ?

surreal whale
#

No

#

{{ project.description_image.url }} returns /image

marble carbon
#

just put : src="{{ project.description_image.url }}"

surreal whale
#

Doesn't work

#

because its stored in static

marble carbon
#

why would u store media files in static

willow iron
#

yeah this is so weird

#

xD

surreal whale
#

Because I don't know how media works

#

so

#

gun

marble carbon
#

show project config man

willow iron
#

make a media root

surreal whale
#

@marble carbon

#

I was told that media

elfin tinsel
#

please?

surreal whale
#

is bad for production

willow iron
#

what?

#

no

surreal whale
#

ok then

elfin tinsel
#

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

willow iron
#

people use media root with AWS S3 Bucket all the time

surreal whale
marble carbon
#

wut lol, I mean u usually serve media and static directory through nginx if not using external storage

surreal whale
#

ok sure

#

umm

willow iron
#

@marble carbon static is served w nginx, media is generally served w a cdn

#

cdn like s3

marble carbon
#

s3 is no cdn

#

cloudfront is cdn

willow iron
#

aws s3 isn't a cdn but it utilizes those origins

#

so in a sense, it functions like one

lavish prismBOT
#

: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).

marble carbon
#

lmfaooo

zealous siren
#

Python doing diety work here

marble carbon
#

i mean he did spam one word per message

native tide
versed python
#

@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

marble carbon
#

@willow iron the only thing special about s3 is that

#

bandwidth costs are quite low

willow iron
#

yep

native tide
#

Can anyone solve this problem

#

Yeh it is weird @versed python and I can't delete the db also

versed python
#

export it if you need to preserve data, then recreate db from scratch

native tide
#

Yeh okay I ll try

surreal whale
#

I got unmuted

#

ye

#

that was stupi

#

d

#

And in that time I set up a media url

marble carbon
#

well gg, next time you have a problem, just get muted

surreal whale
#

No

native tide
#

No when I changed the browser it works perfectly

versed python
#

@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?

abstract kite
#

@versed python it means it does not have proper indentation
@stable kite that doesn't seem right, would incorrent indent be a syntax error?

versed python
#

afaik it's not an indentation error but some binascii stuff i have no idea about

marble carbon
#

it's a base64 bug

versed python
#

yep

abstract kite
#

@versed python do you also have a similar problem?

marble carbon
#

even I had it once

versed python
#

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

abstract kite
#

maybe be try clearing the session from the original browser?

versed python
#

ehh that was an old project, don't have any that data now

abstract kite
#

i'm just speculating here, the session might be storing some incorrect base64 value

versed python
#

well i did encounter it when using drf

#

ill see if that happens again and try clearing sessions

abstract kite
#

maybe be try clearing the session from the original browser?
@native tide can you try this?

native tide
#

Okay wait

#

For me it's not working @abstract kite

abstract kite
#

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

ornate lotus
#

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 yert

#

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

native tide
#

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

ornate lotus
#

Ok if i do loop but how will i tell the loop that this is the button im lookin for

native tide
#

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

ornate lotus
#

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

native tide
#

@ornate lotus It's a function that includes all 12 buttons

ornate lotus
#

Which?

native tide
#

Are you good at DOM?

ornate lotus
#

No not very

#

But i have done some stuff with dom

native tide
#

@ornate lotus Well, are you good at accessing HTML elements with Id and TagName?

ornate lotus
#

Yes i am

#

I know how to do that

native tide
#

@ornate lotus Well, all buttons can be identified by accessing them with TagName, and only one button can be identified by id

ornate lotus
#

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.

native tide
#

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

ornate lotus
#

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>
native tide
#

I think there is no way to do this other than document.getElementById ๐Ÿ˜…

ornate lotus
#

Mhm no probz man thanks anyways ๐Ÿ˜

native tide
#

@ornate lotus u kinda have to if u want to do them individually

ornate lotus
#

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 ๐Ÿ˜Š๐ŸŽ€.

abstract kite
#

@ornate lotus hey you can access the elemet calling the function with "this" object

ornate lotus
#

oohhh

abstract kite
#
<!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>
ornate lotus
#

dude this iswht i needed xd

#

ahhh nice

#

thanx man

proven orchid
#

ok so can i post my js question here?

#

its more of a material ui question

marble carbon
#

sure

proven orchid
#

can u link me the pastebin pls?

#

ig its too long to post here

marble carbon
#

!paste

proven orchid
marble carbon
#

r u using any Framework

proven orchid
#

yes

versed python
#

react

proven orchid
#

yes ofc

marble carbon
#

ow ok, it'll be better to specify then

proven orchid
#

lmao sry fr that

quick cargo
#

It's labelled in his file lol

proven orchid
#

umm...ig i have to bind that with an id but it isnt working

proven orchid
#

anyhelp pls?

native tide
#

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!!

devout coral
#

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

native tide
#

I haven't really used bootstrap but since this is a really small project Im not sure id want to use it

devout coral
#

Oh ok

warm igloo
#

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.

devout coral
#

@warm igloo Do you have experience with Django?

marble carbon
#

here

devout coral
#

Thanks, I was looking at this earlier but it seems it only does date ranges. I might be blind ๐Ÿ˜

marble carbon
#

what do you need?

devout coral
#

So the user can select multiple days. But not necessarily a range.

#

Like for example, 9-01-2020, 9-05-2020, 9-07-2020

marble carbon
#

ohh

devout coral
#

I currently have a working date range picker, but I need different functionality (the one i described) elsewhere.

marble carbon
#

I mean it can be done using the front-end itself

#

without involving Django in it

#

this for example, does what you want

devout coral
#

Ha, that sir. Is good enough

#

Thanks

#

The rest I can handle myself

marble carbon
#

yeah

#

๐Ÿ˜

devout coral
#

Oh that second one is even better

#

I guess my googling skills are not as good as I thought lol

native tide
#

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?

marble carbon
#

post

#

without payload

native tide
#

Ah ok

#

Thank you ๐Ÿ™‚

timid nest
#

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)
devout coral
#

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?

native tide
#

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)

lavish dirge
#

Could you say me how can I scrape AJAX data with Scrapy?

willow iron
#

@marble carbon my issue got solved yoooo

marble carbon
#

how

#

@willow iron elaborate

versed python
#

god

willow iron
#

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

native tide
#

Hi

#

Can we create a war file of django project?

#

How can we do packaging of django project

#

?

plush leaf
#

Are bootstrap 4 questions welcome here?

#

don't wanna ruin the chat for others

surreal harness
#

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

willow iron
#

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
@surreal harness seems interesting. Can you describe the issue a bit more with your code?

surreal harness
#

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)

willow iron
#

so essentially you want to have users verify their email they registered with, right?

#

is that the goal?

surreal harness
#

basically, i just don't want them to re-enter their email when they verify the code that gets sent to their email

willow iron
#

okay got it

surreal harness
#

because then it would arbitrarily allow anyone to brute force a verification code

#

with a given email

willow iron
#

I think I've read about it somewhere and there's something that can help you, if that doesn't work either lemme know

surreal harness
#

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

native tide
#

I want to make a chat app with Django, how do I start and where?

west hollow
#

Anyone good with flask sqlalchemy please i need help so

plush leaf
#

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

nimble epoch
#

@west hollow ill try my best whats wrong?

proven orchid
#

is there a way to remove underline from the anchor tag links using html?

marble carbon
#

ye

#

text-decoration: none;

proven orchid
#

that falls under css

marble carbon
#

o h

#

u could do

#

style="text-decoration: none;"

proven orchid
#

aight

split steeple
#

@plush leaf Did you try putting the navbar in the head?

plush leaf
#

Yeah, still the same issue

cerulean pelican
#

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 ?

acoustic oyster
#

you could put a big 'ol hero image there with some meaningless description xD

cerulean pelican
#

a what what? lmao

#

whats a big ol hero image

acoustic oyster
#

"hero image"

cerulean pelican
#

like a literal

#

hero image

acoustic oyster
#

it is a giant image that covers a lot of the screen

#

haha

cerulean pelican
#

ohhhh

#

could u give an example?

acoustic oyster
#

dont do that though xD

cerulean pelican
#

xD alright

acoustic oyster
#

haha

cerulean pelican
#

this is my first project ever

#

for school

#

pretty ahead of my course

#

no one else knows even how to move shit hahaha

acoustic oyster
#

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

cerulean pelican
#

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%

twilit dagger
#

Anyone else hate Html footers

ember kayak
#

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

tawdry magnet
#

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">
ember kayak
#

@tawdry magnet im a bit confused on what you are saying

tawdry magnet
#

same

ember kayak
#

wanna see my code?

tawdry magnet
#

i dont understand the problem

ember kayak
#

ok, one sec

#

thsi is what its sopostr to look like

#

and this what it looks like

tawdry magnet
#

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)

ember kayak
#

what?

#

ok so, both css templates are mixing

#

and jacking it up

tawdry magnet
#

wtf does that mean

ember kayak
#

UHG IDFK

#

<link rel="stylesheet" href="static/base.css">

#

@tawdry magnet thats how i link a css sheet

#

right

tawdry magnet
#

u can i guess

#

i mean, the site obviously has styling so ofcourse

ember kayak
#

its not showing any css

tawdry magnet
versed lotus
#

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.

wanton ridge
#

@tawdry magnet did you try making <div> for each numbers of blocks? or what's exactly your problem

crude crane
#

Hi

tawdry magnet
#

@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

crude crane
#

does anybody know a good django course?

#

hi

#

please

#

?

native tide
#

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

#

?!!!

proven orchid
#

you going for backend or frontend with django?

wanton turtle
#

But actually when nvm sorry.

stable kite
#

How to encrypt data in JavaScript & decrypt it in Python using AES encryption?

native tide
#

hey guys I want to build a website that does the following

  1. Its a plain website with an option to upload a cat/dog image using the upload button
  2. after uploading it must run a python code in the background and get its output
  3. 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 ๐Ÿ™‚
marble carbon
#

@crude crane here

crude crane
#

thanks man

#

really apreciated

fading pike
#

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?

rotund token
#

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

solar ridge
#

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?

#

I want to overwrite what is returned to a django template

#

while maintinging the str functionality

vestal hound
#

I want to overwrite what is returned to a django template
@solar ridge not directly possible

proven orchid
#

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?

versed python
#

@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
#

@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?

marble carbon
#

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

versed python
#

@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.

proven orchid
#

gotcha...thanks

elder steeple
#

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)

native tide
#

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,

marble carbon
#

give demo account

#

asks for login

native tide
#

oh

#

Username: Sugar

#

Password: 12345foo

marble carbon
#

oh hmm

native tide
#

Your logged in right?

#

Have you found what might cause the cards to display like that.

marble carbon
#

yeah

#

okay

native tide
#

the Username fontSize could be the problem but I set it like that. The shorter the username, the bigger the text.

marble carbon
#

it's because of position absolute

native tide
#

where

marble carbon
#

in the anchor tag css

#

and change margin to '0 auto' instead

native tide
#

well, that fixed it

#

but

#

I want the more info btn to stick to the btm of the article element

marble carbon
#

idk what you mean by stick, it is at the bottom rn

native tide
#

@proven orchid wanna create a django project on jython

slim beacon
#

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.

dawn lark
#

Sounds like an issue on Nginx.. what do your logs say? @slim beacon

slim beacon
#

Are the logs located in /var/log/nginx or is it somewhere else?

vague knoll
#

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?

dawn lark
#

@slim beacon Should be yeah.

slim beacon
#

I am assuming its access.log since error.log does not have anything relevant

dawn lark
#

either or. Should have Gunicorn logs too

slim beacon
#

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"

dawn lark
#

in /etc/nginx/nginx.conf do you have a server defined for the FQDN?

#

That points to the Gunicorn WSGI that is.

slim beacon
#

i do not believe so

dawn lark
#

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;
        }
pulsar glen
#

Will you please help me with creating a "snake" ?

dawn lark
#

Maybe something like that will help @slim beacon

slim beacon
#

I am looking into it now!

#

Let me see if this will work ๐Ÿ™‚

marble carbon
#

ohh

#

did u set the domain in Allowed hosts settings?

#

in your Django project?

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

marble carbon
#

okay

#

did u restart your project?

slim beacon
#

restart the project? You mean the server?

#

Or Nginx?

#

Let me reboot the server just in case

marble carbon
#

using gunicorn?

slim beacon
#

doing it now

marble carbon
#

no not the server itself

slim beacon
#

yes, i am using gunicorn

#

oh

#

i didnt reboot yet

marble carbon
#

yeah then restart gunicorn

slim beacon
#

i have gunicorn automatically being run when the server is started using Supervisor

marble carbon
#

oh supervisor alright

#

then

#

sudo supervisorctl reload

#

would restart gunicorn

slim beacon
#

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

marble carbon
#

yea, whenever you make any changes to your project

#

restart gunicorn using that command instead of rebooting the server

slim beacon
#

Well noted!

marble carbon
#

๐Ÿ˜„

native tide
#

is django or flask better to get started?

candid wyvern
#

Both are easy to get started with, but it usually depends on your use case

graceful mauve
#

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?

blissful urchin
#

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.

marble carbon
#

digital ocean maybe?

blissful urchin
#

@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.

devout coral
#

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?

marble carbon
#

here

devout coral
#

Now that I am reading it I have already read this lol. Forgot about the nice flowchart. Thanks

stoic sundial
#

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]
winter spindle
#

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 ! ๐Ÿ˜„

white tree
#

any chance someone could please eli5: connection pools?

torn rock
#

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

winter spindle
#

ohh okay i will check that out ! thanks

white tree
#

@blissful urchin I use Digital ocean. great stuff. $5 a month for the smallest box droplet

blissful urchin
#

@white tree I see, I'll take that one in consideration for next time

white tree
#

anyone familiar with sqlalchemy pool_recycle stuffs? Im having a problem where the connection pool is timing out and is unable to reconnect afterwards.

tacit juniper
#

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? ๐Ÿค”

marble carbon
#

hmm you might need a flask tutorial

tacit juniper
#

I bet I need

#

๐Ÿ˜„

marble carbon
#

one moment pls

tacit juniper
#

sure

marble carbon
#

here you go

tacit juniper
#

thanks ๐Ÿ™‚

proven orchid
#

anyone here who knows react? ig theres an unexpected behaviour occuring but idk why

sturdy pike
#

@proven orchid There's a react discord names ReactiFlux. They can help you with react

#

naemd*

#

named* fml

proven orchid
#

aight bet really needed that

#

thanks alot

#

really

white tree
#

Ive been using regular ol flask to much success @tacit juniper

#

however I am having trouble with my connections not refreshing/recycling with sqlalchemy.

tacit juniper
#

hm ok

covert sky
#

I can ask a question about HTML in here correct?

white tree
#

I think the idea is more about python in the context of web dev

covert sky
#

I am using HTML of course, and I am wanting to do a few things.

  1. 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
  2. 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

white tree
#

the answer to both your questions is javascript.

covert sky
#

I jsut saw HTML in the description

#

and I would rather stay with HTML if possible... It just keeps my workflow saner

white tree
#

right, but thats not an option

#

unless theres something in html5 which now does alerts or redirects

#

I honestly wouldnt know haha

covert sky
#

I am pretty sure there are alerts in HTML

white tree
#

only alerts Im aware of are through JS. alert(string);

#

you could also make messages appear/disappear with css, but you'd still need a dom manipulator to trigger class changes

twilit dagger
#

How do I make a Django crispy form mobile reponsive?

white tree
#

flex

#

or media queries

#

or both

twilit dagger
#

No I mean as in it doesn't expand but shrink

#

Is media queries the only option

white tree
#

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.

twilit dagger
#

That blue bar is my footer

twilit dagger
#

Basically the height of the Django form doesn't change along with it's parent div

white tree
#

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

warm igloo
#

Or likely an unclosed container div/etc

white tree
#

that could be it too.

#

Im by no means a guru.. but theres a lot of things that could be happening

warm igloo
#

Sometimes you just gotta use your fingers and count open and closed tags. ๐Ÿ˜†

white tree
#

dont be afraid to take off your socks

topaz widget
#

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.

native tide
#

what do you mean using the contents of a json file?

#

do you want to use json as a database?

topaz widget
#

@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.

native tide
#

ah ok

#

what is your current file structure?

topaz widget
#

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.

native tide
#

ah ok

#

honestly I wouldn't worry too much about it, it's just gonna be replaced later

topaz widget
#

True, thanks for second opinion.

vestal hound
#

@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 a res folder

#

but YMMV

topaz widget
#

okay, thanks.

native tide
#

@vestal hound does res stand for anything?

plucky tapir
#

Is there an easy way to just upload an entire django project to github?

versed python
#

umm... use git?

vestal hound
#

@vestal hound does res stand for anything?
@native tide resources

native tide
#

aaaah

#

ok

vestal hound
#

so like src has code, bin has binaries, test has tests, and res has resources

native tide
#

oh damn

#

thats neat

vestal hound
#

it's usually something you see in other languages IME (in particular, src isn't common in Python) but well ๐Ÿคทโ€โ™‚๏ธ

plucky tapir
#

@versed python Do I have to commit it to master or could it be to a branch?

versed python
#

either one, it's your wish

plucky tapir
#

My django project should be a repository? its my first git post

sleek owl
#

Anyone know why Gunnicorn is not working on ras pi?

slate spear
#

hey does pygames work on 3.8.5?

versed python
#

My django project should be a repository? its my first git post
@plucky tapir yes your entire project

plucky tapir
#

๐Ÿ‘
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

topaz widget
#

@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()

plucky tapir
#

@topaz widget Canโ€™t wait to try that in the morning thanks

versed python
#

@plucky tapir You can also use python manage.py dbshell which will drop you into the database itself and you can execute SQL queries.

plucky tapir
#

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?

long barn
#

does anyone know how to use transitions correctly in css

#

i know this is a python server, but i need help

marble carbon
#

@long barn

#

here

versed python
#

@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.

lethal orbit
#

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.

marble carbon
#

rebuild sounds like an npm thing idk

lethal orbit
#

Yes, but sometimes people ask the wrong question ๐Ÿ˜…

#

By their choice of words.

marble carbon
#

yea that as well

lethal orbit
#

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."

marble carbon
#

oh right, in terms of Docker that makes more sense

trail axle
#

can web apps (not website) be written with Python through the backend? I canโ€™t seem to find much.

quick cargo
#

@trail axle python can only be used for backend yes

trail axle
#

yeah I know that, but web apps specifically?

lethal orbit
#

Instagram was originally built in python/django, so of course.

#

Python is a great back-end language.

trail axle
#

ah so webapps are part of backend

lethal orbit
#

Web apps run on the web, so they need a front-end...

#

The vast majority also use a back-end.

trail axle
#

would they need JS?

lethal orbit
#

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

marble carbon
#

Hell yeah Vue FTW

trail axle
#

do Django and Google App Engine do around the same thing?
Django probably does more, but for web apps.

lethal orbit
#

never used Google App Engine ยฏ_(ใƒ„)_/ยฏ

trail axle
#

just heard of it today

lethal orbit
#

But from what I understand, that is used for deployment, and supports different things, including django

trail axle
#

k thanks

vestal hound
#

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

wanton ridge
#

Is the web framework 'bottle' similar to http server, i mean they are written in python so. What's exactly the difference?

lethal orbit
#

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. bottle allows you to write dynamic web pages/apps in python.

#

You would normally have a webserver and wsgi server with bottle.

wanton ridge
#

ahh thanks a lot@lethal orbit

wanton turtle
#

Anywhere I can talk about C++?

versed python
wanton turtle
#

Okay bye.

marble carbon
#

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

wanton turtle
#

Nope.

haughty turtle
#

Why is Vue Js not the main frontend framework

versed python
#

What do you mean by a main frontend framework? There is no such thing as a main something. There are always alternatives.

limber laurel
#

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?

lethal orbit
#

Sounds like something you could do in middleware easily enough. Maybe using the Cache framework, too.

limber laurel
#

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

lethal orbit
#

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?

limber laurel
#

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

weary dragon
#

What's better for APIs? flask or FastAPI?

lethal orbit
#

Still not quite getting what you are trying to do tbh ๐Ÿ˜…

slender whale
#

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.

lean rapids
#

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 :/

high jacinth
#

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?

lethal orbit
#

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

limber laurel
#

@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

long barn
#

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

marble carbon
#

hm

#

background-image using CSS?

native tide
#

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?

tepid lark
#

@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?

sage wadi
#

Do you programatically intend to trigger the lambda?

#

Or use aws triggers?

tepid lark
#

Api gateway integration

haughty turtle
#

How is Django considered hard....

#

All Django wants is that HttpResponse. Or an exception.

#

This is for views...

sage wadi
#

That a pretty common integration. No problem there

haughty turtle
#

Still on part 3 of the tut, but eh, dont see the hard part in this

sage wadi
#

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.

haughty turtle
#

My comment wasnt in relation to anyone elses @sage wadi

#

Just me blabering about Django while reading the tuts

sage wadi
#

Np. Im still wandering how does django interact with @tepid lark lambda

tepid lark
#

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

topaz widget
#

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.

marble carbon
#

yes

#

Vue FTW

topaz widget
#

@haughty turtle Also, there is also Angular, but it is a bit older and I think clunkier.

haughty turtle
#

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.

wicked tide
#

More people use React, but everyone knows Vue is easier to use.

topaz widget
#

Huge gap?

haughty turtle
#

Job wise,

topaz widget
#

With React, you have to work with things like babbel (jsx).

haughty turtle
#

More employeers request React.

topaz widget
#

Right. I just hate Facebook.

haughty turtle
#

Same

marble carbon
#

Can't agree more

topaz widget
#

If I can get away with it, I won't ever use React. I don't trust Facebook one bit.

haughty turtle
#

Funny employeers putting their trust on a monetized company, you would think they would prefer open source.

topaz widget
#

I KNOW, RIGHT?

#

Boggles my mind.

#

The corporate world is a fucking madhouse.

tepid lark
#

React is cool, really

#

Except for their release model.

#

No, functions! No, classes! No, HOCs! No, back to functions.

twin glacier
#

Expecting a mapping object, as JWT only supports JSON objects as payloads.

#

Someone knows how to solve this error in PyJWT?

haughty turtle
#

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

plucky meteor
#

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?

haughty turtle
#

They say Flask is a better choice for beginners

#

@plucky meteor

plucky meteor
#

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 ?

haughty turtle
#

if you want to be a full stack dev.

plucky meteor
#

Just backend stuff but I thought youโ€™d always have to have a UI to plug into it

haughty turtle
#

someone creates the ui and passes that to you in which its your job to connect it with the backend framework

plucky meteor
#

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 ?

twin glacier
#

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

haughty turtle
#

@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.

plucky meteor
#

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 ?

plucky tapir
#

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?

acoustic oyster
#

I host mine through my own server haha.

#

I always recommend raspi

tepid lark
#

$5 DO server

#

or Docker image on your server of choice

#

Makes local testing extremely easy

topaz widget
#

@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.

marble carbon
#

haha

#

I thought you were talking about placing your rpi away then using ssh

haughty turtle
#

+1 for Linode also

tepid lark
#

AWS is expensive unless you know how to game the always free offerings.

marble carbon
#

what about digital Ocean or gcp

tepid lark
#

You can have CloudFront plus Lambda and S3 hosting an app for pennies

#

but you have to jump through a lot of hoops

marble carbon
#

what about the dB

tepid lark
#

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.

marble carbon
#

rds or ec2?

tepid lark
#

or one of the graviton arm instances

marble carbon
#

does RDS offer more besides setting it up for us and updates and backups and the monitoring?

#

other thing I might guess is availability?

tepid lark
#

Key rotation and multi AZ stuff

marble carbon
#

heh I never had to use those anw

tepid lark
#

It'd use it for work but at home I'm cheap

marble carbon
#

ik multi AZ but what does key rotation mean

tepid lark
#

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)

marble carbon
#

can you give an example of static data?

tepid lark
#

your database files at rest basically

native tide
#

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?

tepid lark
#

uh wordpress?

marble carbon
#

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

native tide
#

its a bit more than that there is going to be two types of accounts and profiles and an internal messaging system

marble carbon
#

well yeah then

tepid lark
#

find a guy to go in with you

#

or have lots of money

marble carbon
#

haha

tepid lark
#

my hourly was ~50 last I freelanced

native tide
#

do you have an est. for how much entire project would cost

tepid lark
#

i couldn't really tell you

native tide
#

alright

tepid lark
#

a landing page is super cheap

#

but sounds you have an idea for an online startup>?

native tide
#

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

tepid lark
#

you just poke around locally

#

there always seems to be freelancers willing to do that sort of thing

native tide
#

alright will do thanks

tepid lark
#

it's 2020 and django can't handle proper composite key columns mad

marble carbon
#

wdym

#

there's unique together

proper hinge
#

Yeah, that's not "proper" though

#

Though you can effectively get the same thing

marble carbon
#

yea exactly

proper hinge
#

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

hearty nova
#

Ig?

tepid lark
#

unique together works just fine

#

i just had to alter a table to have an id field alongside the composite key

swift wren
#

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

solar ridge
#

Using the documentation to change the attributes of a widget, I can't change the type attribute:

#

I think the widget render call is overwriting what I set. Or is something else at play here?

versed python
#
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

solar ridge
#

Thanks @versed python I'll give this a try. It definitely overrides the type attribute? On the road right now

versed python
#

I have used it in the past, worked for me

#

No reason for it to not work for you

haughty turtle
#

@swift wren still need help?

swift wren
#

ive not figured it out

#

so yeah if you have a solution

haughty turtle
#

@swift wren what framework are you using?

swift wren
#

apache i think ?

#

im sorry this isnt python, im using html and php

#

thought id ask anyway

white spruce
#

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
#

Position: fixed. And move the about container to the correct place

#

@white spruce

white spruce
#

@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

sage wadi
#

In about css

#

.about

#

Then take the about container up in the html markup until its where u want it

white spruce
#

@sage wadi so now I moved the container and got that fixed, appreciate the help with that

sage wadi
#

๐Ÿ‘

#

Then remove the fixed position

#

Just use a basic table or grid if youre familiar

#

Give the columns width in %

white spruce
#

we can't use table, teacher said grid only

sage wadi
#

Grid then

white spruce
#

so am I not using grid though?

#

also what do I got fixed? are you talking about the container?

sage wadi
white spruce
#

that's what I been using to get to this point ๐Ÿ˜„

#

that exact page

sage wadi
#

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

white spruce
#

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?

sage wadi
#

Nah. I meant remove what i told you to add at the begining

white spruce
#

a bit confused on what you saying I should remove

#

what line is it at

sage wadi
#

You probly didnt add it. Nevermind

white spruce
#

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?

fallen mango
#

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?

white spruce
#

oh my bad

#

still trying to fix this css problem, you think you can help?

white spruce
#

I figured it out!

#

wooo

haughty turtle
#

@fallen mango Django itself recommends PostgreSQL for scalability.

fallen mango
#

ok

#

and any idea about uploading videos

#

?

marble carbon
#

there's Cloudinary

#

if you're looking for free stuff

#

for demo

#

and an easy option

haughty turtle
#

But is Cloudinary scalable

marble carbon
#

you gotta pay more

#

there's Mux too

#

I mean Cloudinary is definitely more scalable than managing uploads yourself

haughty turtle
#

@fallen mango I would think you would want to know where these normal uploads would be stored.

marble carbon
#

Amazon S3 bucket is recommended as well, but it offers no transformations and all

haughty turtle
#

In his statement he is obligated to have option for youtube, S3 bucket and normal uploads.

marble carbon
#

Yeah s3 then, use django-storages

#

p easy

#

with it, just gotta learn AWS S3 tho

fallen mango
#

yeh, i searched about amazon s3

#

looks good for big data storage

marble carbon
#

you can get free tier for first year

#

but you'll need to enter credit card :)

fallen mango
#

whaatttt,seriously

marble carbon
#

yeahh...

fallen mango
marble carbon
#

they don't charge u, it's just to prevent spam

fallen mango
#

ohk,i'll see to it

marble carbon
#

Cloudinary requires no card tho

fallen mango
#

ohh, thanks for suggestion

marble carbon
#

there a django package for easy integration with it as well

fallen mango
#

Great

marble carbon
#

this

#

unlimited videos lol

haughty turtle
#

Hmm unlimited sounds a little far fetched

marble carbon
#

unlimited comes with a cost

#

๐Ÿ’€

muted stump
#

flask or django??

vapid minnow
#

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

haughty turtle
#

you can get modern JS with Dango o.o

#

What are the community thoughts on FastAPI vs Django

strange briar
#

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 ?

lethal orbit
#

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.

haughty turtle
#

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.

sudden grail
#

Hey guys, can i get some responses, what kinda project/task management tools do you guys use?

marble carbon
#

Trello is good

sudden grail
#

@marble carbon do you use it individually?

#

and why do you prefer it over a calendar

#

or over asan or monday?

marble carbon
#

Calendar?

sudden grail
#

yeah

marble carbon
#

how would u use a calendar

#

okay wait lemme show j

#

u

sudden grail
#

Cool

marble carbon