#web-development

2 messages Β· Page 11 of 1

queen needle
#

That would be the cleanest way

#

Either you write it in an html and import it from the template, or in your base html, or you can register a python function if you're feeling brave

#

Basically write a macro with two parameters, one is your classes and one is the form field object. Then you write your html and inside the label tag {{ field }}. Bam, you have a reusable thing that does what you need

#

(I'll be really sorry though if there is a way to nest "expressions" the way you wanted. But I doubt it)

elder lichen
#

Can somebody help me figure out how to get AOS(animate on scroll) working with my flask application?
I followed it's documentation, and looked on stack overflow, and can't find out how to make it work. I tried importing how the docs say, I verified jquery is working, but I can't figure out how/where I'm supposed to AOS.init() because AOS is always undefined
Also verified that flask is seeing my aos.js
https://github.com/michalsnik/aos

for reference ^
GitHub
michalsnik/aos
aos - Animate on scroll library

#

I followed the installation instructions provided at the link above

native tide
#

Is the <script src="https://.../aos.js "> on the page?

elder lichen
#

yes

#

i followed the exact instructions provided and the initialization is my only problem

#

and i used web dev tools to verify that my scripts are all on the page

native tide
#

I'm confused...

elder lichen
#

i'm confused

#

there has to be some way to get this working

fickle chasm
#

Hey guys, quick question about Django. I'm making an app for a school and I'm wondering about how to deal with different types of users

#

Current I've got models for teachers and for students (which have a foreign key relationship to the generic user model)

#

But I'm wondering if I should just use different groups for both

meager anchor
#

Models with foreign keys to the settings.AUTH_USER_MODEL are generally the way to go about this, as far as I'm aware

#

What do you mean with "different groups", though?

#

If you want to deal with permissions, you probably want to create Teacher and Student groups through a data migration

fickle chasm
#

Yeah it'd be with permissions, but also the teacher and student models have relations to other models (e. g. Assignments, classes, etc)

#

By groups I mean the option to create groups through the Django admin

#

So with AUTH_USER_MODEL, would I create the two different models (teacher and student) and add both to settings?

#

I'd like it to have 3 tiers of permissions, admin > teacher > student

#

(sorry, still pretty new to this)

meager anchor
#

if the idea behind the custom models is purely permissions and you don't want to have any custom fields based on hierarchy, then you'd only use groups - but if as you said they have relations to other models, then having custom models is obviously the way to go. As for teacher and student permission hierarchy, groups would be the correct way to do it, but since you already have the student and teacher models, I'm not sure if it would be necessary - i'd use groups regardless since they integrate with django's permission system. You can use a signal or override save() in the teacher and student model to automatically add the student or teacher to the respective group on creation

#

you can then give that user the appropriate permissions on the admin page

fickle chasm
#

I could set it to all users that are teachers right? Or would I have to go through and select each individual user

meager anchor
#

What might be worth noting is that Django 2.1 will add a view_x permission in addition to the regular add_x, change_x and delete_x permissions, but I think it still doesn't support object-level permissions (such as teacher x can edit course z but not course y), for that you might want to look into guardian: https://github.com/django-guardian/django-guardian

#

You can just add it on creation time

fickle chasm
#

Ah OK cool

meager anchor
#

also, to (sorry, still pretty new to this), don't worry about it, Django is quite the huge framework and it takes some time to get into

fickle chasm
#

Awesome, thanks for the help!

meager anchor
#

πŸ‘

keen ore
#

hmm can i somehow do a form that shows more options depending on what checkboxes are checked

#

on flask and wtforms

#

and bootstrap

meager anchor
#

generally, questions about "can i" can generally be answered with "computers can do anything if you work at it hard enough", and i really like referencing that

#

dynamically displaying form fields is probably the easier part, but I would assume that complicates validation a bit

hearty birch
#

its written in flask and the forms by flask-wtforms, and it seems like it's not passing the validation phase of UpdateAccountForm

#

no errors or anything

#

just doesn't update

#

the relevant files are routes.py and forms.py

keen ore
#

how can i make something like this:

Skill name
[-----------]

add another...                            [SUBMIT]
#

and when clicking add another it would turn to

Skill name
[-----------]

Skill name
[-----------]

add another...                            [SUBMIT]
mental chasm
#

@hearty birch Is this AQA?

hearty birch
#

nah

#

OCR

mental chasm
#

Ah

keen ore
#

how can i read field values when i dont know the field's id or name, on flask with wtforms

#

i have a form where user can press a button to add a new field for new language and i want to read all the fields that user has added with the button

mental chasm
#

Would the form not return a dictionary mapping the form name to value

#

If so just iterate over that

keen ore
#

good point

native tide
#

Hello! I have a question to Django Masters :D. So i have my Book/Authors Wiki web app and in my Book model i have a CHOICES. It is a book types there (Historical, Drama, Horror etc). And i need to have another view, book_type_list view and there a list of my choices. But i don't know how to display all choices from my model. Anyone know how to do it? Sorry for my english 😐

queen needle
#

It's been a couple years since I touched Django, but for starters what does your Book model look like?

native tide
#

So this is in Polish language

queen needle
#

It's fine, I played the witcher

native tide
#

πŸ˜„

#

Okay good πŸ˜„

queen needle
#

Lol

#

So you want to access those from your template?

native tide
#

I create a new template (book_types_list) and i would like to have there all values from book_types

#

but i don't know how to create a view like this to display all types

queen needle
#

You can pass Book.CHOICES (as a class attribute) as a parameter to your render template function

#

From inside the template you should be able to access it

#

I'm not on my pc so I can't check my old Django project right now but I remember it was similar to flask πŸ˜…

native tide
#

Okay, so i read a documentation and i read something about get_FOO _display method

#

i create a view like this

#

but when i take a 'book_types' in my template

#

a have a bug

#

"not enough values to unpack (expected at least 1, got 0"

queen needle
#

Ah I remember now, the context

#

Which call is throwing this error?

native tide
#

It is a book_types = Book.get_book_types_display()

queen needle
#

Lemme check the docs

native tide
#

Okay

queen needle
#

Based on the docs

#

It should be get_BOOK_TYPES_display

#

Watch the case

#

I don't know if case is relevant for that function implementation tho

native tide
#

I try to take a BOOK_TYPES but then i have another error - type object 'Book' has no attribute 'get_BOOK_TYPES_display'

#

;<

queen needle
#

Nvm it's not. But also this isn't the function you want, I believe

#

You want to retrieve the entire content of BOOK_CHOICES right?

native tide
#

Yes

queen needle
#

In the context, pass Book.BOOK_TYPES

#

The _display function does something different, it gives you the "long name" for the choice of the current record

native tide
#

Okay so at the first

#

Delete book_types value from my view

#

and just add a Book.BOOK_CHOICES':Book.BOOK_CHOICES to my context

#

?

#

('Book.BOOK_CHOICES':Book.BOOK_CHOICES)

queen needle
#

Sorry it's book types, I forgot what's it called in your module

#

Just pass {"book_types": Book.BOOK_TYPES} as context to the render function

#

Then inside the template you can access the collection by referring to book_types

native tide
#

So i have a bug

#

type object 'Book' has no attribute 'BOOK_TYPES'

queen needle
#

Lol omg I'm sorry, I got the names mixed up...

#

It was BOOK_CHOICES

pearl kite
#

but with zeroes?

queen needle
#

I mean, look at your model definition πŸ˜…

#

It's hard to help people on mobile, can't open tabs haha

native tide
#

aff xD

type object 'Book' has no attribute 'BOOK_CHOICES'

pearl kite
#

Why is it B00K_CHOICES instead of BOOK_CHOICES in the hastebin linked earlier?

queen needle
#

It's Book.the_same_damn_attribute_in_your_class_definition πŸ˜‚

native tide
#

HEy

#

it work

#

πŸ˜„

#

Hahah

#

: DD

#

Thank You πŸ˜„

queen needle
#

Sorry for all the confusion

native tide
#

No problem, everything work so very good πŸ˜„

queen needle
#

tl;dr the function you were using didn't do what you thought it did 😜
Dunno if there's any other helper to get the choices, but passing the class attribute is simple enough.

native tide
#

OKay, so another question xD

#

i have something like this now

#

if i would like to have only the names of types (not (1 'biografia) but Biografia)

#

It's a way to do it?

#

:x

pearl kite
#

You should be able to do that from your template. What do you have currently?

native tide
#

i have something like this in this moment

#

i delete {{book.book_choices }} becouse That it is unnecessary

#

because *

candid totem
#

javascript:

fetch(server, {
   method: 'POST',
   headers: {
       'content-type': 'application/json'
   },
   body: JSON.stringify(someData)
});

Why I am not seeing the data in request.POST (using django) ?

pearl kite
#

@native tide You probably want to do something like book_type[1] in order to extract the correct value from the tuple.

native tide
#

yes, exactly

native tide
#

Another question

#

I have a book_types list and i would like to take a new view (if i click to type then i move in to book list with this book_type) , what is a simple way to do it?

orchid path
#

hey guys, can anybody tell me why reddit uses blob: urls for <video> instead of a normal file? There is normal direct links actually specified outside of the <video> element, so what's the point, what are the advantages of layering it this way? Are they just trying to hide save-video/copy-video-url browser functionality?

#

seΓ±ores, por favor

native tide
#

how would you make that happen

#

i want that

little nexus
#

in <head> <meta name="description" content="Site description here">

meager anchor
#

either that, or by using OGP tags

#

see the meta tags on that page

native tide
#

How would I Go on and Create a user signup in django? Do I just create a new model and set the password field equal to a certain type of Field or do I have to use some build in function and use the existing users table?

native tide
#

so I have a bit of a weird problem

#
print(secure_filename(file.filename))
            if not NotExe(file.read()):
                return abort(415)
            filename = hashlib.md5(file.read()).hexdigest()
            print(os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], filename)))
            if not os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], filename)):

