#web-development

2 messages · Page 98 of 1

stable kite
#

you should only use date field

outer pier
#

is there any possible way to do with datetime ?

stable kite
#

i think not because it stores time also but when you receive bet it's not the same time when you created it

#
class CreateBet(models.Model):
    owner = models.ForeignKey(settings.AUTH_USER_MODEL,related_name="bets",null=True, on_delete=models.CASCADE)
    bet_name= models.CharField(max_length=255)
    amount = models.CharField(max_length=255) 
    scheduled_datetime = models.DateField()```
#

this model should work for you

outer pier
#

but storing time is necessary for me .

stable kite
#

then you should use the same time for getting data

outer pier
#

ok I think I get it . Thank you for your time...

stable kite
#

@outer pier i think you should use lte in query to get data

outer pier
#

lte means less than i guess

#

ok lemme try

stable kite
#

less than equal to

#

because the time of creation is less than time of retrival

outer pier
#

yah you are right .

#

may be i should check it out . thank you so much

stable kite
#

no problem

outer pier
#

its still not working lte is having the value today andd previously created one

#

even gt is having the value today and upcoming one

sudden grail
#

Do you think it’s a growing market?

#

Do you find these kinda apps useful?

#

Thanks for any feedback in advance!

lean rapids
#

anyone know of a way of saying if the username is admin , they get access to the admin panel in flask?
currently with the "current_user.is_authenticated()" , everyone as long as they are logged in, get access to the admin panel.
But i want it that so if the username == admin, they get access, but only then.

native tide
#

is it good design to have a back button on page which takes user back to previous page or no?

mint folio
#

If it just replicates the browser back button then no. Users already know about the browser back button, or if on mobile the swipe. So if the browser gives you this option, and the users know it exists already, then why include a redundant version of this.

native tide
#

oh

stable kite
#

@outer pier use both lte & gte

#

@outer pier use lte with to today's datetime & gte with yesterday's datetime

#

@outer pier py def get_queryset(self): today = datetime.datetime.today() yesterday=today - datetime.timedelta(days = 1) return CreateBet.objects.filter(Q(scheduled_datetime__gte=yesterday) & Q(scheduled_datetime__lte=today))

outer pier
#

thankz

def get_queryset(self):
        def get_queryset(self):
        today = datetime.date.today() 
        return CreateBet.objects.filter(Q(scheduled_datetime__gt=today)).exclude(scheduled_datetime__date=today)
#

worked for me

#
def get_queryset(self):
        today = datetime.date.today()
        return CreateBet.objects.filter(scheduled_datetime__date=today)
#

todays bet

#

anyway thanq so much @stable kite for the time

stable kite
#

ok

winter spindle
#

hello

#

can someone help with how to enter font awesome fonts in my project

versed python
#

@winter spindle go to their website, click on get font awesome

#

you'll probably have to enter your email id, and then get the cdn in your email

#

use it between <script> tags as you normally would

winter spindle
#

ohh okay await i ll check and tell

#

bro how to get the CDN

#

@versed python

proud falcon
winter spindle
#

bro what is tht kit

#

i dont use bootstarp

#

i like have a kit so should i copy its script ?

#

okya thanks i got it !

proud falcon
#

np :)

marble carbon
#

Has anyone ever submitted their Google OAuth App for verification?

#

If so, can you tell me about the process, what are the criteria that they check and all

uneven radish
#

Hi. Can anyone clear my doubt regarding Django and API call?

#

I am calling an API which will return data in JSON format, I am not planning to save any data into database. So should I make a model or directly render it on webpage?

stable kite
#

@uneven radish why should yo make model if you don't want to store data in database

uneven radish
#

How to use List View then? Without model?

proud falcon
#

If I understand correctly, you can add the json data in your context in the view, and then display it in your template file.

uneven radish
#

Oh cool. Thanks. I'll try that.

uneven radish
#

@proud falcon NewsListView is missing a QuerySet. Define NewsListView.model, NewsListView.queryset, or override NewsListView.get_queryset().
This error is coming.

proud falcon
#

a listview is a generic view for listing objects (the ones from models.py), so I suggest you to switch to a TemplateView, which does not requires any model :)

high jacinth
#

Help pls, can anyone direct me to a newbie friendly framework for testing asynchronous requests? Fake responses, httpstatus codes etc?

visual iron
#

hey guys i need to make a key value as a constant in my whole web application. how do i tackle this? i dont even know what to seach... im using flask, or you could give me something to search for or startwith

native tide
#

Help pls, can anyone direct me to a newbie friendly framework for testing asynchronous requests? Fake responses, httpstatus codes etc?
@high jacinth DRF it set up for doing this fairly well. Not sure if it meets your other criteria though.

nova shadow
#

How do I use Expires Headers in Flask?

high jacinth
#

@native tide DRF? What is that in full?

native tide
#

Django Rest Framework. I'm not on a work machine right now or I'd show you the default HTTP page you get when you set up an endpoint.

#

But look into it, its something you can add on to Django and makes serving an HTTP API very straight forward

#

If you're not already using Django it might be a bit more than you need

high jacinth
#

Unfortunately im not using django at all

#

Thanks anyway

quick cargo
#

@high jacinth to test a framework receiving the requests or a framework to test the requests being sent?

high jacinth
#

A framework to test the requests im sending.

quick cargo
high jacinth
#

Ok

#

Lets say for example I wanted to check if my fetch function waits long enough before retrying, can I do that here?

#

Or if it reacts to a 404 the right way

quick cargo
#

err if you wanna do that just make a simple flask app

#
from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()```
high jacinth
#

i think i get it

#

thanks

untold lotus
#

were do i go for game dev

#

oh neaver mind

#

i found it

neat briar
#

Hey guys.. i have a problem related to django
I have a database in which date is stored.
I want to get that object whose date matches with today's date.

native tide
#

do you have some tutorial that shows how to connect your flask app on heroku to an S3 Bucket?

devout coral
#

Hello, what icon would convey the message of terminate or fire.

native tide
#

Last time i found it so complicated, that i gave up and just made all data public and hardcoded the URL to the pictures in the s3 bucket

#

But back to my Heroku / S3 problem: what is the correct way to do this?

#

I dont want to give up this time

devout coral
#

@native tide As in like to fire an employee not fire itself i mean

devout coral
#

@native tide That is great, just got to find it in font awesome.

#

Don't want to add another icon library just for one icon

native tide
#

you can simply take the svg code from flaticon for the single icon

#

dont need to implement the entire library

devout coral
quick cargo
#

maybe make that nav bar a bit easier to read / access

#

now everything else is more clean and smooth the nav seems a lil outa place

devout coral
#

Ok cool

native tide
#

where is the button to fire the employee?

devout coral
#

@native tide It is the running man lemon_s_winter

#

There are titles on hover so there won't be any confusion

#

@quick cargo Should I just make the background a dark color or something?

quick cargo
#

you can

#

you can make that a theme though ig

#

so light or dark

#

i dont think it looks too bad as white

#

though maybe try a gradient background or something

#

not too drastic change but enough to make the boxes a lil more pronounced

devout coral
#

Oh on the body backgorund?

quick cargo
#

id try it

#

#4299E1 -> #3333CC seems like a nice gradient to me at 150degs

devout coral
#

alright

#

I think I am just going to try to intensify the shadows instead.

quick cargo
#

hmm maybe

#

id add a shadow a bit to the nav bar aswell

devout coral
quick cargo
#

looks good

#

maybe move the nav text weighting to semibold which is like 500 weight if i remember

devout coral
quick cargo
#

look 👌

devout coral
#

Should I make the "Title" bigger the thing that says "Division 12"?

quick cargo
#

can do yeah

devout coral
#

@quick cargo Whhy is it that when I increase the text size of my title it also increases the image size?

quick cargo
#

if the image is set to fill how ever high it is then increasing the text size will increase the overall height

#

so maybe check what size the image scales to / is affected by

devout coral
plucky tapir
#

On Django, If I'm logged in as a user, how do I have my input from user to a database table linked to my user logged in? Does it automatically do that or is there a way to have them linked?

#

A user can access the same specific set of info they inputted from the database.

devout coral
#

You want to figure out who is logged in?

#

You can use permissions and in the views when you do your query for you data check for permissions?

tribal dirge
#

How difficult would it be to make a search engine, that searches the internet ofc

plucky tapir
#

@devout coral When the logged in user inputs information into the database, is there a key or something that links it with the user logged in? I will have to look more into permisisons I haven't used it yet I believe

tepid lark
plucky tapir
#