just storing exe files with there names as md5 hashes, when all of a suddent
if not os.path.exists(os.path.join(app.config['UPLOAD_FOLDER'], filename)):
starts returning true

#
    def NotExe(MyData):
    meme = None
    print("NotExe Check")
    try:
        meme = pefile.PE(data = MyData)
    except:
        return False
    finally:
        pass

    if meme is not None:
        if (meme.FILE_HEADER.Characteristics & 0x2000) == 1:
            return False
    return True
native tide
#

I figured out why, I'm using file.read() so I have to close it

native tide
#

it is a spooledTemporaryFile

#

that contains the data

#

nope I completey figured it out

keen ore
#

hmm, im returning a bunch of checkboxes to flask and wtforms, im wondering what would be the best way to handle adding a line to database based on what boxes are checked?

#

i dont want to have a large block of if statements

hearty birch
#

hi guys, was wondering how i would implement some sort of discord login with Flask

regal willow
#

Does anyone have a link to the original code for Class based views, like a detailview

forest narwhal
#

Yo i'm planning to learn things about django, what's the advantage of it besides laravel CI etc ?

buoyant ledge
#

Its nicer than flask because it has a bunch of stuff already attached to it

#

so for stuff you can do like from django import login (but the actual name of it i cant remember) and boom you got authentication

#