Like to have the Users in the Authentication section (logged in), have their information linked with the input they put in to Usersinfo. From what I can tell there's no link that User put 'Example1' into Usersinfo

tepid lark
#

There should be a LogEntry when users update stuff.

#

Easiest way to check if it's a display problem or a model problem is peek around in your DB

devout coral
#

@plucky tapir Not by default, You can add a one to one relationship

tepid lark
#

oh or is that just inside admin models?

#

Anyways, I have a Django auth flow question. I can't figure out the best way to do SAML auth.

#

The python-saml3 lib is great, but do I use a backend or setup an auth app basically?

#

The way is works is you redirect to your identify provider, auth, then POST redirect back with a signed SAML assertion which gets consumed by you, the service provider.

plucky tapir
#

@devout coral I see thank you. I'm reading a bit on it and trying to sort the difference between a primary key (many to one) and one to one. For example, if a user will only have their own their expenses for budgeting inputted, that'd be a.....one to one?

tepid lark
#

what sort of table is Usersinfo?

#

If you've got user_id -> user_id, key, value on userinfo that'd be a one to many relationship

#

if you've got user_id -> user_id, extra1, extra2 that'd be one to one

devout coral
#

@plucky tapir The different relationships will determine how two tables will interact with each other. One to one means only one object from one table can ralate to only one object in the other table. One to Many will be one object from one table can ralate to many objects in the other table

devout coral
#

I am trying to overlay this img "On Hold" over the profile picture like you see above but I am getting that empty space where the "on hold" img was before doing the

position: relative;
top: -50%;

Is there any good way to do this properly? To note I am using bootstrap and the pictures are currently both in a col.

quick cargo
#

eh relative positioning will work fine

white spruce
#

yo @topaz widget hmu whenever you got some time lol

devout coral
#

@quick cargo It leaves that space tho.

#

If you look under the profile pic you can see the space

quick cargo
#

That's probably how your html is laid out

#

Make a div that is a relative box and then make the text absolute

#

So that the div contains both the image and the text

winter spindle
#

heyy !!

#

can someone reveiw my weebsite ?

#

@topaz widget

#

@marble carbon

topaz widget
#

@winter spindle Link?

winter spindle
#

yeah

#

i have made some changes tbh

#

@topaz widget

topaz widget
#

Well, I would center the main title horizontally first of all.

#

"don't just watch | learn"

#

Your vertical alignment needs some work, too.

#

I would put all the text in the main section in a container and make sure that container is centered vertically in the parent element.

#

You can play around with margins if it needs to be off-center vertically a little for balance (since the text on top is larger)

#

I would get rid of the Lorem ipsum text under the title. You should pretty much know what this is going to say.

#

I guess I don't know what's supposed to be in that block, but it looks like a sub-title or little blurb you should probably have a rough idea of what it should say.

#

All the letters in HTML should be the same case since it's an acronym.

#

all caps is best but sometimes you might do lowercase if all caps stands out too much.

twilit dagger
#

Hey can anyone tell me how I can do some of those cool intro effects when the page first loads in

#

@winter spindle Change the font ASAP bro, and fix the spelling

vestal hound
#

Hey can anyone tell me how I can do some of those cool intro effects when the page first loads in
@twilit dagger got an example?

twilit dagger
#

Someone asked me to make a site like this and it has these intro effects

vestal hound
#

oh

#

the animations?

twilit dagger
#

Yea

#

Can you give me some links to some codepens

pallid arch
#

@twilit dagger they just the normal fade in animations

modest agate
#

Hi! Im working on a simple web app with python and django and i need to decide which frontend framework i will use, i have never worked with fronted libraries or frameworks before, which one is the most easy and quick to learn?

marble carbon
#

you don't have to use one

#

you can work without one, django has templating functionality too

#

but if I had to pick a framework, I'd pick Nuxt (based on Vue)

bronze blaze
#

I think bootstrap can also be used

marble carbon
#

I mean if you're new to frontend, try using Bootstrap first with django

#

you don't necessarily have to use any front-end framework

modest agate
#

Ok, thanks! I will try to use bootstrap

vestal hound
#

I picked up Angular first

#

it's kinda like Django in terms of design philosophy (opinionated)

native tide
#

Hello! I've been attempting login validation in flask against a hashed password (using from passlib.hash import sha256_crypt) that is stored inside a PostgreSQL database. While I am able to hash the password when it enters, I keep running into an error that reads TypeError: secret must be unicode or bytes, not wtforms.fields.simple.PasswordField whenever I attempt to check a users login password to the one stored in the database:

   username = StringField('Username', 
      [validators.InputRequired(message="Username required")])
   password = PasswordField('Password', 
      [validators.InputRequired(message="Password Required")])

   def validate_username(self, username):
      user_object = User.query.filter_by(username=username.data).first()
      if user_object is None:
         raise ValidationError("Username or password is incorrect.")

   def validate_password(self, password):
      hash_pass = sha256_crypt.verify(password, password)
      if password != hash_pass:
         raise ValidationError("Username or password is incorrect.")```


The way that it is placed into the database is by (this is in another .py file with the code around it omitted):
    `name = form.name.data
      username = form.username.data
      password = sha256_crypt.encrypt(str(form.password.data))

      registration_data = User(name,
                               username,
                               password)
      db.session.add(registration_data)
      db.session.commit()`


I've been attempting to try and solve this for a few weeks now and am at my wits end. I'm not sure if I am missing something blatantly obvious or if I set this all up wrong. If anyone has any suggestions or guidance to help me get on the right path, I would really appreciate it. Also, if I should have posted this in a python help room, I am extremely sorry for posting it here then.
vestal hound
#

@native tide just so you know, you can use three backticks for a code block

#

```py
code here
more code
```
becomes:

code here
more code
#

also, can you paste the full error traceback

#

my guess, though, is that this is the problem:

   def validate_password(self, password):
      hash_pass = sha256_crypt.verify(password, password)
      if password != hash_pass:
         raise ValidationError("Username or password is incorrect.")

I think you want password.data?

#

I have never used Flask, but judging by the text of the error and your validate_username method, I'm guessing password is the field object and you want password.data to extract the raw value from it.

native tide
#

Thanks for telling me how to do the code block, and I will get you the traceback in just one moment.

vestal hound
#

try what I said first though

native tide
#

Would that be on the second password in the verify section?

vestal hound
#

...both...?

native tide
#

I'll give it a try with each one then both together

vestal hound
#

actually

#

I think the way you're using it is wrong?

#

shouldn't you be pulling the password from the database

#

and doing it like

#

sha256_crypt.verify(password.data, password_from_database)

#

because the first argument is the raw password

#

and the second is the hash, right?

native tide
#

Yes, the first is raw with the second being hash

vestal hound
#

then why are you doing this

#

hash_pass = sha256_crypt.verify(password, password)

native tide
#

The documentation for passlib for sha256_crypt made it sound that I should do it this way.

vestal hound
#

where?

#

I'm looking at it

#

and it doesn't sound like that at all

#
>>> hash = sha256_crypt.hash("password")
>>> hash
'$5$rounds=80000$wnsT7Yr92oJoP28r$cKhJImk5mfuSKV9b3mumNzlbstFUplKtQXXMo4G6Ep5'

>>> # same, but with explict number of rounds
>>> sha256_crypt.using(rounds=12345).hash("password")
'$5$rounds=12345$q3hvJE5mn5jKRsW.$BbbYTFiaImz9rTy03GGi.Jf9YY5bmxN0LU3p3uI1iUB'

>>> # verify password
>>> sha256_crypt.verify("password", hash)
True
#

this is the example given in the documentation

#

it's pretty clear that the first argument is the plaintext and the second the hash

native tide
#

So my thought process was that I needed to put in what the field was called for where the entry would be entered, which in this case I named it password as it was the password field, for the hash section, I had it called password = sha256_crypt.encrypt(str(form.password.data)) which resulted in another password name (as a replacement to hash). So I thought for me to verify the results, I needed to do something along the lines of sha256_crypt.verify(password, password) since the first password would be the plain text answer along with the second password being there to replace hash.

marble carbon
#

I generally use bcrypt thinkmon

vestal hound
#

I don't really understand your thought process TBH

#

there is only one circumstance under which that would work

#

and that is when a password is its own hash

#

unless I have misread what you're saying

marble carbon
#

huh, why did you put the same variable twice

vestal hound
#

yeah, precisely.

#

that's my point

stable kite
#

@native tide it should be py def validate_password(self, password): hash_pass = sha256_crypt.verify(password, password) if not hash_pass: raise ValidationError("Username or password is incorrect.")

marble carbon
#

huh, again

native tide
#

huh, why did you put the same variable twice
@marble carbon So when I was making the program, I ended up calling the index in my database as password which is the hashed value entering the database. Then when I was making the form... I for some reason named the form password as it was a password entry field. I can easily change the name of the one in the form though

vestal hound
#

yes, it returns a bool, but that's not the point

#

@native tide it should be py def validate_password(self, password): hash_pass = sha256_crypt.verify(password, password) if not hash_pass: raise ValidationError("Username or password is incorrect.")
@stable kite the point is that you shouldn't be verifying the password against itself

stable kite
#

ok

marble carbon
#

I see only one issue here

#

bad variable names

stable kite
#

he should pass the password from validate username ()

marble carbon
#

you're just confusing yourself

vestal hound
#

I see only one issue here
@marble carbon also that apparently password is a field object

#

and not a string

#

at least, that's what I guessed from the error

native tide
#

That... is 100% most likely.

vestal hound
#

not being a Flask user

stable kite
#

@marble carbon there are two issue

vestal hound
#

anyway I'm going to have lunch

#

happy debugging!

native tide
#

Thanks gm!

marble carbon
#

just fix your variable names

#

and you'll be good

native tide
#

I'll give that a try @marble carbon

marble carbon
#

so if validate password is

#

a form method

topaz widget
#

Hey does anyone know if chained comparisons are verboten in JavaScript?

marble carbon
#

also

#

wait

topaz widget
#

Anyone know about the possibility of chained comparisons in JavaScript? Or do I need to use && ?

marble carbon
#

wdym

#

give example

topaz widget
#

Can I do 5 < x < 10?

marble carbon
#

lol no

#

not even in Python

topaz widget
#

Are you sure?

marble carbon
#

you'll have to use &&

stable kite
#

we can chain in python

marble carbon
#

huh

topaz widget
#

That's what I normally do, but I saw someone use the chained syntax in chat the other day.

stable kite
#

but not in javascript

topaz widget
#

re: Python

#

okay

marble carbon
#

interesting

topaz widget
#

Cool, thanks for the clarification.

stable kite
#

as far as i think so

topaz widget
#

I'm pretty sure it doesn't work in JS because I just tried to do a conditional ladder that failed with the chained syntax.

stable kite
#

use '&&'

marble carbon
#

but I mean, i wouldn't personally use chained operations, might confuse others reading code

#

&& is more explicit

#

whats they?

stable kite
#

chaining

marble carbon
#

but it's specific to Python

#

right?

stable kite
#

i think no there are many languages that have chaninig

topaz widget
#

Mathematical syntax uses the chained syntax, so it's what's learned earlier in life typically.

native tide
#

@stable kite I gave that code block a try and TypeError: validate() missing 2 required positional arguments: 'username' and 'password' greeted me.

modest agate
#

it's kinda like Django in terms of design philosophy (opinionated)
@vestal hound
Ok thank! But which one do you recommend on terms of easy to learn?

native tide
#

@marble carbon I changed the password in the validation form and the login for to login_password and the error disappeared, it doesn't log in if I use the wrong username, but I can log in if the username is correct and the password is wrong. But at least it's a step in the right direction! Though you mentioned bcrypt earlier, do you recommend I switch over to that salt and hash instead?

stable kite
#

you have to pass two arguments that came from from your form that are username & password

marble carbon
#

I personally haven't worked with passlib, but have seen it mentioned in articles

stable kite
#

@native tide ```py
class LoginForm(FlaskForm):
username = StringField('Username',
[validators.InputRequired(message="Username required")])
password = PasswordField('Password',
[validators.InputRequired(message="Password Required")])