(someone correct me if i'm wrong but thats my understanding)

strange thorn
#

@hearty birch pydis is still open source you could just read what they did

hearty birch
#

that is true, why did I not think of that 🧐 thanks

livid belfry
#

flask is also mean to be a 'micro-framework', ie one with very few dependencies

#

for most things, you'll need to install a lot of third party packages and such

mental chasm
#

"a lot" is an over exaggeration

livid belfry
#

depends how you define 'a lot'

#

also changes with the complexity of the project

#

either way i like flask and django for their own purposes and for different reasons

native tide
livid belfry
#

What would you guys recommend for learning about user logins and authentication within flask?

mental chasm
#

I mean I'm most of the time I only use flask-login and the sqlalchemy flask module too

#

So if a lot is two

quartz maple
brave mantle
#

So I guess the issue is the lack of styling

#

Best thing to do is for you to bring up the console

#

Hit F12, console tab, reload the page

#

it'll show any errors there

quartz maple
brave mantle
#

well, there you go

#

connection reset

#

maybe your webserver is broken

quartz maple
#

how do i fix it

#

i hae to drop everything in /main

#

its configured thatway

brave mantle
#

well, look at your <link> tags

#

you probably have a bad path in them

quartz maple
#

it is a template...

brave mantle
#

your point?

quartz maple
#

my point

#

is it may not be 100% working

brave mantle
#

is that you didn't write the tags, yes

#

But like, if you're going to be doing web work

#

you shouldn't be using someone else's template

#

do you know HTML?

quartz maple
#

well

brave mantle
#

if you don't know HTML, start there

#

and for the love of god avoid w3schools

quartz maple
#

well

#

i could always do it with py.....

#

which it'd rather

brave mantle
#

You would still need HTML

quartz maple
#

do it with py

#

i have vs2017

#

so

#

django or

#

thing

#

flask

brave mantle
#

you would still need HTML

#

there's no getting away from it

#

you need it

quartz maple
#

basic html?

brave mantle
#

You should be relatively proficient with HTML before you build a site with it

#

htmldog is a resource I see mentioned a lot here

quartz maple
#

i like w3schools xddddddd

#

i know the basics

#

not off by heart

#

but iknow the basics

brave mantle
#

w3schools is fine if you already know HTML

#

if you don't, use htmldog or https://developer.mozilla.org/en-US/

quartz maple
#

should i install flask or django on my vps?

brave mantle
#

The webapp framework you use is up to you

#

Flask has a fairly gentle learning curve for beginners

quartz maple
#

Okay

#

How do I upgrade my python ver?

#

im on 3.5 apperently

#

is there a command to go to 3.6

brave mantle
#

Depends on what OS you're running

#

You're on windows iirc so you just uninstall the old one and install the new one

quartz maple
#

no im not

#

im on Debian

brave mantle
#

Then use your system's package manager

#

If it doesn't have the newer version, stick with what you have

#

I think on debian it's sudo apt-get update && sudo apt-get upgrade

quartz maple
#

thats doing something

brave mantle
#

that'll update all of your packages

quartz maple
#

root@KCWS:/var/www/main# python3.6
-bash: python3.6: command not found

#

it didnt update py

#

root@KCWS:/var/www/main# python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.

strange thorn
#

Wasn't Debian's latest version of python 3.5?

#

3.6 is only in the testing repos

#

Because for whatever reason the Debian Devs consider it unstable

#

So you either setup the testing apt repos or compile from source

quartz maple
#

oh ok

#

@brave mantle I need lil help

brave mantle
#

bot.tags.get ask

lavish prismBOT
#
ask

Asking good questions will yield a much higher chance of a quick response:

β€’ Don't ask to ask your question, just go ahead and tell us your problem.
β€’ Try to solve the problem on your own first, we're not going to write code for you.
β€’ Show us the code you've tried and any errors or unexpected results it's giving
β€’ Keep your patience while we're helping you.

You can find a much more detailed explanation on our website.

quartz maple
#

@brave mantle

#

its NOT doing this:

brave mantle
#

did you open the port?

native tide
#

Anyone know why my html file is displaying as html code?

strange thorn
#

Did you do what the guys in the comment said?

mental chasm
#

@queen fiber what jquery do you need help with

quartz maple
#

Yes I did open the port @brave mantle

brave mantle
#

well, assuming it's running, the firewall isn't blocking it, and you're connecting to the right host, it should work.

quartz maple
#

(site) root@KCWS:~# python main.py
python: can't open file 'main.py': [Errno 2] No such file or directory

#

@brave mantle

brave mantle
#

So it's not running or the firewall is blocking it

#

Likely the former

quartz maple
#

how do i make it so its not

#

ERR_CONNECTION_TIMED_OUT

#

on 5000

brave mantle
#

But that isn't timed out

#

That's connection reset

#

I'm pretty sure you just haven't allowed the connection through iptables

meager anchor
#

@quartz maple you can check if its listening on the port with sudo lsof -i :FLASK_PORT where FLASK_PORT is the port you configured it with

quartz maple
#

It doesnt return anything @meager anchor

quartz maple
#

Can anyone help?

wicked mason
#

is css & html discussion allowed here? or only flask and django stuff

quartz maple
#

All web-related stuff @wicked mason

#

Can you assist me too?

wicked mason
#

I'll take a look in a sec

quartz maple
#

Do you know Flask?

wicked mason
#

a little...

#

@quartz maple how did you start the flask server?

quartz maple
#

flask run

#

@wicked mason

#

and

wicked mason
#

uhh

#

try sudo flask run?

quartz maple
#

uhh

#

it just doesnt respond

wicked mason
#

ah

quartz maple
#

do i need to run a virtualenv?

wicked mason
#

nah

#

GWseremePeepoThink try accessing localhost in the browser

quartz maple
#

its running on a vps

wicked mason
#

o

#

yea I'm not good with this stuff

quartz maple
#

@brave mantle

wicked mason
#

maybe you messed up a flask function somewhere and it's not returning anything?

quartz maple
#

i mean i copied it from the tutorial

wicked mason
#

is it throwing any errors in the terminal?

brave mantle
#

What are you hosting this on?

quartz maple
#

Digital Ocean, Debian 8

brave mantle
#

Okay, and iptables -L gives you what?

quartz maple
brave mantle
#

I need the whole thing.

#

So perhaps use our paste service instead of a screenshot.

quartz maple
brave mantle
#

Looks like you're using PuTTY so just selecting the text should copy it

brave mantle
#

Ah, of course, ufw

quartz maple
#

fix?

brave mantle
#

Try ufw allow 5000

quartz maple
#

I have done that

brave mantle
#

Hmm

#

Well, give me a few minutes to actually get to a computer

quartz maple
#

Skipping adding existing rule
Skipping adding existing rule (v6)
brave mantle
#

Maybe paste your main flask file as well

#

Remove the cookie secret if you have one

quartz maple
#
from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "<h1 style='color:blue'>Hello There!</h1>"

if __name__ == "__main__":
    app.run(host='0.0.0.0')
brave mantle
#

Okay

#

Are you using cloudflare?

#

For your domain

quartz maple
#

Ye

brave mantle
#

If you go into your DNS settings

#

Is there an orange cloud next to the domain?

quartz maple
#

ye

brave mantle
#

Click it to turn off the cloudflare proxy

quartz maple
#

Done

brave mantle
#

Then try again in about 10 minutes

#

Cloudflare will only proxy standard Web ports for you, that's 80 and 443

quartz maple
#

THANKS

#

πŸ˜„

brave mantle
#

Note

#

The IP address on your domain will point to the actual server IP now instead of cloudflare

quartz maple
#

o

brave mantle
#

You should secure your SSH server with either a really strong password, fail2ban, or disabling password logins and using SSH keys

quartz maple
#

it has a strong password

wicked mason
#

I highly recommend fail2ban

brave mantle
#

Yeah, it's very useful

#

It basically blocks IPs in the firewall for a while if they get the password wrong too many times

wicked mason
#

even on my private vps which only hosts a discord bot, fail2ban bans 100s of ips daily

brave mantle
#

Yeah, there's always someone trying your ports

#

That's the Internet for you

wicked mason
#

90% of ips getting banned are chinese

#

lol

brave mantle
#

A lot of those are government

#

They're pretty unscrupulous over there

wicked mason
#

yea

#

alright time to ask my css question

brave mantle
#

I think I know what you're gonna ask

#

The footer, right?

wicked mason
#

I want the image on the left to be 100% of the div's size

#

wrong πŸ˜‰

brave mantle
#

So set the width to 100%?

#

That'd look terrible though

wicked mason
#

yea I want there to be no empty space

#

when I set the padding (or margin) to 0, the div shrinks

brave mantle
#

There's probably a margin on the div

#

Or on the image

wicked mason
#

setting margin & padding on the image tag does nothing

brave mantle
#

Isn't that what you wanted?

wicked mason
#

nah, the div shrunk

brave mantle
#

You could set a min-height on the div then

#

or set padding on another element inside the div

wicked mason
#

alright...

#

any idea on how to vertically center the text & button now?

quartz maple
#

@brave mantle ey bro

brave mantle
#

You'd probably be better off applying the padding to a div containing the text/button

#

rather than setting a min-height

wicked mason
#

alright

brave mantle
#

Sup @quartz maple

brave mantle
#

ImportError: No module named 'wsgi'

quartz maple
#

trying to make so u dont have to use

#

5000

brave mantle
#

You don't really need uwsgi for that

#

tbh you probably don't want uwsgi either

#

you probably want gunicorn

wicked mason
#

@brave mantle that worked! thanks

quartz maple
#

how do i do it with gunicorn

brave mantle
#

No problem

#

Why don't you look up a guide, rabs?

brave mantle
#

Small alert: As of today (the 24th), Chrome/Chromium will display all non-HTTPs sites as insecure.

#

@quartz maple Error's pretty clear

#

No module named 'myproject'

#

You probably forgot to tell gunicorn where that folder is located

wicked mason
#

the website I'm working for is still http... GWqlabsSweats

brave mantle
#

But your module isn't named wsgi

#

it's named main, isn't it?

brave mantle
#

Did you read the error?

quartz maple
#

yes

brave mantle
#

hang on

#

why did you call that file wsgi?

#

that's a thing you need to have not done

#

name it app or something

#

and then use app:app

quartz maple
#

its called app now

#

Same error

brave mantle
#

You didn't include the command you ran

quartz maple
#

gunicorn --bind 0.0.0.0:5000 app:app

brave mantle
#

and the folder you're in?

quartz maple
#

(main) root@KCWS:/var/www/main/site/main#

brave mantle
#

actually, that's a problem with your own code

#
  File "/var/www/main/site/main/app.py", line 1, in <module>
    from site import app
ImportError: cannot import name 'app'
#

Have you covered Python's basics in a tutorial or something?

quartz maple
#

yes but got nothing to do with this,,,,,,

#

idk what import app is?

#
from site import app
brave mantle
#

didn't you write it?

quartz maple
#

Im following a tutorial

brave mantle
#

what are those bin/include/lib folders?

#

Yeah, but if you don't know what the syntax means, you need something lower-level

quartz maple
#

idk what its reading tho..

brave mantle
#

well it's not, because site is a built-in python module

#

part of the standard library

#

which definitely doesn't have app in it

quartz maple
#

site

#

is what my flask file is called

brave mantle
#

wut

#

None of this makes any sense

quartz maple
#

Exactly..

brave mantle
#

Okay, but then site.py is not in the main folder

#

so why are you trying to run some other file?

#

You should rename that to app instead, and rename that wsgi.py back to wsgi.py from before

quartz maple
#

Okay @brave mantle site.py is what flask uses to run and return a webpage.

#

The other one is the virtual environment

#

In main

native tide
#

Hello. I have a web app in django - database with books and authors. I would like to create a Voting view. Somebody know what is the best way to do it?

little lion
#

Hey \o/ what do you think of cookiecutter django? would you recommend it?

grand badge
#

@native tide We cant write code for u

#

But

#

I would imagine that the user clicks a button on a book or something and then it records the vote to a db

#

And adds 1 vote to a field in the db

#

and IntegerField

queen fiber
#

Since we are in a flask discussion , i need some help with caching search quries or finding a way to make them faster

#

currently using flask-msearch

native tide
#

Anyone know how I get checkboxes in flask? I wanna do a calculation on all the selected files, in flask app builder

native tide
#

@grand badge Thanks, in this moment I using a django-stars-rating from github in my project. It work's fine πŸ˜„

quartz maple
#

@brave mantle

#
● site.service - Gunicorn instance to serve inte.ca site
   Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: ena
   Active: failed (Result: exit-code) since Wed 2018-07-25 22:05:48 UTC; 23s ago
 Main PID: 24012 (code=exited, status=210/CHROOT)

Jul 25 22:05:48 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site
Jul 25 22:05:48 KCWS systemd[1]: site.service: Main process exited, code=exited,
Jul 25 22:05:48 KCWS systemd[1]: site.service: Unit entered failed state.
Jul 25 22:05:48 KCWS systemd[1]: site.service: Failed with result 'exit-code'.
lines 1-9/9 (END)...skipping...
● site.service - Gunicorn instance to serve inte.ca site
   Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-07-25 22:05:48 UTC; 23s ago
 Main PID: 24012 (code=exited, status=210/CHROOT)

Jul 25 22:05:48 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site.
Jul 25 22:05:48 KCWS systemd[1]: site.service: Main process exited, code=exited, status=210/CHROOT
Jul 25 22:05:48 KCWS systemd[1]: site.service: Unit entered failed state.
Jul 25 22:05:48 KCWS systemd[1]: site.service: Failed with result 'exit-code'.

brave mantle
#

I dunno why you're mentioning me specifically

quartz maple
#

Β―_(ツ)_/Β―

brave mantle
#

plenty of other people around here

#

but anyway, go read the logs

#

they'll be in /var/log somewhere

quartz maple
#

i mention you as ur the only one who helps

#

which log?

#

How do i do this:

#

Create and bind to a Unix socket file, myproject.sock, within our project directory. We'll set an umask value of 007 so that the socket file is created giving access to the owner and group, while restricting other access

subtle tinsel
#

Anyone with Dash/Flask experience got a few minutes?

mental chasm
#

Not sure what dash is but I've used flask

#

Also next time just ask the question :)

little nexus
#

yep i use dash

#

it's kinda painful

#

but nice in that it does everything for you

ripe imp
#

helllo lads

#

can someone help with reddit css?
i want to remove this flair box in the sidebar: specifically this one

i tried to inspect element that part, but nothing shows up
does that mean it can't be removed by reddit css

native tide
#

With python

#

How can I make online multiplayer

#

Heard of websockets and sockets not sure how to thoufh

#

Thoufh

#

Though

#

Any help please

strange thorn
#

are you referring to online multiplayer for browser games or for desktop apps?

native tide
#

Desktop

strange thorn
#

usually you would write the client side aka the desktop app in a language actually suited to gaming

#

like c++ c# etc

#

and if you are using a prebuild engine, which you would usually do it is extremly likely this engine already has support for the server side built in

#

so you would write the server side in that lang too

native tide
#

But I have to use Python

#

How can I do it with Python

strange thorn
#

the same way you would do it with any lang

#

how can you do it is such a general question

native tide
#

And how is thst

#

That

#

Like

strange thorn
#

that hihgly depends on what you are doing

#

there is not one general way

native tide
#

It's a 3d game where there's boxes on a flat plane

#

If someone starts it creates a new box for them they can control

#

And it's online multiplayer like that so they can see each other controlling the boxes

strange thorn
#

if you dont want to fight with the pain of plain sockets (trust me you dont) you'd use the twisted framework for python

#

supports both server and client side

brave mantle
#

No you wouldn't

#

You'd use asyncio lol

strange thorn
#

twisted has async support

brave mantle
#

There's no advantage to using twisted though

strange thorn
#

ive seen twisted listed as a requirement for some backend jobs in game dev

#

Β―_(ツ)_/Β―

brave mantle
#

In fact twisted is considerably slower than asyncio

#

Python 2 jobs, maybe

native tide
#

Soo

#

I don't use twisted??

strange thorn
#

so you would use some sort of async framework

#

your decision i guess

#

anyway once youve picked your framework

#

you would have to build some sort of synchronization mechanism

#

so the server always contains the state of a game and the clients can read from it and can write to it

#

although i am not sure how to exactly implement that one

native tide
#

Huh

strange thorn
#

what huh

#

i wont think of a system just for you in detail, youll have to serialize your objects representing your game entities or the client unique information of those objects into some sort of string with pickle for example

#

and then send them to the server

brave mantle
#

Except not pickle, pickle isn't safe

strange thorn
#

some sort of serialization

subtle tinsel
#

Anyone here use Dash much?

cobalt valve
#

hey anybody have some experience with sockets threading??

#
import logging
import socket
import _thread
import sys

log = logging.getLogger('udp_server1')


def udp_server1(host='10.10.156.180', port=7001):
    print('start')
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    log.info("Listening on udp %s:%s" % (host, port))
    s.bind((host, port))
    tcphost = '192.168.1.133'
    BUFFER_SIZE = 1024
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # IPv4, TCP
    sock.bind((tcphost, port))
    sock.listen(1)
    print('Listening Till1')
    while True:
        conn, address = sock.accept()
        (data1, addr) = s.recvfrom(128*1024)
        conn.send(data1)
        conn.close()
        print('7001_', data1)
        yield data1

def udp_server2(host='10.10.156.180', port=7002):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    log.info("Listening on udp %s:%s" % (host, port))
    s.bind((host, port))
    tcphost = '192.168.1.133'
    BUFFER_SIZE = 1024
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # IPv4, TCP
    sock.bind((tcphost, port))
    sock.listen(1)
    print('Listening Till2')
    while True:
        conn, address = sock.accept()
        (data2, addr) = s.recvfrom(128*1024)
        conn.send(data2)
        conn.close()
        print('7002_', data2)
        yield data2
while 1:
   _thread.start_new_thread( udp_server1, ('192.168.1.133', 7001, ) )
   _thread.start_new_thread( udp_server2, ('192.168.1.133', 7002, ) )
#

not getting any errors

#

but its not running the function...

quartz maple
#

@cobalt valve

#

can u help me with socket?

polar wasp
#

@cobalt valve your "while 1" is going to make it try to start hundreds of threads that won't be able to get the socket, and it seems like the threads never get a chance to run because the main thread is holding the GIL. Consider using the threading module and its join method instead. Also, your thread functions can't be generators (no yield statement), what are you trying to do with that? I'm on my way to bed, but I can maybe help you tomorrow

#

!tag ask

#

!tag get ask

lavish prismBOT
#
ask

Asking good questions will yield a much higher chance of a quick response:

β€’ Don't ask to ask your question, just go ahead and tell us your problem.
β€’ Try to solve the problem on your own first, we're not going to write code for you.
β€’ Show us the code you've tried and any errors or unexpected results it's giving
β€’ Keep your patience while we're helping you.

You can find a much more detailed explanation on our website.

polar wasp
#

@quartz maple ^

#