def validate(self, ):
user_object = User.query.filter_by(username=self.username.data).first()
if user_object is None:
raise ValidationError("Username or password is incorrect.")
else:
hash_pass = sha256_crypt.verify(self.password, user_object.password)```

marble carbon
#

user_object.password

native tide
#

I take it that the userobjects.password is meant to be user_object.password?

marble carbon
#

yea

stable kite
#

sorry my mistake

#

i changed it

native tide
#

@native tide but why are you doing like so djano have in built method for authentication
@stable kite I was planning on learning Django, but a friend recommended I give Flask a try and now I am determined to solve this problem before moving onto Django.

[SQL: SELECT "user".id AS user_id, "user".name AS user_name, "user".username AS user_username, "user".password AS user_password
FROM "user"
WHERE "user".username = %(username_1)s
LIMIT %(param_1)s]
[parameters: {'username_1': <wtforms.fields.core.StringField object at 0x000001BAEB901E48>, 'param_1': 1}]
(Background on this error at: http://sqlalche.me/e/13/f405)```

I may try changing a few more things in my code to get this to work, such as organizing the code in a more... reader friendly fashion... But I really appreciate the attempts for help, I think I messed up quite a few steps back so I am going to go back to where I first hashed everything and see if I made an error back there in the end.
fiery crypt
#

Looking for someone that I can work with to setup Flask-change-password module on my flask site. Please DM

stable kite
#

@native tide I have changed the code check & try it out

native tide
#

@stable kite Sadly no luck, but it gave me an idea for how to solve it though. Thank you for the help!

stable kite
#

ok

white spruce
#
var div = document.getElementById("board")[0];
div.addEventListener('click',function(event) {});
});
#

error
: cannot read property addEventListener of undefined at html document

#

anyone got any idea what's wrong here

stable kite
#
var div = document.getElementById("board")[0];
div.addEventListener('click',function(event) {});
});

@white spruce it should be var div = document.getElementById("board")

white spruce
#

isn't it that I got?

#

what I had wrong

versed python
#

remove the 0

white spruce
#

what if I want that element though in a div?

#

can't that work

#

say I got 9 divs

versed python
#

Are you saying that the element you are targeting is within a div?

white spruce
#

yeah

#

exactly

#

and it's the first div

versed python
#

yeah it can be done.

white spruce
#

it's actually the whole div

#

it's tic tac toe

#

lol

versed python
#

using xpath, or of its id of it has a unique one

white spruce
#

what if it has no id

versed python
#

or I think using nth child too, but I don't know much about this method

white spruce
#

damn lucid been typing so long. I be wondering if he trying to help me

eager panther
#

hey, this is my first time using jinja and I've run into a suuper weird problem... the page is displayed with all the css but when you delete the css files it still runs normally is this a common issue or do you have no idea what I'm talking about

white spruce
#

dang

eager panther
#

lol no sorry I'm a noob

versed python
#

@eager panther maybe your browser has cached the css?

#

you need to force reload your browser

#

ctrl shift r for Google Chrome i think

eager panther
#

ohh okay lemme try that

#

that was such a simple solution lol but it worked thanks a ton!!

near bison
#

I am dynamically adding background colour to an input fields to indicate validation to the user upon form submission.. but the browser is overriding my background colour even when ! important is given.. help

real rain
#

hi guys, I'm setting up my first website but I can't seem to get the favicon.ico get actually displayed when i go to the website. I use Flask with templates and I tried putting the favicon inside the templates folder and the root directory, but it still doesn't seem to do the trick.

Any help will be appreciated

#

and yes i use heroku for this

#

I have collapsed the unnesecary ones

stable kite
#

@real rain your favicon.ico is being displayed in your web page

worn rapids
#

Hey all, I have a question about apps.py for Django applications. Let's say I have two apps in my Django app, one for books and another for readers. Where do I put my apps.py? One in each of those directories?

#

fixed it! typo lol

tender seal
#

as font awesome doesn't have discord icon how can I add it to a webpage?

quick cargo
#

@tender seal go to discord's branding page

marble carbon
#

huh wdym

#

it's there

outer pier
#

can i change a model values accordingly when a specific field in another model changes in django ?

abstract kite
hidden gulch
#

Hello , I've been trying to host a web services with php and nginx docker , but after hosting , when I try to connect to the website , I get ,
Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /app/public/config.php:3 Stack trace: #0 /app/public/index.php(3): include() #1 {main} thrown in /app/public/config.php on line 3
here's the config.php

<?php

$conn = mysqli_connect(localhost, root, toor, tmp)    ;

    if(!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
    //echo "Conneted successfully";
?>```
here's the nginx dockerfile

FROM nginx:1.17.8-alpine

Copy the public directory

COPY ./public/ /app/public/

Copy the nginx config file

COPY ./docker/nginx/nginx.conf /etc/nginx/conf.d/default.conf```

#

is there a fix/workaround for this?

#

here's the php dockerfile ```yml
FROM php:7.4.3-fpm-alpine3.11
RUN apk add php-mysqli

Copy the php config file

COPY ./docker/php/php-fpm.conf /usr/local/etc/php-fpm.d/www.conf

Copy the application code

COPY . /app

VOLUME ["/app"]

sullen basalt
#

If for example I have the following models:

class Author(models.Model):
    name = models.CharField()
    
class Book(models.Model):
    author = models.ForeignKey(Author, on_delete=CASCADE)
    name = models.CharField()```

How can i make a rest serializer to show the author with books?
vestal hound
#

If for example I have the following models:

class Author(models.Model):
    name = models.CharField()
    
class Book(models.Model):
    author = models.ForeignKey(Author, on_delete=CASCADE)
    name = models.CharField()```

How can i make a rest serializer to show the author with books?

@sullen basalt nested serializers

#

one serializer contains another

vapid acorn
#

How redirect on django from the real root (not an apps root) to an application?
I mean like from localhost:8000/ to localhost:8000/home

outer pier
#

@abstract kite thanq ... helped me

versed python
#

@vapid acorn can you explain a bit? Do you want an html button to redirect? or use python code?

abstract kite
#

How redirect on django from the real root (not an apps root) to an application?
I mean like from localhost:8000/ to localhost:8000/home
@vapid acorn create a new route in urls for '' which will redirect to home/

vapid acorn
#

@versed python i meant like the website staring off at "home/"

versed python
#

@vapid acorn follow what thatrandomnpc said, but for production environments you'll have to look for more robust solutions, like configuring your apache or ngnix routing or something

vapid acorn
#

ok

sullen basalt
#
class TestViewSet(viewsets.ModelViewSet):
    serializer_class = TestSerializer
    queryset = Test.objects.last()``` Why does this result in 'AttributeError: 'Test' object has no attribute 'model''
versed python
#

Test.objects.last() will return a model instance not a queryset. @sullen basalt

sullen basalt
#

So how do I do this then?

versed python
#

i dont remember tbh but maybe try queryset = [Test.objects.last(), ]

sullen basalt
#

Results in: AttributeError: 'list' object has no attribute 'model'

outer pier
#

show your test serializer

stable kite
#

@sullen basalt try this py class TestViewSet(viewsets.ModelViewSet): serializer_class = TestSerializer queryset = Test.objects.all().last()

gilded monolith
#

my aim is to have my_api/search?water_level:<=5000&&color:=pink for example

#

pls ping me if you some suggestion

low blade
#

are you trying to get the 5000 and pink values?

gilded monolith
#

the 5000 and pink and the operator

#

we use a little flask app

#

so i can easily get stuff like field=value with request.args

#

i just want something more versatile

vague ibex
#

Hey guys, I needed a help in CSS

#

What I'm facing currently is : I've coded a website and now there's a scrollbar over the x-axis which is really looking bad.

#

I've tried *{ overflow : hidden} but it actually ruins a text effect I've used.

#

Surprisingly, the text effect isnt doing anything wrong coz I removed it from my project once and it did not affect anything which ensures that its completely fine.

#

I just spotted the problem (ig so) , whenever I do it width : 98 vw, it removes the scrollbar-x, but whenever i make it 100vw , it adds the scroll bar back

worn mural
#

@gilded monolith I never head of an framework that has this '<' operator. But if FastAPI is the GOAT to builduing fast and scalable REST API

vapid acorn
#

If you use bs4 like soup.find("div",attrs={"class":"row"}, will it also detect an element with the class "row header" ?

marble carbon
#

yep

#

since it has row class

native tide
#

so can flask handle board game servers?

#

what u think

outer pier
humble stump
#

Hey, anyone here can assist with an onclick function?

rigid laurel
#

I might be able to help - best to just post your question

humble stump
#

So, it kinda does what I expect it to do, I mean, when you press it twice it eventually starts flicking between front of card and back of card

#

however, I was trying to get those divs on top of each other

#

hide the back when it's not being used

marble carbon
#

uh that code screenshot isn't really helpful

#

!paste

lavish prismBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

heady frigate
#

how do I get the given arguments in Quart? (query string)

marsh canyon
#

request.args.get("a") # Query string e.g. example.com/hello?a=2
this line

heady frigate
#

Thanks

modest agate
#

Hey! What is the minimum time that i can learn enough javascript to implement it on a project with for example react

versed python
#

if you go as you learn?

#

just learn basic js and start with react

#

you will probably hate your life for the next few weeks, assuming you already don't, but you'll catch up soon

marsh canyon
#

vue is a really good alternative to react

#

and easier to learn

modest agate
#

you will probably hate your life for the next few weeks, assuming you already don't, but you'll catch up soon
@versed python lol i will try with react if it's to difficult i will go with vue.js

versed python
#

do yourself a favor, go with vue

#

especially since you don't know js

modest agate
#

Ok, yes , thinking that better, i think that i will go wih vue, because i have only a few weeks to build the project

lofty matrix
#

How do you limit user uploaded file size depending on the page/context? Consider youtube where a user may need to upload multi-gigabyte video files, but when uploading a profile picture, there is no reason to allow the user to upload anything larger than a few megabytes. Is this handled on the web server side or the application side? Can the "over size" error occur immediatly, or do you need to wait until the user has already uploaded the maximum amount of data before triggering the error

umbral pivot
#

can anyone think of a way to save any more space here? (save removing the indentation and newlines) ```html
<html>
<svg viewBox="0 0 10 5">
<path fill="#5BCEFA"d="M0 0h10v5H0z"/>
<path fill="#F5A9B8"d="M0 1h10v3H0z"/>
<path fill="#FFF"d="M0 2h10v1H0z"/>
</svg>
</html>

versed python
#

@lofty matrix if you're using django forms, then just use an appropriate validator to that field, django will take care of the rest

wet heath
#

Hey guys, is there anyway to I run my discord bot inside my website that i made with django?

humble stump
#
$(document).ready(function(){
    if ($('.memorizePanel').length != 0) {

        $('.flipCard').click(function(){
            if ($('.cardFront').is(":visible") == true) {
                $('.cardFront').hide();
                $('.cardBack').show();
            } else {
                $('.cardFront').show();
                $('.cardBack').hide();
            }
        });
    }
});
#

I'm gonna update the divs to resemble this but here's the thing, I don't get where exactly I'm supposed to place card.back in my html

#

Do I need to repeat the code for the entire column?

#

I tried that earlier today and it just displays one under the other even though the button kinda worked.

humble stump
#
{% extends "base.html" %}                                                                                      
{% block content %}                                                                                            
<div class="row memorizePanel">                                                                                
    <div class="cardFront">                                                                                    
        <h3 class="text-center">{{ card.front }}</h3>                           
    </div>                                                                                                     
</div>                                                                                                         
<div class="cardBack">                                                                                         
    {{ card.back }}                                                               
</div>                                                                                                         
<div class="row">                                                                                              
    <a href="javascript:" class="btn btn-primary btn-lg flipCard">              
                Flip Card                                                                                      
    </a>                                                                                                       
</div>                                                                                                         
                                                                                                               
{% endblock %}  
#

issue is that both card.front and card.back are visible when the page is loaded, however, when you click the button it exhibits the expected behaviour

humble stump
#

Ok, so like

#

if I add this line (line 2)

#

It works, but it loads it and then hides it -.-

#

I'm just fudging my way through this and it hurts me.

#

so like i can see the card.back very briefly then it just hides

#

I've updated styles.css to .cardBack: display: none; and this has not helped

#

Ok, it has, just needed to refresh with clearing cookies.

#

thank you for facilitating my internal monologue.

white spruce
#

how do I get a div element to click only once in js? anyone?

white spruce
#

?

devout coral
#

In Django how should I best organize all my JS and JQuery? Currently I have everything inline and I know I should move it to external files but don't know a good way to organize it all.

marble carbon
#

static/js?

devout coral
#

Yeah I have that now. BUt should I have one JS file per template?

lethal orbit
#

Yeah I have that now. BUt should I have one JS file per template?
Hell, nah.

devout coral
#

So one big JS file?

lethal orbit
#

Don't repeat yourself.

devout coral
#

Repeat?

#

They are all different functions

lethal orbit
#

Write reusable functions and share them, as much as possible.

devout coral
#

I am saying for organization purposes

lethal orbit
#

You can (and should) split them up in separate JS files...

#

But by functionality, not by template....

devout coral
#

That was the question. Was not sure what others did. I know to re use functions.

#

So as if they were packages then?

lethal orbit
#

So as if they were packages then?
Basically, yes. Hard to say without knowing anything about your project, but you could have e.g. a file with date functions, a file with text processing functions, a file for animations, etc.

devout coral
#

To be honest all this JS is solving one or more specific problem for the template as opposed to like utility functions.

#

@lethal orbit Yeah I get that, but most of my functions are not general purpose use.

#

That is why I said by template

lethal orbit
#

If it is highly template-specific, you can always keep it inline.

#

Like if you know it's not reused anywhere....

#

You can just stick a <script> tag in the template.

devout coral
lethal orbit
#

If it is not too large.

devout coral
#

This is one of my functions, it is only really used for this template though. I do not need it elsewhere

marble carbon
#

well no need then

devout coral
#

So leave that function inline.

#

Then when do I decide to move it to a separate JS file. Because technically if I need to use a function elsewhere or everywhere I could just but it in my base template. (which I had until a few minutes ago but not sure if that is the right choice lol)

native tide
#

My website here

#

has a few problems

#

for example when you try to reset your password

#

it will prompt for an email

#

And it should send you an email

#

but you get an error

devout coral
#

@native tide I did not get an error.

native tide
#

Did you get an email!?

lethal orbit
#

Hmmm... It is a bit long. Might not be a bad idea to separate it. I'd probably be lazy and just move it to a separate file, and just do <script>{% include "add_row.js" %}/<script> in my template lol

#

Then the file is cleaner while you edit, but you don't have to worry about serving it separately.

#

But I tend to use Django for APIs exclusively, so maybe not the best person to ask :p

native tide
#

O

devout coral
#

@native tide I did not put an actual email.

native tide
#

That's why

#

But actually, try to send a real email.

little furnace
native tide
#

it's safe

little furnace
#

Im using React JS btw

native tide
#

@devout coral you should sign up first actually

#

then try reset password

devout coral
#

Ok one sec

#

@native tide Am I not able to log in?

native tide
#

You should be

glass badger
#

Hey all, for Django, is it better to use TemplateView.as_view or views.home for URL patterns?

devout coral
#

@native tide I got an error now

nova shadow
#

Would it be faster to have 100 blueprints with 1 app.route or 1 blueprint with 100 app.routes? Flask

#

performance wise

native tide
#

can you send a screen shot plz @devout coral

devout coral
#

@glass badger You mean using a class based view vs a function based one?

native tide
#

oh my

devout coral
#

You are using Django?

glass badger
#

@devout coral yes exactly, class based vs function. Sorry didnt know how to word it

devout coral
#

It is a preference thing tbh. I prefer function based views. But class based views can save you a lot of time, specially when paginating and filtering.

glass badger
#

so class view for lets say a blog?

devout coral
#

Class based views for a blog will probably make your life somewhat easier. A bit less code to write.

glass badger
#

Do things conflict when I have a mix of URL patterns?

#

for static pages like about, home, keep things function based, then for the blog part, keep things class based?

devout coral
#

It won't conflict.

#

But it might be easier to follow your code if you keep it consistent.

#

But even then, you should be fine in mixing it.

glass badger
#

awesome, I think I will mix it and be sure to document that.

#

thanks for the info!

devout coral
#

Ah documentation, lol. I need to get better at that .

glass badger
#

😄

#

for function based, do i need to create a new app for every page?

lethal orbit
#

No need for a different django app, just use different views.

#

Assuming they fit together.

#

Apps should be used to separate things logically.

#

You can have a home app, and an about app, but if they are small, don't rely on many models, etc. you can also keep them in a single core app or whatever.

glass badger
#

awesome, understood

lethal orbit
#

Matter of preference, really.

devout coral
#

Any good way to go through a css file and Identify unused classes?

marble carbon
#

yes

glass badger
#

thats a good share.

winter spindle
#

hello

#

does any one know how to fix tht blue border error in brackets ?

devout coral
#

What do you mean?

#

@marble carbon Thanks

winter spindle
#

like when in live preveiw i want a thin bllue border to appear but a highlighted region comes

#

@devout coral do you know how to use brackett

#

i will send you the problem

#

it is there on github and someone has asked it before

glass badger
#

Could i get someone some help from someone who knows Django in #help-coconut ? I need help with something very trivial

winter spindle
#

@devout coral

devout coral
#

Oh it is a text editor. Lol

#

I have not used that before. I use pycharm

winter spindle
#

ohh okayyyy !!

devout coral
#

Which reminds me my license expires in 6 days

winter spindle
#

ohh okay 😂

pliant wyvern
#

Looking for help on a web crawler

#

ping me if you can help

glass badger
#

http://127.0.0.1:8000/about/about/ has anyone had this happen before in django?

jagged crater
#

@glass badger What are your urls.py files in your project app and your app with your about page?

#

@glass badger By "project app", I mean the folder with asgi.py and wsgi.py in it.

tepid lark
#

Do I have the Django APPEND_SLASH behavior right?

#

I have this

urlpatterns = [
    path('Shibboleth.sso/', views.sso_login, name='login'),
    path('Shibboleth.sso/SAML2/POST', views.acs, name='acs'),
    path('Shibboleth.sso/SLO/Redirect', views.sso_logout, name='logout'),
    path('Shibboleth.sso/attrs/', views.attrs, name='attrs'),
    path('Shibboleth.sso/metadata/', views.metadata, name='metadata')
]```
#

I can access acs, but get it gives me a redirect for logout ...

#

nvm, it was my browser redirect cache. 🙄

#

Shib is fun, it doesn't matter what* your AssertionConsumerService endpoint is as long as the Idp and SP metadata matches.

trail axle
#

is it possible for the frontend to receive text data from the backend?

glass badger
#

@jagged crater , I fixed it. the issue was i included include() to a url path twice.

#

thank you though for trying to help

tepid lark
#

@trail axle what do you mean by text data?

versed python
#

@trail axle of course, all requests are essentially text data

tepid lark
#

You can request whatever you'd like, JSON, HTML, XML god willing

versed python
#

albeit they have a definite structure, commonly json

trail axle
#

normal text, i.e
Hello World!

versed python
#

sure it can

tepid lark
#

Set up a view that returns text as a response, make a fetch or XMLHttpRequest call.

trail axle
#

it’s to write a web syntax highlighter without using too much js

versed python
#

yeah it can be done

tepid lark
#

Ah okay, you're returning preformatted text?

trail axle
#

basically, yes.
it returns

<span class="keywordhighlight">keyword</span>
native tide
#

im new to web development kinda

#

know a little html a little css

#

but I mainly do python and mysql

trail axle
#

is that kind of a bad way to do it?

versed python
#

nope it's completely fine

#

is the text itself highlighted on the server or client side?

trail axle
#

it highlights the text the person is writing on a <div contenteditable>

versed python
#

you said you won't use js so it's server side i suppose

trail axle
#

using innerHTML=highlightedText which comes from a replaced python string

jagged crater
#

@MrAwesomeRocks#9809 , I fixed it. the issue was i included include() to a url path twice.
@glass badger I assumed that was what happened, that's why I was asking for your urls.py files.

#

At least your website is working now lemon_pleased

acoustic oyster
#

Hello, friends. Im hoping someone can help me understand backend auth.

I am using graphql for an api with django. I Would like to use token authentication for this. There is no good token auth module specifically for what I am doing and I would really like to learn this stuff.

I currently have a system to create a jwt token and send it back to the user. As a temporary test, I am testing that the token is valid in the DB, but I understand this is not needed and is also bad.

Could someone point me in the direction on how to build an auth backend for an api?

I am used signing in to get a bearer and refresh token, then sending a header like {"Authorization": "bearer <token_here>"} to make an authenticated request, and refresh token to get a new bearer token. I am unsure on what this type of auth is called our how I can code it from scratch in my own app. Any help is greatly appreciated.

versed python
#

if you are using any sort of Javascript framework for your frontend, most of them have a module to handle authentication.

acoustic oyster
#

this is purely python client to a python server

#

I am more doing this for learning. I am have been reading articles for awhile and feel that I am stuck. I am unsure how I can use a token ONLY to authenticate a user, ensure proper permissions, and that the token is valid without a db query. But the articles I am reading say that is the main benefit of JWT: authentication without the need to check the db

#

or even store a token on the server

#

I have just gotten to the point where I am out of google search results, so I am totally lost haha. This is probably better for #cybersecurity actually

versed python
#

how are your users supposed to access that website? browser? curl?

acoustic oyster
#

well, using aiohttp, or any method really xD this is a backend for discord bot client.

#

upon a bit more thinking and help, I am understanding jwt a bit more, but I am still unsure how to implement the full backend for this.

versed python
#

there's a lot of packages for this django-simple-jwt is one,though I have never gotten it to work tbh. Maybe try using them instead of implementing your own backend?

acoustic oyster
#

Ty, there are some tools I saw. I am more doing this for learning purposes as I would like to understand more about how jwt works and auth as a whole.

versed python
#

implementing your own sounds like a big task, can't really help with that tbh. But if you make a github for it, hit me up, I'll try to contribute.

acoustic oyster
#

It is on github as part of the backend for my bot, I do not have a separate module for it though.

glass badger
#

is it possible to chain together {% extend %} html files in django?

acoustic oyster
#

@glass badger I think you are looking for {% include "template_name.html" %} ?

sour echo
#

in this how to add space between different boxes

#

?

#

using css

marsh canyon
#

yes, use margin-left and margin-right

#

on each of those boxes

#

btw, are you using flexbox or grid ?

sour echo
#

div

#
    box-sizing: border-box;
    border:4px solid black;
    width: 100px;
    height: 100px; 
    display: inline-block;
    padding: 10px;
    text-align: center;
    transition: 3s ease;
}
div:focus{
    background-color: blue;
}
div:hover{
    width: 200px;
    border-radius: 200px;
    background-color: orange;
}
.animate:hover{
    transform: rotate(360deg);
    background-color: pink;
    width: 50px;
    height:50px;
}```
#

html code

marsh canyon
#

you can add margin on those divs and u will get spacing

sour echo
#

ok

marsh canyon
#

although, I would recommend you to look into flexbox, its really handy

sour echo
#
    box-sizing: border-box;
    border:4px solid black;
    width: 100px;
    height: 100px; 
    display: inline-block;
    padding: 10px;
    text-align: center;
    transition: 3s ease;
}
div:focus{
    background-color: blue;
}
div:hover{
    width: 200px;
    border-radius: 200px;
    background-color: orange;
}
.animate:hover{
    transform: rotate(360deg);
    background-color: pink;
    width: 50px;
    height:50px;
}```
#

css

#

ok i will try flex box

marsh canyon
sour echo
#

ok done

#

thanks

marsh canyon
#

👍

ornate lotus
#

I learnt flex box from here hope this helps 🎀

#

Cool so ya i was working with flask on a web based card game kinda and i gave the css files and all but when i changed the css file, the changes were not made in the website

#

I googled this up and i saw that chrome caches the css file and js file so everytime i make a change in css i have to go to chrome settings and then clear the cache data everytime is there anyway i can fix this without having to clear cache data everytime

vestal hound
#

@ornate lotus ctrl-F5

ornate lotus
#

ohhh thats cool

#

that will make it easier

valid prairie
#

When to use generic views?

#

and should i?

#

every time?

versed python
#

Generic views are exactly that- generic views. Django provides views for very common problems, like rendering a list of your model instances from database. Or rendering a form.

valid prairie
#

okey, so if i have to create Contact page, where on GET i return page, on POST i get data from form (captcha,email,username,txt) and i send it through GMAIL and i save it to database

#

?

#

i should use generic or default

#

?

versed python
#

You should judge which view you want to use- for example if you need to display 2 forms with 1 FormView, that'd be difficult without tinkering. Then you should consider using fucntion based views (unless this DoubleFormView is to be used more than once, in which case you should create a mixin)

#

?
@valid prairie Generic View- FormView

valid prairie
#

okay thanks

#

sooo

#

90% of views are Generic

#

i should use

versed python
#

Yeah most of the views are common enough, so django already provides them

valid prairie
#

okey, but realy i need to provide forms?

#

i have it coded in html

versed python
#

If you want to use django's inbuilt form verification then yeah. Otherwise your HTML form is okay too

#

But then you won't be able to use FormView

valid prairie
#

so

#

witch one in this situation?

versed python
#

I'd prefer the first one

#

Using django forms that is

valid prairie
#

okey, ill do that

native tide
#

Does anyone know if a website GUI is possible to be tied into Discord? Like, a GUI app for a Discord bot is possible... but what about through a website?

ionic idol
#

what would be the best way to encrypt database fields and documents/photos with django & drf?

versed python
#

@stable kite has a package for that

ionic idol
#

for my documents i use a FileField I do not see that being supported by Django-CryptographicFields

modest agate
#

Hey guys, do you think that i can use vanilla javascript for a project? It is a notes app where you can save them, and i don't know javascript so i need to start learning, would i need to use some library like vue or react?

#

And, because i'm very new to fronted libraries, what does libraries like vue.js used for?

stable kite
#

@ionic idol i think as File Fields just store your URL for the file so you can use URL field for that

twilit dagger
glad patrol
#

i create server client model i need to display client info on html page i am using sockets for my model , so can i display my client info on html page if i am using sockets?

stable kite
#

@glad patrol which framework are you using?

glad patrol
#

simple html

stable kite
#

are you storing data in database?

glad patrol
#

no where

#

it only dsiplay on server console right now

stable kite
#

I think you should store your data somewhere & then render it in html

ionic idol
#

@stable kite thank you

glad patrol
#

i got you so it is possible to that i can dispaly my client data on html if i use socket right

stable kite
#

@ionic idol for what?

ionic idol
#

@ionic idol i think as File Fields just store your URL for the file so you can use URL field for that
@stable kite this

stable kite
#

@glad patrol i don't think socket is the best way for sending data to html

glass badger
#

Can anyone recommend a good Django model template for a blog?

stable kite
#

@ionic idol are you using my package?

ionic idol
#

not yet but i'm considering using it

glad patrol
#

@stable kite i already create server client model using socket now i want to display it on web , please suggest me what can i do .

stable kite
#

@ionic idol ok please share you views about it and create issue on github if you feel so

#

@glad patrol i think you should create a web socket to share data between html & python

#

use js for web socket

glad patrol
#

is there any darag and drop html page generateor

stable kite
#

@ionic idol use the package from starting in production otherwise it will raise an error

outer pier
#

hii guys is it possible to update the unfilled fields of existing model when somebody hit another url

#

using serializer

modest agate
#

hey guys, when do you think that is the right time to setup firebase(the database and the storage) with django? i mean after making the views or before

stable kite
#

@outer pier using update method

outer pier
#

I tried it but not working in my case

stable kite
#

what case?

#

can you post the code of model & code through which you are updating it

outer pier
#

I am trying to add to this
model:

class CreateBet(models.Model):
    owner = models.ForeignKey(settings.AUTH_USER_MODEL,related_name="bets",null=True, on_delete=models.CASCADE)
    bet_name= models.CharField(max_length=255)
    amount = models.CharField(max_length=255) 
    scheduled_datetime = models.DateTimeField(null=True,blank=True)
    accepted_user = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.SET_NULL,related_name="accept",null=True)
    status = models.BooleanField(default=False)

the other fields are already created whenever a user hit a url but whenever I try to accept bet with some another url all I want is to update accepted_user and status field .
if somebody knows the ans pls let me know . Thanq in advance
since I want to serialize the the data I have to use serializer and viewset in drf

#

this is all i wanted

#
class AcceptBetSerializer(serializers.ModelSerializer):
    bet = BetCreateSerializer(many = True , read_only= True)
    class Meta:
        model = CreateBet
        fields ='__all__'
        # def update(self, instance, validated_data):
        #     id = validated_data.pop('id')
        #     object = CreateBet.objects.get(id=id)
        #     object.save(status=True)
#

this is all i tried

stable kite
#
class AcceptBetSerializer(serializers.ModelSerializer):
    bet = BetCreateSerializer(many = True , read_only= True)
    class Meta:
        model = CreateBet
        fields ='__all__'
        # def update(self, instance, validated_data):
        #     id = validated_data.pop('id')
        #     object = CreateBet.objects.get(id=id)
        #     object.save(status=True)

@outer pier this is serializes This will not update your database

#

@outer pier you need to create a view for it

#

@outer pier it should not be read-only

outer pier
#

@stable kite

class AcceptBetViewset(viewsets.ModelViewSet):


    serializer_class = AcceptBetSerializer


    permission_classes = [permissions.IsAuthenticated]
    
    
    
    def perform_create(self,serializer):
        print('hii')
        serializer.save(accepted_user = self.request.user,status=True)
    
    def get_queryset(self):
        return CreateBet.objects.filter(accepted_user=self.request.user)
#

have already created the view

stable kite
#

check this out

#

it will help you

outer pier
#

lemme check thanq ..

native tide
#

Someone that could help me with some easy php?

#

Just started

#

Dm me if ur able

twilit dagger
#

How do I make one of those buttons which changes the section under it depending on which button is clicked

#

Like if I have three buttons - Html, CSS, JS then clicking on the Html button which display Html under it, clicking CSS will display Css under it and so on

native tide
versed python
#

The first element is the button that will trigger the change, and the function is the one that changes the content

outer pier
#

@stable kite that was all I wanted thanq for your help

#

but lemme ask a dbt . If I use put this way then couldnt the user get the data and manipulated. ?

humble stump
#

hello gentle people

#

i would like to inquire about methodology, the best methodology to construct the back end system of a 'next' feature which queries a sqlite database for another random row in the same table

#

two things

  • should i create a @app_route('/next') or can i do something more intelligent to display it in place in the same html page
  • how can i stop it from displaying the previous row again, since this is random, be aware i do have access to the current object as i am displaying it
#

any tips/hints/help would be much appreciated.

#

let me know if i've explained this question horribly

#

the current random object is displayed via a sqlite query in the app_route function definition, then is passed to the front end, if you will.

unreal bison
#

You asked for my two cents. I would suggest examining other similar projects to determine their approaches to solving this type of problem.

#

Compare, and see which, if any, suits you best.

humble stump
#

thank you for your input, the only issue i have with it is that

#

often times one functionality is deeply tied into another piece of functionality

#

and it's a little tough to decipher / amend my code to do so entirely to replicate their methodology

unreal bison
#

When in doubt, I read over the PEP documents. They often provide brain/logic untangling wisdom.

humble stump
#

plus to find a similar example is quite hard

#

yeah

viscid roost
#

Hello Everyone

brisk wadi
#

Hi, I'm so beginner, in fact, I just started, however, when I do python manage.py startapp app-name I get:

  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\Admin\anaconda3\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "C:\Users\Admin\anaconda3\lib\site-packages\django\core\management\__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Admin\anaconda3\lib\site-packages\django\core\management\base.py", line 336, in run_from_argv
    connections.close_all()
  File "C:\Users\Admin\anaconda3\lib\site-packages\django\db\utils.py", line 224, in close_all
    connection.close()
  File "C:\Users\Admin\anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 248, in close
    if not self.is_in_memory_db():
  File "C:\Users\Admin\anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 367, in is_in_memory_db
    return self.creation.is_in_memory_db(self.settings_dict['NAME'])
  File "C:\Users\Admin\anaconda3\lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
    return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'WindowsPath' is not iterable
acoustic oyster
brisk wadi
#

Why would I?

acoustic oyster
#

you would just do that to change your DB settings

#

so you should NOT edit it after creating a project if you just want a basic project

brisk wadi
#

I have the default settings.py, but like, what does db does with startapp?

#

so you should NOT edit it after creating a project if you just want a basic project
@acoustic oyster I didn't edit a thing

acoustic oyster
#

ok, hmmmm

#

maybe try to python manage.py makemigrations and python manage.py migrate?

#

oh, make sure django is installed and you are in the virtual environment with your django install

#

that can cause this issue

brisk wadi
#

sorry I went afk

#

I changed my editor

#

However, now when I do django-admin startproject project-name I get 'djagno-admin' is not recognized as an internal or external command, operable program or batch file.

#

Even tho I have django installed

modest scaffold
#

@brisk wadi you're probably in the wrong directory

#

guys how would i go about counting the amount of a certain model i have

flat spade
#

Has anyone implemented Blockchain with Python on Windows OS ?

#

Getting error while installing web3 on Windows

outer pier
#

@brisk wadi activate your virtual environment buddy

brisk wadi
#

OK, is
from django.urls import path
same as
from django.conf.urls import url
?

flat spade
#

@outer pier ok trying...

#

@outer pier same errors. No changes

outer pier
#

@brisk wadi older version of django uses url latest versions uses path and you cant use usl

modest scaffold
#

how do i count the number of times an object is assigned to a manytomany field

brisk wadi
#

@brisk wadi older version of django uses url latest versions uses path and you cant use usl
ok, but I noticed that the old one uses a regular expression

halcyon palm
#

Can i make a aimbot with python?

quick cargo
#

we're not gonna help with that

outer pier
#

@brisk wadi indeed

dark junco
#

Can someone help me with a web dashboard for discord bot?

acoustic oyster
#

many people here can, just ask any specific questions you have

native tide
#

it is card view, but i dont know how to get this layout

#

i will do with boostrap card view

modest scaffold
#

if you know some css it shouldn't be too hard to recreate

modest scaffold
#

can someone help me with the post save reciever on django

modest scaffold
#

what is a deferred attribute

marble carbon
#

code?

modest scaffold
#
@receiver(post_save, sender=Rant)
def postSaveUpdate(sender, instance, **kwargs):
    print("joe nuts",instance)
    for cateogry in instance.categories.all():
        #category.count+=1
        print(category.name)
        #category.save()
#

the print returns this "<django.db.models.query_utils.DeferredAttribute object at 0x0000022F3564B808>"

marble carbon
#

huh

modest scaffold
#

i have found no information of this

marble carbon
#

seems like an XY problem

#

what is it that you're tryna do?

modest scaffold
#

so basically im trying to add categories to a blog post and every time i add a category to blog i want the count value to increase

#

so i know the total number of blogs under that catgory

#

the blog model has a manytomany field with the another model object called category

#

each category has a count which is an integerField

#

and after i save a post i want all the categories in that manytomany field to be updated

marble carbon
#

what...no

#

you don't need a field to save the number of posts under a category

#

Post.objects.filter(category=cat).count()

#

ez

#

or using a related name

#

Category.objects.get(pk=5).posts.count()

white spruce
#

anyone?

halcyon palm
#

??

white spruce
#

@halcyon palm , I am asking what else do I need to add to the javascript to get the 9 grids to show after click

native tide
#
class SnippetSerializer(serializers.ModelSerializer):
    class Meta:
        model = Snippet
        fields = ['id', 'title', 'code', 'linenos', 'language', 'style']```