(As i mentioned, I'm on my way to bed, but if you just ask your question someone might be able to help you with it tonight or tomorrow)

cobalt valve
#

@polar wasp let me know when you up again...ill check what happens if i remove the yield...

#

@quartz maple sorry man went to bed... i can try...shoot when you ready

polar wasp
#

ok wow i meant to go to bed then, now it really is too late

#

goodnight

cobalt valve
#

lol

#

no stress

#

gonna try that thing quick

strange quarry
#

Any form of Testing tips anyone can reccommend?

#

for Smoke testing a web application?

deep cave
quartz maple
#

@polar wasp Wat

#

That was my question, to ask "can you help me with sockets"

#

don't tell me to use the ask thing

#

if the person was available i would have refered more info

#

but they weren't so it's not worth my time

brave mantle
#

@quartz maple I think we've talked to you about your attitude a couple times now, but that's simply not how you treat people you want help from.

By not actually posting your question, you're just wasting everyone else's time instead. If you're so intent on getting an answer, ask the actual question. And remember to provide a code example and information on what you've done to solve your problem.

#

Nobody is going to go "Yes I can sockets" and wait a few hours for you to post your question.

wind tangle
#

Hello, I was wondering if someone could help me

#

I cant seem to find an element on a website that I want to use in selenium

#

And when I go into the chrome element finder, nothing appears

#

Does this have anything to do with it having to use adobe flash player

polar wasp
#

probably

#

flash is flash, as far as HTML is concerned it's just a single media element without anything in particular inside it

wind tangle
#

So selenium isnt an option then?

polar wasp
#

i don't know

#

i haven't used selenium

wind tangle
#

do you have any experience in pyautogui?

polar wasp
#

no, sorry

wind tangle
#

Ok, np, thanks for the assistance

polar wasp
#

no browser inspector for flash elements though, so you're going to have to find what you're looking for the hard way

grim prawn
#

why the heck does beautifulsoup documentation suck so much

polar wasp
#

whats wrong with it

grim prawn
#

i can never figure out what attribute it is that i need for a given thing

#

they are all similarly worded and don't give you any context

polar wasp
#

like what?

grim prawn
#

and everything i try doesn't work

#

children, descendants, next elements

#

desc = [x.string for x in testsoup.find(id='bling').children]

#

i spent like 15min on this alone

quartz maple
#

How do I :

Create and bind to a Unix socket file, myproject.sock, within our project directory. We'll set an umask value of 007 so that the socket file is created giving access to the owner and group, while restricting other access

#

@brave mantle I actually asked the proper thing a bit ago. I didn't know what code to put into the file, so that's why I asked.

neat nest
#

@quartz maple if you read forwards in the DigitalOcean tutorial... it tells you

native tide
#

I am working through the Flask Mega-Tutorial and am running into an issue where my web app won't precess a 404 or 505 page and instead takes me to a defualt page stating that the connection has been reset. Is there anyone here who could possibly help me out with this?

quartz maple
#

@neat nest no it doesnt ffs

#

it doesnt tell me how to create a socket file.

#

I've done everything else.

#

And as far as i know i've done it correctly.

#

But im stuck on that bit ^

#

@plucky trellis Woudl you like to see my .service file

neat nest
#
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app```????????
quartz maple
#

I've done that...

#

But I get an error....

neat nest
#

well that error is probably what you should lead with, then

quartz maple
#

Well would you be willing to help me ammend the error?

neat nest
#

if not me then someone will be I'm sure

quartz maple
#


[Unit]
Description=Gunicorn instance to serve inte.ca site
After=network.target

[Service]
User=inteca-webmaster
Group=www-data
WorkingDirectory=/var/wwww/main/site
Environment="PATH=/var/www/main/site/site-env/bin"
ExecStart=/var/www/main/site/site-env/bin/gunicorn --workers 3 --bind unix:site$

[Install]
WantedBy=multi-user.target

#

thats my .service @neat nest

neat nest
#

what's going on in your ExecStart?

#

that doesn't look much like the tutorial one to me

quartz maple
#

Well

#

Its not gonna be called myproject is it

#
● site.service - Gunicorn instance to serve inte.ca site
   Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: ena
   Active: failed (Result: exit-code) since Sat 2018-07-28 04:48:17 UTC; 28s ago
  Process: 26850 ExecStart=/var/www/main/site/site-env/bin/gunicorn --workers 3
 Main PID: 26850 (code=exited, status=210/CHROOT)

Jul 28 04:48:17 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site
Jul 28 04:48:17 KCWS systemd[1]: site.service: Main process exited, code=exited,
Jul 28 04:48:17 KCWS systemd[1]: site.service: Unit entered failed state.
Jul 28 04:48:17 KCWS systemd[1]: site.service: Failed with result 'exit-code'.
lines 1-10/10 (END)...skipping...
● site.service - Gunicorn instance to serve inte.ca site
   Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2018-07-28 04:48:17 UTC; 28s ago
  Process: 26850 ExecStart=/var/www/main/site/site-env/bin/gunicorn --workers 3 --bind unix:site.sock -m 007 wsgi:app (code=exited, status=210/CHROOT)
 Main PID: 26850 (code=exited, status=210/CHROOT)

Jul 28 04:48:17 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site.
Jul 28 04:48:17 KCWS systemd[1]: site.service: Main process exited, code=exited, status=210/CHROOT
Jul 28 04:48:17 KCWS systemd[1]: site.service: Unit entered failed state.
Jul 28 04:48:17 KCWS systemd[1]: site.service: Failed with result 'exit-code'.

#

its the exact same its just to my

#

filenams

neat nest
#

well it looks like the 210/CHROOT is pointing to something, but I don't know systemd well enough to tell you what. possibly a directory permissions issue?

quartz maple
#

?

#

ExcecStart is weird tho

#

because the wsgi is in the main project folder

#

@neat nest

neat nest
#

yeah? it's in your WorkingDirectory

quartz maple
#

so where am i going wron?

neat nest
#

well, like I said, I could not tell you for sure, but I would suspect a directory permissions issue

quartz maple
#

so

#

does the site.sock file get generated

#

or do i have to create it

#

because idk where it goes

#

or what to put in it

neat nest
#

I imagine the socket file is generated and used automatically

quartz maple
#

What do I do then

#

Is there another way to start it with

#

a .service

neat nest
#

I do not know what is causing your error. I would wait until someone with relevant experience sees or present your issue to one of our #315249263103967242 that have more generalized Linux support

quartz maple
#

so

#

they're useless

neat nest
#

you said hello and left?

#

it doesn't even look like you visited Code Monkeys

#

for someone trying to solve a problem you seem strongly opposed to seeking help

brave mantle
#

@quartz maple You probably need to chmod or chown the site project files so that gunicorn can actually read them

#

I'll leave it as an exercise to you to figure out how to do that

upper stream
#

Anyone know django here?

neat nest
#

I'm sure many people do! you might be better served just asking your question

upper stream
#

Resource for learning it?

meager anchor
brave mantle
#

Two Scoops is very reputable as well

upper stream
#

@brave mantle link pls

brave mantle
#

Sorry, I'm in a car currently, but I'm sure you can Google "two scoops Django"

upper stream
#

ok

native tide
#

Hi everyone! Somebody who know Django? I have a little problem. I have a star rating in my project from django-star-ratings. In this moment i need to have a top 10 Voting Boks. I try do create a view based from Ratings but it's not working. Somebody know how to fix it?:|

reef sun
#

Hi all, I'm working through the Django tutorial and I've just got to the part with models. I'm having some difficulty getting my head around them - would anyone have the time to sit down and explain it to me clearly or point me in the direction of a decent tutorial video that goes into more depth than the tutorial?

native tide
#

Okay, nevermind, I fixed it. πŸ˜›

#

in my opinion, the best tutorial on Django on yt πŸ˜ƒ

reef sun
#

Cheers @native tide

native tide
#

πŸ‘Œ

stark yarrow
#

Hello, I'm having a issue with flask and dynamic forms, can someone help me?

#

I created a subclass of a form inside a view. I have to grab information online via json, and then display the forms using the name/ID that the json file gives me. I'm looping through json and appending to a list StringFields('id'). This creates a bunch of UnboundFields. So far so good, but I cant display them using Jinja. If i just loop through the list and call the field, it display something like <UnboundField(StringField, ('SKU : ',), {})>... If I use form.label() it gives me an error: UndefinedError: 'wtforms.fields.core.UnboundField object' has no attribute 'label'.

#

This is inside the view

#

Template ^

#

I know a bit about the bind() method but I dont know how to use it in my case

quartz maple
#

@brave mantle can you help me?

#

chmod

neat nest
#

you should maybe contact him before it's midnight where he lives

#

also I'm certain you can provide more detail than "chmod"

quartz maple
#

can you help me with chmod?

meager anchor
#

not sure what chmod has to do with web development, nor general python help altogether - maybe ask your full question in one of the off-topic channels

quartz maple
#

It has alot to do with it....

tame viper
#

such as..?

quartz maple
#

It's relevant

#

as its in the tutorial based on Flask

#

well

#

it was suggested anyway

#

@tame viper

#

i'm not gonna go to off-topic channel just to talk about chmod then come back here and talk on the same sort of topic relating to the thing i am having issues with

#

It was suggested anyway by an admin

#

So

neat nest
#

if you're talking about me, I've told you multiple times to ask better questions

wintry geyser
#

hey guys, i wrote a custom script in flask for the page I want to refresh. It works fine on the same browser but doesn't work across browsers, does any one know why?


<script>

  window.setInterval(function(){
      if(localStorage.update == "1"){
          localStorage.update = "0";
          window.location.reload(true);
      }
  }, 100);
</script>

{% endblock %}
#

So this is the page that is being refresh, it is activated when I press a button on the other page.

#

Updating the page to get an update of the database table basically.

#

Does this has anything to do with cookies? I don't think so as I inspect the source code and it simply jquery to me, unrelated to cookies. I checked the console, no errors and it works on the same browser, just not across different browsers; it doesn't refresh.

#

maybe the refresh command is the problem, does anyone know any alternative function to that's able to refresh across all different browsers?

#

Update: I just tried incognito mode and it appears to be the case for chrome, that this is related to sessions and cookies perhaps. guessing it has to do with local storage.

native tide
#

Somebody who know good in django?:P

#

I have a little problem

#

πŸ˜›

native tide
#

So in this moment i need to do one thing

#

I have my book_types (CHOICES)

#

and a view

#

and in my template i have something like this now

#

In this moment it looks like this

#

I try to do something like this

#

when user click on the type (Number 1-Biografia), he was see a book list with only this types

#

If there is not a books with this type, he see 404 or something like this

#

I don't know how to do this. Somebody can explain me or something ?

shrewd sand
neat nest
#

look up making post requests with aiohttp

#

aiohttp is a d.py dependency so you have it already

shrewd sand
#

@neat nest Its just a mess of crap

neat nest
#

...?

shrewd sand
#

@neat nest the docs don't mention anything about image useage

#
#

I would like to use that

#

But it won't work with async

tame viper
#

uhh any URL will work with async if you use aiohttp

neat nest
shrewd sand
#

No i mean

neat nest
#

it looks like the Imgur API is pretty clear on how to interact with it

shrewd sand
#

I can't use that API

neat nest
#

aiohttp can make POST requests with all that information

shrewd sand
#

Wait

#

aiohttp + imgur api?

#

ok

#

Makes sense

tame viper
#

aiohttp is basically requests but async

shrewd sand
#

@tame viper I got confused

#

But it looks complicated

#

Why should i have to generate tokens?

neat nest
#

the imgur API looks complicated???

shrewd sand
#

Yeah

#

I haven't done any http stuff before + i can't read docs

brave mantle
#

I can confirm at least one of these things :P

#

There must be a rest API tutorial out there though

narrow zealot
#

are there any good resources for getting started with the YouTube api?

quartz maple
#

Try some docs @narrow zealot

native tide
#

Anyone know this error, getting sqlalchemy_utils.exceptions.ImproperlyConfigured: β€˜cryptography’ is required to use EncryptedType using flask and sqlalchemy

meager anchor
#

a blind guess would be that you need to install the cryptography package with pip?

#

EncryptedType needs Cryptography library in order to work. yup

fickle chasm
#

Is it possible in Django to add a form for a different (related) object under a detailview?

#

I've got a school group detailview that I'd like to have a form under to add an assignment to the group

#

Would I just use a form mixin?

grand badge
#

@native tide what is your problem

native tide
#

@grand badge I Fix it yesterday, but thanks for asking :D

#

this is my code for the login form

def login():
    """Log user in"""

    # Forget any user_id
    session.clear()

    # User reached route via POST (as by submitting a form via POST)
    if request.method == "POST":

        # Ensure username was submitted
        if not request.form.get("username"):
            return apology("must provide username", 403)

        # Ensure password was submitted
        elif not request.form.get("password"):
            return apology("must provide password", 403)

        # Query database for username
        rows = db.execute("SELECT * FROM users WHERE username = :username",
                          username=request.form.get("username"))

        # Ensure username exists and password is correct
        if len(rows) != 1 or not check_password_hash(rows[0]["hash"], request.form.get("password")):
            return apology("invalid username and/or password", 403)

        # Remember which user has logged in
        session["user_id"] = rows[0]["id"]

        # Redirect user to home page
        return redirect("/")

    # User reached route via GET (as by clicking a link or via redirect)
    else:
        return render_template("login.html")```
 Whenever I enter invalid user/pass combo I am getting this error: TypeError: get_bind() got an unexpected keyword argument 'username'. instead of returning the invalid user/pass 403 page
any ideas why?
no issues when typing just username or just password. only getting error when typing in both
buoyant ledge
#

this is sql alchemy right?

native tide
#

yes

#

@buoyant ledge I can post the full code if needed

native tide
#

it was a syntax error

meager anchor
#

a TypeError is not a SyntaxError

#

if you're using SQLAlchemy, why are you writing SQL yourself, though?

stark yarrow
#

Hey its possible to use a string as a variable in Jinja? For example if I create a new dynamic field with setattr like, setattr(BaseForm, 'id', StringField('name'), this ID at the moment is unknown to me, because it comes from another server. I need to render it but the only way I can know the ids is if I pass a list of IDs to the template, and loop through it to find each ID. What I tried and failed is to loop in the template and use the ids like: form.ID().

#

if this makes sense

#

{% for id in list_of_ids %}
{{ form.id.label() }}
{{ form.id() }}{% endfor %}

#

list_of_ids is a list of strings

native tide
#

What is the best framework for web development?

native tide
#

for python? flask - django

native tide
#

I met with opinion from other people's that's django is worst than Flask. It was True? ;x

shrewd sand
#

@native tide flask is generally considered easier for begginers

native tide
#

@shrewd sand It's a fact or just opinion of a fews?

#

πŸ˜›

shrewd sand
#

@native tide thats subjective

#

So of course it aint fact

native tide
#

Oh, okay. I understand. Meaby when i have much more time i take closer with Flask. In this moment only Django.

shrewd sand
#

@native tide If you already know Django i see no reason to not continue with it

native tide
#

@shrewd sand Only just to see difference :d

grand badge
#

@native tide you can't really say one framework is worse than another framework. Flask and Django can make you the same end product. I guess its based on preference

#

Django is a batteries included framework while flask makes you choose the batteries you want with your project

tame viper
#

you can even mix and match. duracell + panasonic if you want.

#

sorry, bad joke lmao

buoyant ledge
#

(No you can’t that’s a bad idea Juan)

quartz maple
#

I'm having issues with Sockets and what content I am supposed to put in a .sock file. I'm not sure what it means in the tutorial i'm following by We will tell it to start 3 worker processes (adjust this as necessary). We will also tell it to create and bind to a Unix socket file within our project directory called myproject.sock. We'll set a umask value of 007 so that the socket file is created giving access to the owner and group, while restricting other access. Finally, we need to pass in the WSGI entry point file name and the Python callable within:.

#

``[Unit]
Description=Gunicorn instance to serve myproject
After=network.target

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
Environment="PATH=/home/sammy/myproject/myprojectenv/bin"
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app
I have setup my.service`` file.

#

However, it seems this bit: ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind is what is causing errors.

neat nest
#

had the error changed since the last time you provided it in this channel? if not, Gdude and I still believe it to be an issue with your directory permissions. make sure it's accessible to the user running the process

#

you don't need to put anything in the sock file, as the tutorial says, it will be created for you

quartz maple
#

okay well if it is

#

then, whats the command to change that?

#

the user is inteca-webmaster

#

and it was created for this

#

i didn;t realise i was supposed to use a non-root user

#

otherwise i would just use root

#

til i got evverything setup properly

#

no the error hasnt changed. but im restating my issue as i got in trouble for nt pproviding enough info

#

so there you go..

neat nest
#

chmod and chown are standard permission manipulation commands, I would look into them

quartz maple
#

sorry my typing i bad im on my school computer...

#

on a vpn

neat nest
#

also the User=sammy makes me think that the user isn't inteca-webmaster like you say

quartz maple
#

thats from the tutorial

#

as i said

#

im not on my usual omputer

#

dont ave access to my vps atm

neat nest
#

you don't have access to the system you're seeking help for?

quartz maple
#

well i can access it

#

i choose not to on a school device

neat nest
#

seems like a weird time to ask for help with it if you're not using it

#

but I guess you don't need to be on it to read about file permissions

#

good luck :+1:

quartz maple
#

whtt exactly do yu suggest i look for?

neat nest
queen needle
#

I dunno why everyone think Flask is easier for beginners, it seems like Django is to me

#

Django might seem more complex because it has more "stuff" packed in it, but without some solid class design, project management and understanding what extensions you need, you won't get very far in Flask - whereas with Django you can get a site up and running quickly and even takes care of the DB for ya

neat nest
#

I think the notion that it's easier lies in the fact that you can produce your first barebones web service in minutes, not that it can achieve the same level of baseline functionality with minimal effort

#

Django is certainly much easier in the sense that it handles lots of work and design for you in stages of development beyond the very earliest

grand badge
#

I think people don't recommend django to beginners is that a lot of things can be confusing at first. Flask is a bit more easy to understand. I started out with Flask and liked it but because of the many choices of databases and other stuff, I started learning django.

queen needle
#

yes, the main difference lies not in the difficulty of the framework but in the approach

#

that's why I think django and flask are not competing, but complementary

#

Django seems more suited for the top-down approach, while Flask is made for the bottom up strategy

quartz maple
#

how do i give chmod perms to a specific user?

#

``
● site.service - Gunicorn instance to serve inte.ca site
Loaded: loaded (/etc/systemd/system/site.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2018-08-01 10:28:21 UTC; 1min 53s ago
Process: 920 ExecStart=/var/www/main/site/site-env/bin/gunicorn --workers 3 --bind unix:sit
Main PID: 920 (code=exited, status=210/CHROOT)

Aug 01 10:28:21 KCWS systemd[1]: Started Gunicorn instance to serve inte.ca site.
Aug 01 10:28:21 KCWS systemd[920]: site.service: Failed at step CHROOT spawning /var/www/main
Aug 01 10:28:21 KCWS systemd[1]: site.service: Main process exited, code=exited, status=210/C
Aug 01 10:28:21 KCWS systemd[1]: site.service: Unit entered failed state.
Aug 01 10:28:21 KCWS systemd[1]: site.service: Failed with result 'exit-code'.
~
``

grand badge
#

Use three back ticks for a code block @quartz maple

quartz maple
#

I tried to yeah,

#

I mean I nearly did three but two seemed to look better

#

I know to use three

grand badge
#

I can't see a code block, maybe it's cuz I'm on mobile?

quartz maple
#

I can see a code block either

#

I used two code blocks as it looks better

#

Thst is when it comes to that specific one

tame viper
#

@quartz maple you've asked this question here before, and at least three people have told you that this isn't the right channel for that. you've also been told twice by Lucy exactly what to do, would you like me to show you again to save you from scrolling up a tiny bit? here you go.

quartz maple
#

@tame viper mate I was kicked

tame viper
#

for a reason

quartz maple
#

I can’t scroll up chances are, when I was kicked my messages were deleted

#

Jesus Christ of course for a reason

tame viper
#

nope

#

they're still there

quartz maple
#

Well I didn’t know that.

#

They normally delete

tame viper
#

and you're still not researching chmod and chown. shoo, get to it

quartz maple
#

Fyi I did

#

Ik use chown

#

And I don’t know if that’s the issue.

tame viper
#

so then try it?

quartz maple
#

I’m not on my pc

#

I was before now I’m in bed

tame viper
#

so then stop asking questions when you're not in a state to attempt the answers. did you not try beforehand, when you researched chmod and chown?

quartz maple
#

I researched them I didn’t attempt the thing I found as I hadn’t found it, but then I did and I wasn’t on my pc to execute it

#

Because I just got off.

tame viper
#

so then if you did find it, why are you still asking here?

quartz maple
#

Because I posted the error message before I did?

tame viper
#

but you found the answer already.. yes?

quartz maple
#

I’m not sure yet if it works, it works if it doesn’t

#

Then it’s something else’s

tame viper
#

so then why are you asking if you don't even know it works yet? if it does work, you'd just be wasting our time. (but you're already doing enough of that)

quartz maple
#

Yeah okay.

#

Where do I chown to?

#

Exactly

#

And if it isn’t the right channel, why does it relate to web development?

deep cave
#

a permission problem is not really related to web development, although it seems like we've already given you some keywords here.

tame viper
#

but it doesn't relate to web development? chmod and chown are questions about unix-like permission management. here's your answer, which you've already been given btw

quartz maple
#

Okay

deep cave
#

there's a linux discord where you might get help with chown or chmod, I can link you if you want.

quartz maple
#

And I will do that

#

No it’s okay I’m in a Linux discord

deep cave
#

well it might be better to ask them these kinds of linux questions

#

we're really just here to help with python

#

or other webdev questions

quartz maple
#

I know that, but it is sort of for Python, once I get past this error

#

It goes to flask

tame viper
#

once you get past that error, perhaps it is python. it's still not currently python though

deep cave
#

and once you get past it, you're welcome to come back here :P

tame viper
#

yup

quartz maple
#

I’ve never heard of gunicorn either.

deep cave
#

you just posted a bunch of gunicorn-related log output o.O

quartz maple
#

I followed a tutorial

deep cave
#

well you should probably try to gain a deeper understanding of the components that make up your application

#

following tutorials blindly without understanding what you're doing will lead you to places like this.

quartz maple
#

Well I’m new to flask, and I was told to use gunicorn with it otherwise I don’t know.

#

I don’t know what’s it used for.

#

I just wanna make it use port 80.

fickle chasm
#

in Django how to change permissions for a model with a OneToOne relationship to a User model?

#

currently I've got this -

#

`class Teacher(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)

class Meta:
    permissions = (
        ('create_assignment', "Create an Assignment object"),
        ('change_assignment', "Update an Assignment object"),
        ('delete_assignment', "Delete an Assignment object")
    )`
#

views.py class AssignmentCreateView(PermissionRequiredMixin, CreateView): permission_required = ('create_assignment', 'change_assignment', 'delete_assignment') model = Assignment form_class = NewAssignmentForm

#

i'm not sure if I should change Teacher to an AbstractUser or if there's a different way of going about it

#

i've already run manage.py migrate so the permission are in the db

#

I'd like it so that only users with a related teacher model can create assignment objects

uncut solar
#

Does anyone here know how to write/debug javascript?

#

I need help debugging my chrome extension, but I'm not able to open a developer tool window in chrome

native tide
#
{% block navbar %}
<nav class="navbar navbar-default navbar-fixed-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>                        
      </button>
      <a class="navbar-brand" href="#myPage ">Logo</a>
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#about">Inicio</a></li>
        <li><a href="#services">Lista de Material</a></li>
        <li><a href="#portfolio">InstalaΓ§Γ΅es</a></li>
        <li><a href="#pricing">MatrΓ­cula</a></li>
        <li><a href="#contact">Contato</a></li>
      </ul>
    </div>
  </div>
</nav>

<div class="jumbotron text-center">
  <h1>ColΓ©gio Intellectus</h1>
  <img src="logo.png">
</div>
{% endblock %}

help

#

Why this {% endblock %} is on the page?

tame viper
#

@native tide check the template that uses this

#

there might be an extra {% endblock %} there

native tide
#

I already get it

#

thank you

tame viper
#

okay cool :D

#

while i'm here, does anyone have any idea for flask projects i can do? i'd prefer it to be something useful that anyone can use ^-^

native tide
#

@tame viper , This a school website i'm training to do, but i'm too dumb. pepe

tame viper
#

hey, just keep trying. you'll get there :D

native tide
#

@tame viper a basketball api

tame viper
#

elaborate.

native tide
#

:D

tame viper
#

(that was a verb, not an adjective. my bad)

native tide
#

oh idk tbh i was just meming

tame viper
#

haha

#

if you can think of a good enough idea with that, i'll do it

#

i just want something to do

misty dome
#

HI
I need a pro in WebDesign
It is possible to put an entire card inside a label?
Is it correct?*

<div class="card">
    <label class="m-0" for="pizza_gigante_idProduto">
        <div class="p-1 p-md-2 card-header text-center bg-warning">
            <strong>
                <input type="radio" name="pizza_tamanho" id="pizza_gigante_idProduto" value="gigante">
                Gigante
            </strong>
        </div>
        <div class="p-1 p-md-2 card-body text-center">
            R$ 27,99
        </div>
    </label>
</div>

So I can click anywhere on the card
To activate the radio

shrewd sand
#

@misty dome use a span

#

Or make the div clickable

#

With <a>

solar glen
#

Hi, I'm trying to run a flask webapp(locally) that takes a CSV file and turns it into a QIF file for GNUcash. the file does get uploaded and put into the correct folder but it returns an internal server error. I think it has to do with how flask handles POST requests or it is something with my return function. Raboflask.py - https://pastebin.com/PeWQ3G1M Log: https://pastebin.com/eXUZ7t6m. Could anybody point me in the right direction?

stark yarrow
#

Hey, is it possible to populate a WTForm MultipleFileField field with known file paths? ex: form.pictures.data = ['full/file/path.jpg', 'full/file/path2.jpg'].

#

And is it possible to get the full file path on the computer with this field?

queen needle
#

@solar glen I can't check the code throughly, but have you set the content type properly? Also make sure you're handling bytes, not unicode string types

modern prism
river pawn
#

Hello! is there anyone who is good at facebook pixel tracking and help me please?

uncut solar
#

!t ask

lavish prismBOT
#
ask

Asking good questions will yield a much higher chance of a quick response:

β€’ Don't ask to ask your question, just go ahead and tell us your problem.
β€’ Try to solve the problem on your own first, we're not going to write code for you.
β€’ Show us the code you've tried and any errors or unexpected results it's giving
β€’ Keep your patience while we're helping you.

You can find a much more detailed explanation on our website.

river pawn
#

Thanks, I am now on Django Ecommerce project and FB tracking has already been partially implemented, but no dollar amounts are being sent.

#

I need to update existing code to send dollar amount.

#

I am new to FB pixel tracking and don't know what I have to do.

#

after googling, I saw this example. fbq('track', 'Purchase', {'value':'9.99','currency':'USD'});

#

I am guessing this is what I have to do. but not sure

#

This is existing code on my purchase.html

#
{% if facebook_pixel_id %}
    <script>
        fbq('track', 'Purchase');
    </script>
{% endif %}
#

Should I paste my facebook-pixel.py also ?

#

hello?

tame viper
#

please be patient, your question will get answered when someone who can help is available

river pawn
#

okay, thanks

forest narwhal
#

Can i use django framework to build personal website ?

tame viper
#

yes.

forest narwhal
#

lemoneye1 lemoneye2
lemonbeard1 lemonbeard2 πŸ‘Œ

solar glen
#

@queen needle thanks for your reply! πŸ˜ƒ the file that is uploaded is encoded as utf-8 but i will look into it more thanks!

sour heath
#

Is there a way to block someone from being able to see a flask url when it is only meant to be pulled by the javascript in the frontend, the information passed is meant to be hidden within the game, but I'm not sure how I would render the image from the data in the backend without another player to be able to simply pull that information by typing a url

neat nest
#

you'd either need a mechanism to verify that the frontend is making the request or to encrypt the response

sour heath
#

I believed so

neat nest
#

in either case, due to JS's rather transparent nature, you're essentially just obfuscating

#

a determined enough user probably won't find it difficult to spoof or crack whatever mechanism you use

sour heath
#

yea

#

welp

neat nest
#

the only surefire way to make sure they don't get the data is to structure your application so that it's not sent, but you mentioned that seems impossible

sour heath
#

well, to my knowledge

#

I'm not exactly the most experienced in this stuff

neat nest
#

if you share some of your concept, maybe others could weigh in

sour heath
#

my concept being what I'm doing?

neat nest
#

sure, at least enough that you think people could help determine how you might limit the data offered to the end user

sour heath
#

okay, I'll try, am I allowed to post an example of what I'm doing as a website?

#

or would that be classed as advertising?

neat nest
#

should be fine

#

will be fine, I should say. I'm an admin giving you explicit permission

sour heath
#

1 would correspond to player ones first card

#

up to 4 being all player ones cards

#

and 5-8 being player twos cards

#

this is obviously not good as its simple enough to access such data

neat nest
#

ah, I see

#

so you don't need to provide both players with all the data pertaining to the other player, it just happens to be publicly accessible at the moment

sour heath
#

what?

neat nest
#

you made it sound like you needed the frontend to always be able to get everyone's information, but that doesn't seem like the case to me

sour heath
#

really?

neat nest
#

the server should be doing the work of managing the rules, not the client

sour heath
#

did you also happen to test the basic functionality of the program to furthur prove your theory?

neat nest
#

it's less of a theory and more of a recommendation

sour heath
#

or is it such an issue on how my program is built

#

ah

neat nest
#

is there a reason that client 1 always needs access to client 2's cards? or could the server determine at its discretion when to reveal that information?

sour heath
#

truthfully, I'm not sure, I wouldn't think so

#

except when, during the playing phase of the game that exists between the two players that the other player would have to load the other players card as its played

#

in the actual game, their hands would be hidden

#

to each other till such an event occurs

neat nest
#

so in that event, they should be making a request to the server to find out what card was played, assuming you're doing this entirely with HTTP endpoints

#

does that sound feasible?

sour heath
#

well, I think so

#

by http endpoints you mean flask endpoints correct?

neat nest
#

yup

sour heath
#

something like this in the javascript $('#div3').replaceWith() would ruin such a thing though, yes?

#

as you can view in the webpage

neat nest
#

oh, is the card revealed when it's played or no? I admit I'm not testing your application at the moment because I'm on a phone and multitasking

sour heath
#

well, as I haven't exactly made it multiplayer, it more or less moves it

#

but theoretically if they were hidden in the first place, they would be 'revealed'

#

as I have a sort of 'key'

#

keys = { 'card1': player1Choices[0], 'card2': player1Choices[1], 'card3': player1Choices[2], 'card4': player1Choices[3], 'card5': player2Choices[0], 'card6': player2Choices[1], 'card7': player2Choices[2], 'card8': player2Choices[3]}

#

this is what the flask endpoint is using to comprehend what card is pulled upon making a jquery ajax request

neat nest
#

I'm afraid I don't follow

sour heath
#

okay, above is something that updates a dictionary that the javascript uses

#

in this endpoint

#

def play(card): card = card.strip('.') Played.append(keys[card]) return str(keys[card])

#

the only important part is the return

#

also accessing this url happens to mess up the flow of the game as it appends to the 'Played' list

#

this is just making it so in the js I can type something like: python var card = $.ajax({ type: "GET", url: "/image_movement/.card1", async: false }).responseText;

#

and it will return player ones first card

neat nest
#

this is more of a general comment on design, but it would also help mitigate some of your data hiding issues. my recommendation would be to have one /hand endpoint for this purpose, instead of an endpoint for every card. the clients would need to provide some token verifying which they were and then could recieve all the information they ought to at once

sour heath
#

but doing so would change the difficulty of 'playing a card'

#

as I would have to find the index of the card, but I'll be fine, what kind of token do you speak of?

#

whenever the ajax request happens it inputs the token?

#

I believe this would work but if the player were to view the js file in the debugger window, they could easily access such a thing

neat nest
#

sure but the player knowing their own token would only give them access to whatever information their client already has

sour heath
#

I see

neat nest
#

the token would be provided by the server to verify which client is which, you'd probably want to randomly generate them so they don't get reused

sour heath
#

so the file for each player would be different

#

js file that is

neat nest
#

hmm, I don't see why that would be the case

#

the server would make them aware of which player they are and that should be enough information

sour heath
#

hm

#

this seems difficult

#

what if the player were to trace the vars and find the token to the other player?

neat nest
#

why would they have access to the other player's token?

sour heath
#

well, thats what I'm finding hard to prevent

neat nest
#

there'd need to be an initial "handshake" where the server and client exchange information

#

that's when the client gets its token

#

although