#

Hi guys I'm readying about DRF, but I don't understand what the class Meta does... can anybody explain this please?

#

Oh I guess it stands for the "metadata" of an object in that class

#

So within the parent class, you can have multiple subclasses. but the Meta class has metadata such as the fields etc... so if you had an object, x, you could do x.Meta.info for the required info... cool

#

Can anybody build on this?

harsh sigil
#

Hey guys I am trying to log into a Google account with Python and I have tried using automation frameworks like Selenium but Google detects that and kicks me out. Would it be possible to use an App Password and log in that way? I have found some articles about loging into Gmail but nothing about a general Google account

white spruce
#

don't think anyone is really available in web dev today

harsh sigil
#

Where else should I try asking?

white spruce
#

not sure just hope someone comes to answer your question

harsh sigil
#

yeah me too, I've been hacking at this nonstop for like a week

halcyon palm
#

You hack? and what?

harsh sigil
#

Sorry its a phrase used around where I am, it just means working on it

halcyon palm
#

I just started python

#

and i make notes

#

do you do the same?

harsh sigil
#

No I am a system admin so my tools revolve around that

halcyon palm
#

Oh that sounds really cool

#

can i have the admin pannel?

#

XD

#

Do you have a admin pannel?

harsh sigil
#

Lol I have a couple

marble carbon
#

So within the parent class, you can have multiple subclasses. but the Meta class has metadata such as the fields etc... so if you had an object, x, you could do x.Meta.info for the required info... cool
@native tide https://stackoverflow.com/a/10344231

#

@harsh sigil what are you trying to achieve?

halcyon palm
#

@harsh sigil what are you trying to achieve?

harsh sigil
#

I have a website that is hidden behind a google account login prompt. I need to be able to log into a google account

halcyon palm
#

Send me the link

marble carbon
#

oww

halcyon palm
#

oww

harsh sigil
#

Unfortunetly I am not sharing a clients URL. It is not important anyways. I am trying to get through the Google account log in page.

marble carbon
#

hmm fair enough

halcyon palm
#

Yea send link

#

and who are you trying?

#

like what are you trying to do?

marble carbon
#

.....

#

they literally said it

halcyon palm
#

Hack them

marble carbon
#

rn

halcyon palm
#

yes i know i dont under stand

#

English

halcyon palm
#

OHHHHHHHHH

#

wow im a idiot

harsh sigil
#

Here is a link to the log in page. I need to type in a email, go to the next page type in a password, and submit them

halcyon palm
#

xss the site why not

harsh sigil
#

Google does not allow that, so I need to find a way around it

marble carbon
#

yep, google won't allow that

halcyon palm
#

xss

#

LMAP

#

xss

marble carbon
#

maybe smth using cookies but

#

!rule 5

lavish prismBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.

halcyon palm
#

python can xss right?

marble carbon
#

sorry

halcyon palm
#

did i break a rule sorry if i did

marble carbon
#

no I mean not yet

halcyon palm
#

yea i so did

#

i said xss the site

marble carbon
#

but if we proceed further we will breaking it

halcyon palm
#

want to procced?

harsh sigil
#

I am willing to use their API or I was reading about "App Passwords" but cannot find an example using them outside of sending emails with gmail. I have also tried seeding chrome with user data with --user-data-dir and it works great if I type the command in manually but it still detects the automation controlling the browser and kicks me back out when using Python

marble carbon
#

i said xss the site
@halcyon palm not like xss on Google would work

halcyon palm
#

True

#

They are to smart

marble carbon
#

want to procced?
@halcyon palm no

halcyon palm
#

it was a joke

harsh sigil
#

I am not going to hack Google. Even if that was possible this is a commercial product for a paying customer and I am not exactly in the business of selling exploits.

halcyon palm
#

Should i try to hack roblox?

marble carbon
#

bro... please, if a mod sees u talking about this ur banned, don't joke around like that @halcyon palm

halcyon palm
#

OHH

#

ok i will not hack roblox

#

i was just asking ok

#

plus that would take years

#

and i would not have the tim e

#

and i would need a team

marble carbon
#

@harsh sigil u only want the login?

halcyon palm
#

and a good vpn

#

Let me go find a good vpn

#

Not to hack

harsh sigil
#

@marble carbon yeah after I get passed the google log in prompt I am able to just use Selenium or some other testing framework for the website

halcyon palm
#

is that ok to do?

marble carbon
#

So the website is only using google login, not the regular one?

halcyon palm
harsh sigil
#

uh I'm not 100% sure what your asking, but its the same prompt you would use for gmail or youtube or something?

halcyon palm
#

my box looking so poggers

marble carbon
#

@halcyon palm can u please

#

😐

halcyon palm
#

Yes?

marble carbon
#

zip it, thanks

#

or try an offtopic

halcyon palm
#

Dude the box poggers

marble carbon
#

....

halcyon palm
#

🔥 🔥 🔥

#

Fire box i got going

white spruce
#

anyone here as yet that can help?

halcyon palm
#

what if humans where a giant code project?

#

on some dudes ;aptop

marble carbon
#

anyone here as yet that can help?
@white spruce just ask ur question

halcyon palm
#

I can try to help

#

What do you need?

#

or do you want to help?

white spruce
#

@marble carbon I asked about a hour ago, but because I never got a respond I was just wondering

halcyon palm
white spruce
#
var btn;
var container;
window.addEventListener('load', () => {
  btn = document.querySelector('.btn');

  btn.addEventListener('click', e => {
  e.preventDefault();
  container = document.getElementById('board').className="square";
  console.log(container);
  })
});
marble carbon
#

okay then

#

brb

halcyon palm
#

What is it for?

white spruce
#

I am trying to put my square class

#

@marble carbon should I still ask?

halcyon palm
#

Did you put the dots in right?

white spruce
#

since you going a way

halcyon palm
#

and cap them right?

white spruce
#

SQL a tictactoe

halcyon palm
#

tehe

marble carbon
#

uh I'm not 100% sure what your asking, but its the same prompt you would use for gmail or youtube or something?
@harsh sigil ur question isn't really web development specific, if ur Willing to go through the app password and API route, and not breaking ToS try opening a help channel, #❓|how-to-get-help

#

since you going a way
@white spruce be back in 5 mins

white spruce
#

okay man, really appreciate it

#

I'll post question

halcyon palm
#

im 13\

#

but i spell like im 7

#

so ehh

native tide
#

@marble carbon you dm'ed or should i ?

harsh sigil
#

@marble carbon Okay I will move my question there. Thank you

halcyon palm
#

[] POGGERS phone

white spruce
#

I got these divs ```
<body>
<h1>Tic <span>-Tac-</span> Toe</h1>
<div id="game">
<div id="status">Move your mouse over a square and click to play an X or an O.</div>
<div id="board">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="controls">
<button class="btn">New Game</button>
</div>
</div>
</body>

I am trying to get these divs into a 9 grid cell for tic tac toe, when I press the btn element. So what I am doing is trying to add the square class from my css to all these divs in javascript, but it seems to only be adding to the board div. Here is my javascript so far. Would this work and what would I need to add to my EventListener?

var btn;
var container;
window.addEventListener('load', () => {

btn = document.querySelector('.btn');

btn.addEventListener('click', e => {
e.preventDefault();
container = document.querySelectorAll('board').className="square";
console.log(container);
})
});

Here is my square css class and board

#board {
display: grid;
grid-template-columns: repeat(3, 150px);
grid-gap: 20px;
}

.square {
background: white;
border: 1px solid var(--grey);
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
border-radius: 10px;
width: 150px;
height: 150px;
font-size: 96px;
font-weight: bold;
display: flex;
justify-content: center;
align-items: center;
}

halcyon palm
#

Add comments so i can read it lol

#

#this is a box

#

yoo why mute me

#

who tf di tha

#

Let me go raid a furry server

#

peacea

kindred kernel
#

Lol what?

barren swift
#

finally

halcyon palm
#

Sup

#

finally??

shadow hornet
#

!tempmute 753791188527743017 3d making completely irrelevant comments in an on-topic channel, saying they're going to make a spam bot, among other nonsense

lavish prismBOT
#

:incoming_envelope: :ok_hand: applied mute to @halcyon palm until 2020-10-14 00:58 (2 days and 23 hours).

kindred kernel
#

im 13
@halcyon palm we know

marble carbon
#

thanks

white spruce
#

@marble carbon see my question got pushed up

#

welcome back though

#

hope you see it

marble carbon
#

okay so did u post ur question completely should I read it?

white spruce
#

yeah it's complete

#

I am trying to add the square style to the divs after I click the button that way the 9 grid cells can show up

#

that's what I am trying to do, hope you understand

#

because the squares has what the cells should look like to play the game

marble carbon
#

hmm

white spruce
#

I have tried all the stuff I know and the square class just will not add to the divs

#

the most I got it added to was the board using getElementId

#

and that does not work correctly

marble carbon
#

okay what if

#

u added a placeholder class to all those divs and selected then using that placeholder class instead

white spruce
#

oh keep in mind, the css nor html can be touched

#

only allowed to use javascript

#

if I could have touch the html and css

#

I would have been fix this lol

marble carbon
#

lol why not

white spruce
#

said so by the teacher

#

he got the final say

#

you know what I can do?

marble carbon
#

Ow

white spruce
#

I have tried ```
querySelectorAll('#board>div').className="square";

#

thought that would work but nth

marble carbon
#

nah

#

okay you're doing it wrong

#

forEach

#

lemme grab a link

white spruce
#

i got it in my notes, i'll check on it

marble carbon
#

uh wait

#

is this a graded assignment

white spruce
#

it's a lab to get our practice

#

but he wants to see it

#

you can't help me?

#

I don't see how to use the for loop

marble carbon
#

okay if it's for practice

white spruce
#

but ofc it's gonna be graded

marble carbon
#

what

white spruce
#

I wouldn't be asking

#

otherwise

marble carbon
#

hmm

#

I'll only give u a hint then

white spruce
#

I have been trying and I am stuck

#

cmon man

#

you can see that I have been trying

marble carbon
#

querySelectorAll("div").forEach

#

forEach takes a function

white spruce
#

can for each add styles?

#

remember it's only the board id div

#

I can't do all divs

marble carbon
#

hmm

#

wait u want the styling on board or the children of board?

white spruce
#

the children

marble carbon
#

okay then use the #board > div

#

selector instead

#

okay nvm u already tried

white spruce
#

exactly man

#

that's why I am here now

#

I tried everything I know

#

was hoping someone could help me fix what I got

#

been stuck at this point for hours man

marble carbon
#

so querySelectorAll("#board>div").forEach();

#

and ur code inside it

white spruce
#

@marble carbon you mind writing inside my code I showed you

#

I am getting an error still

#

what exactly are we putting in for each

marble carbon
#

Okay so

#

querySelectorAll returns the list of all elements

#

what you're doing won't work

#

so that list of elements is an array

#

I told you, you can use forEach to loop through that array

#

and do what u want

#

I Can't give u exact code because

#

!rule 5

lavish prismBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious or inappropriate. Do not help with ongoing exams. Do not provide or request solutions for graded assignments, although general guidance is okay.

white spruce
#

man, make an exception for this one

#

I have been trying