#web-development

2 messages · Page 101 of 1

vestal hound
#

Also the WSGI standard isn't really meant for async programming which is why ASGI exists
@pine yew I think the point is to be able to deploy Django on both

pine yew
#

@vestal hound I don't see what there is to gain from that scenario.

true scroll
#

Hey guys, Flask_wtf captcha related issue , when i implement the captcha, it simply gets ignored whether its done or ignored, i can always submit the form

    username = StringField('Username', validators=[InputRequired(), Length(min=5, max=20)])
    password = PasswordField('Password', validators=[InputRequired(), Length(min=8, max=80)])
    repassword = PasswordField('rePassword', validators=[InputRequired(), Length(min=8, max=80)])
    recaptcha = RecaptchaField()```
```<form action="" method="POST">
    {{ form.hidden_tag() }}
    <p>{{form.username.label}}</p>
    {{form.username()}}
    <p>{{form.password.label}}</p>
    {{form.password()}}
    <p>{{form.repassword.label}}</p>
    {{form.repassword()}}
    {{form.recaptcha}}
        {{form.submit()}}
</form>
<p class="signup">Already have an account?<a href="#">LogIn!</a></p>```
#

it lets me submit the form without checking if iv done the captcha or not

native tide
#

Hi

native tide
#

Hello, new to front end

#

One question

#

Bootstrap. Worth it or no?

versed python
#

how do you define 'worth'?

strange briar
#

Bootstrap. Worth it or no?
@native tide yes

#

how do you define 'worth'?
@versed python no need to go further if you do front end you need bootstrap

versed python
#

not really

#

i haven't learnt bootstrap for one

native tide
#

can someone recommend web app projects? i know a little js, i know html, and i know css as well as python, but i want to tie them all together to make a nifty like, social media website, per se

#

i want a tutorial i can find. i know the code but im unsure of how to structure it and stuff you know?

versed python
#

!kindlings @native tide

lavish prismBOT
#

Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

zinc hill
#

quite new to full stacks development: so I have been playing around with django for a bit. Recently, I wanted to do something like

request.restaurant.order_set.all() # get all order

and I wanted to dictionary that so when pass to the front end it would be much simpler to unpack. Once unpack, I made each of the object that was pass a button so when click it sends the object back to View. I used fetch to send a POST to View.

Now my question is everytime the button is click and it trigger the JS, the objects becomes a string and when I send it to django it return as type string instead of the object. I did some reason and found out about serialisation and rest framework. Is this like a good practice to make an API and just have template request the data instead of passing data straight from View to Template?

strange briar
#

i haven't learnt bootstrap for one
@versed python You know what a framework library is ? yes
are they useful ? yes
do they work with react-apps and vue apps ? yes
Do most of the projects still use bootstrap ? yes
so MAYBE YOU never used bootstrap, but it is undeniably useful and widely used, ofc you can use another library, ofc you can write your css by yourself, BUT bootstrap is still the most used library today, so why deny the fact that if you want to learn about front-end bootstrap is obviously worth ?

versed python
#

Saying that bootstrap is essential to go forward on your path in frontend is like saying you cannot become a web developer without learning django. Django is just a framework that people prefer to get started with web development but by no means the only way. Similarly, bootstrap is also a framework. The only reason people prefer to get started with it is because it is easy to pick up and widely used.

#

TBH most frameworks do build upon the basics of bootstrap and extend it so you'll probably end up learning it either way.

#

But by no means is it NECESSARY to learn bootstrap.

strange briar
#

Bootstrap. Worth it or no?
that was the question, not bootstrap is essential to go forward on your path in frontend

versed python
#

and my answer was 'what do you mean by "worth"'

strange briar
#

it is easy to pick up and widely used. and it is a huge reason to learn about it, period, jesus Ignis you absolutely want the last word, bootstrap is worth learning about for someone new in front-end, why do you want to start a debate on what does he mean by worth, or the alternatives, it is worth

versed python
#

I am not trying to argue with you. The reason why it's widely used is because it's easy to use. Doesn't mean it's worth it. You really need to know what they mean by worth to recommend something. Maybe they are looking for a reactive website, bootstrap isn't what you should choose to make one.

#

or maybe they want to make a website that looks like a Google website, ie, a material design one. Again bootstrap isn't the right choice.

#

So yeah I still stand by it that they need to define what they mean by worth.

frozen python
#

I’m getting messed up with rendering data from my views/classes/def. as far as “files” what do I make -in order- to then render it as in “for i in examples”

stable kite
#

@frozen python ```py
return render(request,"your_html.html",{"examples":data})

winter spindle
#

heyyy

#

i am learning django from corey schafer but when i add his html and css the blog content gets hidden behind the navbar

nova nacelle
#

@winter spindle okay, use z-index:9999 for the header(navbar) in the style.

winter spindle
#

@nova nacelle heeyy bro the problem is like i want them to come below my navbar

nova nacelle
#

yes that's what it does

winter spindle
#

why 9999 ?

#

and i dont know whre

#

to put

#

can you tell

#

i will share my html and css

nova nacelle
#

DM me.

winter spindle
#

k

nova nacelle
#

Done..👍

crude crane
#

Hello

#

I'm having a problem with django forms validation

#
        postcard_form = PostcardForm(request.POST)
        if postcard_form.is_valid():
            data = postcard_form.cleaned_data  # data is a regular dictionary
            return redirect('/form_page')
        elif 'date_of_delivery' not in postcard_form.cleaned_data:
            raise forms.ValidationError("please enter a valid date") ```
#

here it's suppsed to tell the user to "enter a valid date" when they hit submit with an invalid date format

#

but for some reason it returns this error:

#

So how do i validate the data on the server side in django?

marble carbon
#

what's onn line 18

crude crane
#

line 18 is the last line

wise crescent
#

[Django]I got 2 problems when I try to use bootstrap, the first one is this. I'm not sure why it keeps popping up but it seems not affecting all the layouts

#

the other one is here. The dropdown-menu is not showing when I clicked on the profile pic. I have no idea how to troubleshoot this issue.

#

Please help. I never use javascript or bootstrap before

marble carbon
#

line 18 is the last line
@crude crane is there supposed to be _() around ur string that Discord might be escaping somehow

crude crane
#

no

sweet blaze
#

I'm using wtforms. And i want to check when a file is uploaded if it's of a certain type or not . I was wandering if it is possible to do this check as a validator ?

crude crane
#

@crude crane is there supposed to be _() around ur string that Discord might be escaping somehow
@marble carbon i tried adding it but it didn't work, it's giving me NameError at /form_page
name '_' is not defined

#

@marble carbon i tried adding it but it didn't work, it's giving
me NameError at /form_page
name '_' is not defined
@crude crane

marble carbon
#

just remove that _() and pass a simple string

crude crane
#

same error

modest scaffold
#

can anyone help me with this django error django.template.base.VariableDoesNotExist: Failed lookup for key [type]

#

i cant find anything on it

marble carbon
#

variable does not exist error

humble stump
#

sup folks

#

bit of trouble understanding this 500 error

#

js:

#
function knownCard() {                                                             
    xhr = new XMLHttpRequest();                                                    
    xhr.open('POST', '/_mark_known');                                              
    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');  
    xhr.onload = function() {                                                      
        if (xhr.status === 200) {                                                  
            alert('Something went wrong' + xhr.responseText);                      
        }                                                                          
        else if (xhr.status !== 200) {                                             
            alert('Request failed.  Returned status of ' + xhr.status);            
        }                                                                          
    };                                                                             
    var k = j % objects.length                                                     
    xhr.send(encodeURI(objects[k].id));                                            
};
#

flask:

#
@app.route('/_mark_known', methods=['POST']) 
def mark_known():
  return flash('success')
#

so, i'm sure it's doing something because removing methods=['POST'] returns 405 error rather than 500

#

mad because it kinda works

vapid acorn
#

In django, how and where is stored, wether a user is logged in or not ß

stable kite
#

@vapid acorn it is in request that you get in your view

#

@humble stump I think because you are passing data to your view but your function doesn't accept any arguments.

versed python
#

@vapid acorn it is in request that you get in your view
@stable kite i think they're asking where the data is stored not how to access it. I think it is stored in is_authenticated field in the database

stable kite
#

@versed python there is no fields like is_authenticated in django default user database

versed python
#

hmm you're right

#

i did say i wasn't sure lol

#

it's a method right?

stable kite
#

we can get user requesting a resource from request only

#

it's a method right?
@versed python yes

versed python
#

we can get user requesting a resource from request only
@stable kite but where does this request get the user from?

stable kite
#

Django does it on it's own

versed python
#

that's not really a valid answer

vapid acorn
#

I mean if you wanted to code this part yourself, would it be stored with a session id on the server or in the cookies or on the client side in the session-storage?

stable kite
#

@versed python request are objects of classes of HttpRequest so this is where we get user

vapid acorn
#

but it isnt just bound to one request

stable kite
#

but it isnt just bound to one request
@vapid acorn wdym?

#

@vapid acorn the session idare stored as cookies on client

vapid acorn
#

yeah

versed python
#

so you're implying that whether a user is logged in or not isn't stored inside the database at all?

#

I think that is actually true

stable kite
#

@versed python yes

versed python
#

yeah

vapid acorn
#

that sounds logical

versed python
#

i think the browser caches or something

#

i dont understand that shit

stable kite
#

the last time of login is stored on database

versed python
#

yep

vapid acorn
#

couldnt you just modify the browser cache on the client side as the client?

stable kite
#

@vapid acorn you can

versed python
#

you could. It's called logging out

vapid acorn
#

What do you think is stored in the cache, A session token together with a boolean to indicate if the user is logged in?

stable kite
#

@versed python modifying is session id is not called logging out

vapid acorn
#

*boolean is wrong, wouild rather be a user id

stable kite
#

@vapid acorn no the session id which is generated by django

vapid acorn
#

@stable kite I just printed the stuff stored in the get-request, and there was no indicator wether the user is logged in or not

#

just and empty <QueryDict: {}>

stable kite
#

you have to use request.user

#

to get the data of user

vapid acorn
#

oh ok imma try that

#

If im logged out it's now:
AnonymousUser
And if I'm logged in:
myUsername

#

That makes sense

stable kite
#

yes

untold dirge
#

https://www.linkedin.com/posts/harshita-raj_aos2020-projectabrlead-participant-activity-6722771055259344896-3Swa
Please visit the above link and register for another open source program AUTUMN OPEN SOURCE 2020 .

The link for the same are given in comments and join the slack channel given in comments of the post in the above link.

Register here as a participant https://aos.sanscript.tech

Hey folks ! 🚀

I'm delighted to be a part of this great event #AOS2020 (Autumn of Open Source 💜 2020) and get selected as a #Project_Lead for the same...

red pine
#

consider if i have a (small) set of users who create content for my website and the general set of users who can view the content. Do i put both these types of users in the same table in django ?

wanton ridge
#

I have a login.html and a register.html. Anyone can explain me how to put those two html files in a web framework flask? I wanna do if someone register and then you can only login with the registered datas.

red pine
#

do you know flask ?

versed python
#

consider if i have a (small) set of users who create content for my website and the general set of users who can view the content. Do i put both these types of users in the same table in django ?
@red pine ideally no. Separate them.

red pine
#

in /admin i see something called groups, is it useful for this kind of a situation ?

versed python
#

yeah it is. But from what I have heard, these groups aren't really useful and become not enough after you introduce some application complexity. I think there are packages out there which handle this stuff better so maybe you can look into those.

#

but yeah groups is the way to go

red pine
#

okay thanks

versed python
#

oh wow

red pine
#

haha

versed python
#

i had no idea he was on pydis

red pine
#

i dont think he is active toh

versed python
#

also you just ghost pinged him

#

huh yeah maybe

red pine
#

this is one cool guy i like his cotent

wanton ridge
#

@red pine no i am wanna learn flask

red pine
#

see you have to set up routes in flask and then you can manage log in etc after you have some user model

wanton ridge
#

ahh i see

red pine
#

routes > views (models) > template this is basically it. a route is like www.yourdomain.com/about/ the about is a route. once this route is hit flask will check which view corresponds to this route and display that view using a template (if any)

wanton ridge
#

ohh thanks!

#

i am watching some videos of login&registration in flask and trying to understand it and then doing it myself

red pine
#

try to follow one complete tutorial from start to finish if you see user auth from one channel and models from another you might miss stuff

wanton ridge
#

sure i will. Thanks for your advice

midnight kayak
#

hello

ivory niche
#

my own css is being overiden by bootstrap

#

is there a way to fix that

#

base code

{% load static %}

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="{% static 'css/base.css' %}">
        {% block extrahead %}{% endblock %}
        
        <title>Chatparty - {{Title}}</title>
    </head>
    <body>
        
        {% block content %}
        {% endblock %}

        <!-- jQuery first, then Popper.js, then Bootstrap JS -->
        <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

    </body>
</html>
mild helm
#

Why is it when you have the same variable and two different values. The first one takes precedence over the other? @obtuse iris

obtuse iris
#

I'm not quite sure that I understand you, @mild helm

#

I'll repost my original question:
When using wsgi servers like Gunicorn, is it required to both:

  1. have the actual server installed on your system via apt-get install gunicorn and
  2. have the python package installed via pip install gunicorn?
mild helm
#

Sally = 'pickles' Sally = 'cucumbers' then print why is pickles always print first than cucumbers?

#

@obtuse iris

obtuse iris
#

Oh, you're asking me an unrelated question

#

Can you give me some actual code?

#

You're correct in that the behavior you're saying is happening is strange, but I cannot reproduce it if I don't know exactly what you did

quick cargo
#

@obtuse iris gunicorn is just python

#

you just do pip install gunicorn

obtuse iris
#

@quick cargo Hmm... That's what I thought. I'm trying to troubleshoot the appearance and meaning of this error when I run a dockerfile (I'll get that in a second)

#

Dockerfile:

FROM python:3.7

RUN apt-get update -y
RUN apt-get install -y python-pip python-dev
RUN apt-get install -y gunicorn
RUN apt-get install -y python-gevent

# We copy just the requirements.txt first to leverage Docker cache
COPY ./requirements.txt /app/requirements.txt

WORKDIR /app

RUN pip install -r requirements.txt

COPY . /app

# ENTRYPOINT [ "python" ]

CMD [ "gunicorn --workers 3 --bind 0.0.0.0:5000 app:wsgi" ]
quick cargo
#

do python -m gunicorn

obtuse iris
#

Sorry to be verbose, but to be clear, you mean to replace the last line with CMD [ "python -m gunicorn --workers 3 --bind 0.0.0.0:5000 app:wsgi" ]?

red pine
#

does anyone know how to create a link in my navigation to the django admin page ?

quick cargo
#

well you should have them as seperate arguments @obtuse iris

#

idk why you also do apt-get gunicorn or gevent

obtuse iris
#

That's just there because I was troubleshooting why it wasn't working

quick cargo
#

try ["gunicorn", "--workers", "3", "--bind", "0.0.0.0:5000", "app:wsgi" ]

obtuse iris
#

Give me one second! What would the separate strings accomplish?

quick cargo
#

well its todo with how its passed to exec

#

Docker is built off Go and go's exec system requires that they be seperate argument otherwise they get escaped as one lone single command

obtuse iris
#

I see, I did not know this!

#

Either way, it's still treating it as a file:

#

I think I'm doing something really stupid here. Should I not have ENTRYPOINT ['python'] in there?

#

That was it! Now I'm getting a module error I'm going to tackle for a minute or two. @quick cargo , thank you!

#

@quick cargo It works! That was indeed the gotcha, separate they work

left vigil
#

How can I make a form field unique inside of flask? not in the database

stone wren
#

how do I parse json objects that keys are index numbers?

like this:

{
  "COUNT": "32",
  "ITEMS": [
    [
      "21",
      "ar",
      "Argentina ",
    ]
}
summer wyvern
#

what do you recommend for webapps/frameworks
Django or Flask

#

I want to make a webapp that generates passwords

silver shell
#

@summer wyvern Django

#

I have a @property on my model which calculates a result based on data. If data is not present it raises an ArithmeticError with an error message. In my serializer i put this field in Meta->fields, however when ArithmeticError is raised due to missing data, server crashes and returns 500. I instead just want to serialize the ArithmeticError message back to the user, so that user knows why it cannot calculate. How do I do that?

native tide
#

@summer wyvern Django seems to be the accepted go-to if you want as many features as possible, but its obviously more complex, the file structure tends to scare off a lot of beginners as well but its nowhere near as complicated as it looks

#

Flask is also alright though

snow pollen
#

is there a way to get linting to work with transcrypt

native tide
#

how to make a html into an actual site you can search?

snow pollen
#

?

vapid acorn
#

you mean publish it to the web?

native tide
#

yes

quick cargo
#

host it and link it to a domain

snow pollen
#

github pages

quick cargo
#

then basically wait for google's web crawlers

native tide
#

@snow pollen uhh

#

why u copy my name

#

and ok thank you

snow pollen
#

google picks up github pages pretty well

native tide
hollow flower
summer wyvern
#

Hi

left vigil
#

How can I make a form field unique inside of flask? not in the database

#

adding a unique validator to this

radiant aurora
#

double forward slash

#

any idea why would that happen?

#

views.py

@login_required(login_url='/accounts/login/')
def dashboard(request):
    return render(request, "dashboard.html")

urls.py

path('dashboard/', dashboard, name="DUS Dashboard"),

html file

<a class="navbar-item" href="{% url 'DUS Dashboard' %}">
iron cliff
#

How can I do that? I didn't understand?? (Sqlite)
Encrypt the database and store the password on PATH

native tide
#

@radiant aurora I think your name shouldn't contain spaces

radiant aurora
#

My name?

versed python
#

@radiant aurora name in urls.py. It shouldn't contain whitespaces

#

just use hyphens or underscores

lofty marsh
#

This might sound really dumb but how do you get subdomains that are before the main domain (as in en.domain.com)?

marble carbon
#

u need to create a DNS record for that

#

and point it to ur server

marble carbon
#

v nice

#

you know u could just take screenshot

#

instead

#

or even post code itself

worn rapids
#

Anyone know how to write tests for django forms, specifically crispy forms? Can't seem to find documentation on it

versed python
#

@worn rapids you could try giving incorrect input to your forms and checking if the correct ValidationError is being raised

#

idk how to make it specific to crispy forms though

worn rapids
#

do u have an example for generic form test implementation? @versed python

marble carbon
#

@fair shale u might have better luck getting help, if u posted ur problem/question itself

versed python
#

@worn rapids i dont really use Django forms anymore, but one of my projects I did, I did test views and their corresponding forms.

marble carbon
#

you gotta install the thing ur trying to import first

versed python
#

that's really unhelpful information

#

just post the traceback

#

bruh

#

ok

#
  1. post your code which gives you the error
  2. post the FULL traceback
ashen bay
#

Anyone here familiar with beautifulsoup :\

slender needle
#

How do I start web developing with Python ?

versed python
#

RUN

real rain
#

start with learning flask or django

#

and build up from it I guess

#

@slender needle ^^^

slender needle
#

Ohhh

#

Thanks !

pine bane
#

Hi, I am using FastAPI to develop an API and using postgres as DB. I have to add pagonation any helpful resource?

night spoke
#

anyone familiar with the django polls tutorial? I am on part 5 and the admin site does not allow to create choices. i can't tell if i missed something or if you are just expected to command line in all the choices

versed python
#

what exactly are you doing?

radiant aurora
#

@radiant aurora name in urls.py. It shouldn't contain whitespaces
@versed python we can use whitespaces. But why is the extra slash coming at the end?

versed python
#

i have no idea. And i recommend you remove the whitespace. Use camelcase or just hyphens or underscores

radiant aurora
#

I'm using the space for a reason. If its not fixing the double slash issue then there is no point in removing it for now.

#

thanks though

iron cliff
#

Hello, I need to encrypt my SQLite database and store it in the path. Anyone knows how to do it or made this before?

radiant aurora
#

check out sqlcipher

marble carbon
#

Hello Saitama

tame kelp
#

yeah

marble carbon
tame kelp
#

ok

#

uh all of it?

ripe goblet
#

me will eat popcorn while i watch Soder help saitama

tame kelp
#

:3

ripe goblet
#

i think this is dejavu

marble carbon
#

lol

tame kelp
ripe goblet
#

valk was the one i also helped with this

#

he has problems with static

tame kelp
#

hmmm

marble carbon
#

yea static isn't configured right

tame kelp
#

well, i got problems with everything so ur always gonna get deja vu :3

marble carbon
#

add staticfiles_dir

tame kelp
#

?

#

also i think i revealed my secret key...

marble carbon
#

that link before static_root

#

open it

#

lol doesn't matter it's on ur local system

#

don't be too paranoid xD

tame kelp
#

lel

ripe goblet
#
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]```
#

it should look like that

tame kelp
#

oh, i only have static url

marble carbon
#

yeah also, show tree where ur saving static files

ripe goblet
#

@tame kelp i think django uses pathlib now

marble carbon
#

it's fine

tame kelp
marble carbon
#

i still revert back to regular one

tame kelp
marble carbon
#

yep

#

app tsatic

glass sandal
#

STATIC_URL is your static folder . and STATICFILES_DIRS is all directories you have static files in them . So you can load static and use them in your HTML

tame kelp
#

STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")], even after adding this it doesnt work

glass sandal
#

There is STATIC_ROOT too , for collect_static mostly

#

STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")], even after adding this it doesnt work
@tame kelp what do you wanna do

ripe goblet
#

@tame kelp STATICFILES_DIRS = [BASE_DIR / 'static']

tame kelp
#

ok

#

i did import os tho

marble carbon
#

ok I'll let thems take over xD

glass sandal
#

What do you wanna do saitama

#

Tell meh

tame kelp
#

scroll up my net is slow

ripe goblet
#

@glass sandal he has problems with static files

glass sandal
#

OH

#

Sait

#

GOto your HTML

#

Goto*

#

And then add this to top of your html file

ripe goblet
#

i think he did what i think it is

glass sandal
#
{% load static %}
ripe goblet
#

yeah he did that

tame kelp
#

i did that

glass sandal
#

Hmm

#

What do you do when you wanna use a file?

ripe goblet
#

i did that
@tame kelp so is it working now?

tame kelp
#

no, i did that earlier

ripe goblet
#

ah i mean STATICFILES_DIRS?

tame kelp
#

it isnt :(

glass sandal
#

You have to do this :

<script src="{% static "file.js" %}"></script>

Example

tame kelp
#

yeah, i did but not working still

glass sandal
#

Then

tame kelp
#

wait

glass sandal
#

Add STATIC_ROOT

tame kelp
#

my net is sloww

glass sandal
#

and set it to :

ripe goblet
#

i think it might be his file structure

glass sandal
#
STATIC_ROOT = os.path.join(BASE_DIR, "assets")
#

And then

tame kelp
#

weaiiit

glass sandal
#

run :

python3 manage.py collectstatic
tame kelp
#

i didnt reply to u

#

AHHHHHH

ripe goblet
#

he forgot collectstatic ?

glass sandal
#

i think so

marble carbon
#

lol

#

what if he's having cache issue

tame kelp
#

it gives me file not found error

marble carbon
#

:)

#

nvm

#

lol

glass sandal
#

file not found?

ripe goblet
#

lmao

glass sandal
#

Then make it lmao

tame kelp
#

which file

glass sandal
#

what file does it give error

tame kelp
#

i dont think my image will upload

glass sandal
#

MEDIA_ROOT ?

ripe goblet
#

i think i know

tame kelp
ripe goblet
#

i think i know

#

wait wait

#

did you only have /static as a folder?

#

no subfolders with /css/ or /js/?

tame kelp
#

what?

glass sandal
#

Yeah right , was that the only folder?

#

What are static's subdirs?

tame kelp
#

i sent my folders you can look

ripe goblet
#

/static/css/main.css <~

tame kelp
#

wait what

glass sandal
#

Got it

tame kelp
#

i didnt create a css folder

glass sandal
#

move it one dir topper

ripe goblet
#

you should do that

glass sandal
#

Move static to one dir upper

#

That'd fix it sait

#

surely

#

trust meh

ripe goblet
#

yeah trust us

tame kelp
#

so my main.css will be inside css which will be inside static?

glass sandal
#

Noooo

#

Do what i said

#

Move static to one dir upper
^^^

ripe goblet
#

when i was a noob

tame kelp
#

i didnt understand what u said

glass sandal
#

🤦 Just move static to one directory upper than the current one

#

Like move it to the directory that manage.py is in

tame kelp
#

what does that meannnn

ripe goblet
#

holy shit

glass sandal
#

r u ....r u kidding me

#

move that to one dir upper

ripe goblet
#

move it up in the directory

glass sandal
#

Move it from Web_dev/simple_web/ to Web_dev/

tame kelp
#

like static will be inside my main web folder instead of my blog app?

ripe goblet
#

yup

glass sandal
#

Yes 🤦

tame kelp
#

its inside my blog app

glass sandal
#

Move it one dir upper

#

please

#

it'll fix it

#

100%

ripe goblet
#

yes

glass sandal
#

no doubts on that

tame kelp
#

and should i remove what u guys told me to do ealier?

ripe goblet
#

what remove?

glass sandal
#

Just

#

move

#

that

#

folder

#

Test

#

if didn't work

#

Then get help again

tame kelp
#
STATICFILES_DIRS = [BASE_DIR / 'static']
STATIC_ROOT = os.path.join(BASE_DIR, "assets")```can i remove this
glass sandal
#

First of all

tame kelp
#

didnt work :/

#

lemme try moving it up once more

glass sandal
#

Change

STATICFILES_DIRS = [BASE_DIR / 'static']

to


STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
#

Don't

#

Do

#

that

#

please

#

Just let it be where it is rn

tame kelp
#

ok

glass sandal
#

You have to chill a bit lol . Don't just do everything again if it didn't work

#

no offense just saying

#

It must work now

ripe goblet
#
├── hypernews
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── manage.py
├── news
│   ├── admin.py
│   ├── apps.py
│   ├── __init__.py
│   ├── migrations
│   │   └── __init__.py
│   ├── models.py
│   ├── tests.py
│   └── views.py
├── static
│   └── css
│       └── base.css
└── templates
    ├── base.html
    ├── create.html
    ├── future_page.html
    ├── index.html
    ├── main.html
    └── search.html``` your static should be like this okay? remember that okay? create a github repo for it so you can remember it okay?
glass sandal
#

Also , every app isn't a project . A project is different , in django at least

#

A project contains different apps

ripe goblet
#

^

glass sandal
#

But your main dir is an project

ripe goblet
#

yup

glass sandal
#

as far as I can tell

tame kelp
#

it doesnt work

glass sandal
#

What errors?

ripe goblet
#

can we look at your directory tree?

#

:3

tame kelp
#

ok wait

ripe goblet
#

tell us both the error and the dir tree

glass sandal
#

Yeah

tame kelp
#

it says this -```[18/Oct/2020 14:34:58] "GET / HTTP/1.1" 200 3045
[18/Oct/2020 14:34:58] "GET /static/blog/main.css HTTP/1.1" 404 1665

glass sandal
#

Not found

tame kelp
#

and it looks weird and not what its supposed to

ripe goblet
#

why is it blog?

glass sandal
#

Oh my ... why blog

ripe goblet
#

it should be css

glass sandal
#

Yeah exactly why blog

#

Change {% static "blog/main.css" %} to {% static "main.css" %}

#

in your html

ripe goblet
#

{% static "main.css" %}

#

i see typo

tame kelp
ripe goblet
#

okay try it now

tame kelp
#

IT WORKEED

ripe goblet
#

:3

glass sandal
#

nice

#

gg

ripe goblet
#

nice gg cyka blyat

#

i think blog will still work if {% static "/blog/main.css" %}

glass sandal
#

Idts

ripe goblet
#

he lack a slash

glass sandal
#

static will choose the static dir

#

Not the main dir

ripe goblet
#

ah okay

tame kelp
#

idk, i just did it main.css and it worked

glass sandal
#

mhm . Since you didn' t have a folder named blog in static

#

And main.css was just in static , not in static/blog or something

ripe goblet
#
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ title }}</title>
    {% load static %}
    <link rel="stylesheet" href="{% static 'css/base.css' %}">``` mine looks like this
#

hmmm

#

mhm . Since you didn' t have a folder named blog in static
@glass sandal ah i see

glass sandal
#

mhm

#

imho , saiT should've learned Flask first

#

Cause he would've understood how things worked in Django better

tame kelp
#

thanks a lot, tho i have no idea how can i make a frontend like that on my own >.<

ripe goblet
#

really? i didnt learn flask :((

#

i have not learn it yet either

glass sandal
#

I didn't learn flask at first either . But when I did , I understood how django worked better

ripe goblet
#

I didn't learn flask at first either . But when I did , I understood how django worked better
@glass sandal ooooooooooooooooooooooh time to flask then 😮

glass sandal
#

It helps you , also , flask itself is as powerful as django , easier to deploy

#

But it needs 3rd party libraries for some things

#

like e.g , for admin we have flask-admin

peak meadow
#

Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:

[uwsgi]

chdir = /home/pi/sampleApp
module = sample_app:app

master = true
processes = 1
threads = 2

uid = www-data 
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true

die-on-term = true

lazy = true
lazy-apps = true

This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?

ripe goblet
#

but what if i got the hang of django? do i need to?

glass sandal
#

It is good to learn flask

#

And it is easy

ripe goblet
#

okay then

#

so can you help the next guy?

glass sandal
#

Lemme check it

#

Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:

[uwsgi]

chdir = /home/pi/sampleApp
module = sample_app:app

master = true
processes = 1
threads = 2

uid = www-data 
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true

die-on-term = true

lazy = true
lazy-apps = true

This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?
@peak meadow try change module to app:app

peak meadow
#

sample_app is the name of the py script

#

sample_app.py

glass sandal
#

Oh I see

#

Hmmm

peak meadow
#

I was talking more about

marble carbon
#

don't quote such big stuff smh

peak meadow
#

what to use http = 0.0.0.0:3134

#

or http-socket = 0.0.0.0:3134

glass sandal
#

try http-socket first

peak meadow
#

or what's the best aproach as this one works smooth

#

I think the one that i got

#

because I specify protocol = http

#

it's http-socket

glass sandal
#

Wish I knew wsgi more

peak meadow
#

yeah, no worries

glass sandal
#

Not much knoweledge of wsgi

#

Well , pretty sure someone could help u . Probably not me since I don't have experience working with wsgi

peak meadow
#

Np

#

Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:

[uwsgi]

chdir = /home/pi/sampleApp
module = sample_app:app

master = true
processes = 1
threads = 2

uid = www-data 
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true

die-on-term = true

lazy = true
lazy-apps = true

This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?

#

I put this here so people can see it again. Thank you

tame kelp
#

wish i can learn how to make this kind of frontend soon, but for now i will just use coreys snippets

marble carbon
#

need help with wsgi?

#

hmm what u using uwsgi or gunicorn?

tame kelp
#
django.template.exceptions.TemplateSyntaxError: Could not parse the remainder: '-home' from 'blog-home'```
#

oh wait i think i know

#

nvm i figured it out

#

they will be inside quotations

native tide
#

hello

stray shard
#

can anyone help me,
I have 90 links, I want to change them to my affiliate link then upload them into my site.

twilit dagger
#

@tame kelp Lol I still use Corey's snippets

tame kelp
#

lel

rapid bramble
#

Hello,

#

Anyone would like to make a Django based application for a small amount of money?

slate tinsel
#

e

rapid bramble
#

Basically looking to hire someone for a project though I don't have that great a budget

slate tinsel
#

i would do it for free but i dont know yet how to do it yet i havent got to that part in my school yet sorry

rapid bramble
#

Django isn't taught at school, and I'd have done it myself just if I wasn't facing this shortage of time.

scenic moat
#

Would you guys please help me? What should I know in Python & Django to create a "Courier Based Web Application" ? Is there any specific to focus on most?

radiant aurora
#

Have you worked on Django before?

scenic moat
#

No...I'm beginner that's why I'm just wondering to know...😩

stable kite
#

this is giving me an error
@tame kelpit should be like this {% url 'blog-home' %}

tame kelp
#

uh, i fixed that

nova imp
#

Hey guys, has anyone know how to use matplotlib's plt.imshow in a Flask server. Using it for a research project to embed numpy arrays for easy visualisations.

peak meadow
#

Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:

[uwsgi]

chdir = /home/pi/sampleApp
module = sample_app:app

master = true
processes = 1
threads = 2

uid = www-data 
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true

die-on-term = true

lazy = true
lazy-apps = true

This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?

cold portal
#

I have a question about displaying ajax json content that auto-refreshes, without a data table or full on chart and without refreshing the page. Just trying to get advice on any way I can achieve that. I’m going for a dashboard of sorts where there are “cards” on the page displaying a number that is automatically updated based on the json data retrieved from the Ajax request. Any ideas?

#

(I’m using Django)

orchid agate
summer wyvern
#

Hi

#
python django-admin.py runserver
#

but this is the output

#
Traceback (most recent call last):
  File "django-admin.py", line 21, in <module>
    management.execute_from_command_line()
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
    super().execute(*args, **options)
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\management\commands\runserver.py", line 68, in handle
    if not settings.DEBUG and not settings.ALLOWED_HOSTS:
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\conf\__init__.py", line 83, in __getattr__
    self._setup(name)
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\conf\__init__.py", line 68, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
#

please help

#

thanks

radiant aurora
#

I think you need to have a manage.py file and then run it

toxic flame
#

Good night, I have a django application, which on a models I have a textfield, on the textfield, I want to render the amount of rows inside of the textfield into an integer, currently I reached to the point where it counts all the chars in the textfield, but I want it to count each row on \n break.

versed python
#

@toxic flame perform a .splitlines() on the text field and find the length using len()

toxic flame
#

@versed python how do I query the textfield though?

#

.values()?

versed python
#

Like you normally would

#

yeah there are various ways

#

just use one

#

you shouldnt require values since that would be db intensive

toxic flame
#

instance = productsByTheSeller.values('stock')
ree = instance.splitlines().len()

versed python
#

there are other ways to select a particular column using django orm, i don't remember tho

toxic flame
#

it currently returns an error

versed python
#

re = len(instance.splitlines())

toxic flame
#

o

#

'QuerySet' object has no attribute 'splitlines'

#

thus this is the error

versed python
#

uhh yeah you need to extract the text

toxic flame
#

i will use google thanks.

versed python
toxic flame
#

he's probably importing an external icons library

versed python
toxic flame
#

you add # in front of a selector and it will become an id, a . and it will become a class

versed python
#

how do I do that?

toxic flame
#

with class, you can put more than 1 class in 1 'variable'? is that what you call it?

#

for example

#
.blue{
  color: blue
}
.border{
  border: 1px solid black
}
<h1 class="blue border">Hello</h1>```
versed python
#

I think I was unclear expalining my question. bsically I need to add a # inside a <span class="icon icon-link"></span> using only css

toxic flame
#

this will show the text as blue and has a 1 px solid black border

#

uh

versed python
#

I am sure it can be done

#

have no idea how. Using tailwind css if that helps

toxic flame
#

you mean hide the css?

stable kite
#

@versed python what is your questions

versed python
#

Can someone tell me what css classes can I add to make this span look like this?
@versed python starts here

#

I think I was unclear expalining my question. bsically I need to add a # inside a <span></span> using only css
@versed python this is the genral gist @stable kite

#

you mean hide the css?
@toxic flame Not really. The css is there so that I can target the element. But I can't figure out how to add a # inside the <span>

stable kite
#

@versed python just type it

versed python
#

I can't

#

its generated dynamically

#

it was originally written in markdown

#

and converted to html using something

toxic flame
#

the image does not show any #

stable kite
#

what is written in markdown?

versed python
#

Basically it's a blog post

#

That was written in md files

#

the image does not show any #
@toxic flame It doesn't have any. That what I am trying to add

toxic flame
#

can you show me where do you want to add it

versed python
#

inside the span tags

#

the first pic i sent

stable kite
#

just you span as prefix &after # your dynamic content

versed python
#

how to do that

#

using just css?

toxic flame
#

<span class="icon icon-link">#</span>?

versed python
#

yeah

#

that's what I require

toxic flame
#

um

#

just put it

versed python
#

<span class="icon icon-link"></span>but I have

toxic flame
#

i don't see any reasons why it wont display

versed python
#

just put it
I can't its generated dynamiclaly

#

which means I have not written any html

toxic flame
#

what's the backend frameowkr?

versed python
#

vuejs + tailwind css

toxic flame
#

it's probably related to tailwind css

#

1 moment

versed python
toxic flame
#

why don't you build your own css? it's alot easier

versed python
#

why don't you build your own css? it's alot easier
That doesn't answer my question

toxic flame
#

welp i'm having a hard time still doing my problem

versed python
#

nvm I solved mine

#

I just used javascript instead of css

dense slate
#

Ok quick question: If I am the author of a campaign, this following code puts a result in my query for every subscriber (not me) that is in my campaign.

campaigns.filter(Q(author=request.user) | Q(approved_subscribers=request.user))```
#

Why would it repeat for every subscriber? I just want it to show in my list only once per situation if I am either the author, or I am a subscriber in someone else's campaign.

#

Currently, every person that is in one of my campaigns, causes the campaign to repeat on my list for the number of subscribers that exist in it.

vestal hound
#

@dense slate that's because of how SQL works

#

basically, your query as is translates to a UNION ALL

#

wait, let me look at that again

#

no, that's not right

dense slate
#

I want a campaign to be listed if I am the author or if I'm a subscriber.

vestal hound
#

yes, and the solution is to use .distinct() at the end

#

but that shouldn't be happening

dense slate
#

Right

#

I use distinct elsewhere, but it doesn't fix this one.

vestal hound
#

approved_subscribers is a M2M field...?

dense slate
#

Right

vestal hound
#

okay, got it

#

that's why

#

try distinct('id')?

dense slate
#

But why would it repeat a campaign I author, for each subscriber that is not me?

#

I only ask for them where I am the author, or I am one of those subscribers

vestal hound
#

can you show the result of print(campaigns.filter(Q(author=request.user) | Q(approved_subscribers=request.user)).query)?

#

I just woke up so maybe I'm on the wrong track but I'm p sure it's because of the join over the M2M field

dense slate
#

Not at my pc, I'll try in a bit.

#

If you wanted to query events, for which you are either an creator of member, would you approach that query this way in the first place?

vestal hound
#

honestly it feels like it makes sense

#

I use distinct elsewhere, but it doesn't fix this one.
@dense slate I believe that it doesn't work because the rows returned are not distinct after the join

dense slate
#

Why did you add .query? What does that do?

vestal hound
#

it contains the generated SQL

dense slate
#

Ah

vestal hound
#

so my guess is that after the join, the rows are not distinct because they differ in the joined values, which are not shown to you because they're not part of the Campaign model

#

which is why .distinct() doesn't work

#

but if you take distinct over id, it should...?

dense slate
#

I'll try it when I can

vestal hound
#

although I feel like this should work out of the box

#

do you have like any annotations or something

brisk jay
#

Hey guys. This is /technically/ a python web question as i'm using flask backend.
I have Access-Control-Allow-Origin turned on on my API and application, but still chrome is blocking my js post requests,

#

Any idea why ?

versed python
#

idk if it's the same but django has a package called django-cors-headers

#

maybe you can find something similar for flask

gaunt marlin
#

i remember that frontend framework sometime has the settings that block cors too, happened to me before

azure kestrel
#

Hi

#

So I am having trouble with a redirect to a url in the requestslibrary with python

#

I try to go to this url
https://<USER>:<PASSWORD>@api.stocktwits.com/api/2/oauth/authorize?client_id=<CLIENT_ID>&response_type=token&redirect_uri=http://<YOUR DOMAIN>&scope=read,watch_lists,publish_messages,publish_watch_lists,follow_users,follow_stocks

#

Which, when I put into a browser, successfully redirects.

#

For some reason it fails to do so in my code

#

I am thinking it might be simpler than I realize

#

Based on what I've seen online, it seems like my approach is correct, but I am missing something.

#

response = requests.get(AuthorizeURL, allow_redirects=True)

#

So I check the url of it, and it's not the redirect url... just the original.

native tide
#

I'm adding a custom action to one of the models on django admin site, and I want to ask for user input for that action. What would be the best way to do that?

versed python
#

using forms

native tide
#

I followed this answer and it works for my custom action, but the default delete action now doesn't work - it opens the confirmation page, and after confirmation it just says that the action wasn't selected
https://stackoverflow.com/a/63644851

fathom cradle
#

How do you guys feel about home tests for work interview? I got a hometest, and it feels like a few days worth of work, and thats before an interview with any engineer one on one

#

Feeling like I should drop the "oportunity" altogether and just cancel with the company.

late lichen
#

I want to make a Whatsapp bot using Python

#

please help

versed python
#

twilio is the easiest to use afaik

gaunt marlin
#

@fathom cradle if you have time and feels like you can do it, we can't know.

#

apply to any jobs basically

fathom cradle
#

Would you be ok with a job interview that just goes, hi, we looked at your CV and want to waste 2 days of your life?

#

I think that is a bad custom in the industry.

#

But maybe im just overeacting.

native tide
#

@fathom cradle I've completed a similar test recently just for the experience. If you have time and think that it will let you learn something new, then complete it. Even if you won't get accepted, let it dangle in your github to show the future employers what you can do

gaunt marlin
#

always good to have pre-made project from your own or any past experience

native tide
#

Yeah, so this test assignment may be good enough for other employers

gaunt marlin
fathom cradle
#

@fathom cradle I've completed a similar test recently just for the experience. If you have time and think that it will let you learn something new, then complete it. Even if you won't get accepted, let it dangle in your github to show the future employers what you can do
@native tide Did you get hired?

gaunt marlin
#

please ask in that for advice

fathom cradle
#

please ask in that for advice
@gaunt marlin thanks, didn't see that channel

bright spindle
#

from django, i got a working Model class that looks like this

#

however, i do have an issue that the loading time is ridiculously long, probably due to super().save() needs to be ran before, which means i need to save, load then the image again

night compass
#

python3.9 doest support pylint

#

what should i do

gaunt marlin
#

you gotta wait for them to support, 3.9 came out like a few weeks ago

#

if you can't then you can downgrade your python version to 3.8

wraith trench
#

Hey, on django admin I have pretty active model which gets new values every few seconds, and I would to make changelist_view autorefresh model values with ajax every 10 seconds instead of reloading page. Maybe someone could point me to right direction, with some guide on this topic, because so far haven't found anything on google.

peak meadow
#

Guys. I have a flask app that's an API and I get requests once a month from a single computer, I don't want to use NGINX. What's the best uWSGI setup for this ?
This is my current uwsgi:

[uwsgi]

chdir = /home/pi/sampleApp
module = sample_app:app

master = true
processes = 1
threads = 2

uid = www-data 
gid = www-data
socket = /tmp/sample_app.sock
socket = 0.0.0.0:3134
protocol = http
chmod-socket = 664
vacuum = true

die-on-term = true

lazy = true
lazy-apps = true

This uwsgi.ini works perfectly on port 3314 but only if I specify protocol = http. I have read on stack that I do need to use http or http-socket but I didn't get exactly as the opinions were different. What you guys think ?

strange ocean
#

how can i retain all the properties of the default progress bar

#

except for the color ?

#

like the progress color

#

?

stable kite
#

@strange ocean like what properties?

strange ocean
#

@stable kite the whole look and feel

tough oxide
#

Can anyone here teach me Django from scratch ??

#

If yes plz dm me

summer wyvern
#

Hi

#

@tough oxide follow this tutorial I am using this one also

tough oxide
#

ok thanks mate

versed python
#

why are you learning django 2.1?

#

@tough oxide find a recent one dude

#

this one is years old

tough oxide
#

ok

#

do you have suggested book or tutorial

#

@versed python

#

or any other resource

versed python
#

not really but corey schafer was good when I learnt django

tough oxide
#

ok thank buddy

void cape
#

Hi, does anyone here use either WebFaction or OpalStack for hosting? I'm about to move from the first to the second and am wondering if anyone has any experiences to share about that.

mortal mango
#

I have a GitHub Pages website and I just created a rest API with Django Rest Framework. Is there a way I can run my rest api with GitHub Pages?
or would I need a webserver

tropic rapids
#

Where can i learn flask for free??

summer wyvern
#

on youtube

tropic rapids
#

Thanks

#

Is the course food

#

Sorry good

#

I just don't wanna waste my time

summer wyvern
#

Im not sure

#

but this guy is ver good

#

but Django is a better option

buoyant shuttle
#

Guys i have a dilemma, to choose either django or flasl

summer wyvern
#

Django

#

well I asked the same question

#

and the others said Django

buoyant shuttle
#

I learnt django months ago, and i'm taking pirple.com classes, and they are teaching flask

summer wyvern
#

oh

#

ok

buoyant shuttle
#

when i go to other platform and go to fullstack dev course

#

they include flask

summer wyvern
#

I have no idea how to do Django yet

#

I just started yesterday

buoyant shuttle
#

ah

tropic rapids
#

Hey my one friend told me flask is good

summer wyvern
#

yeah

buoyant shuttle
#

I just know django, and i dont think i wanna learn flask cause im satified with django

#

but i paid for this course so,

summer wyvern
#

but mine told me Django

buoyant shuttle
#

lol

summer wyvern
#

maybe we should all just learn both

tropic rapids
#

For learning django u should go first with flask

summer wyvern
#

and use the one that we prefer

tropic rapids
#

Than it will easy to learn django

buoyant shuttle
#

@tropic rapids it's not like i googled for courses on flask,

#

its part of the full-stack dev course, thats the backend they chose

tropic rapids
#

Yep

#

First learn front end

buoyant shuttle
#

I just learn flask cause i paid

mortal mango
#

how can I add a domain to my Django Rest Framework? So I can do something like domain.com/api and get the json data instead of local host

tropic rapids
#

I didn't learn django

#

I will start flask today

split wave
#

whats the best program for beginners

#

i was thinking to use Django

tardy furnace
#

Hey, I'm just new to web scraping and been trying to make a script to get fresh requests on some website. But how do I get the new requests? meaning after re-reading the content of the HTML page how do I determine the new requests?

I tried to do the following:
old_containers = soup.findAll("td", {"class": "details-td"}) #this gets called out of the loop (runs only once)
new_containers = soup.findAll("td", {"class": "details-td"})
containers = new_containers - old_containers

But it showed the following error:
TypeError: unsupported operand type(s) for -: 'ResultSet' and 'ResultSet'

What are 'ResultSet' and how do I handle them?

*I mean by 'requests' just new posts

sudden grail
#

Hey, who uses slack every day at work?

hallow jacinth
#

Anyone know or have a tutorial I could use for setting password requirements with flask? I understand how to use the Validators from flask-wtf, but that only lets me set a min/max length. I would like to learn a way to create requirements like 1 upper, lower, special char, and number. I would prefer to not have to write my own validators, but if I have too then that is fine xd

native tide
#

b

outer apex
hallow jacinth
#

I will take a look at it, thank you :D

vapid acorn
#

I am using django and dont really want to use the models with migrating the database bla bla bla, is it recommended to just create an own database handler class to do that stuff?

#

I feel like I have more control If I do it like this with storing password hashes and stuff

#

btw, could you just use a model-inheritated class like normal with __init __ and will a normal instance attribute also be stored in the db automatically?

quick cargo
#

if you're not using the ORM then using DJango is pretty pointless overall

#

at that stage you might aswell use Flask or a micro framework

mortal mango
#

if I make my VPS a webserver, will it effect the other things I'm running on my VPS?

iron beacon
#

hey guys, anybody already found this error when using the viewsets of Django Rest Framework?:
Object of type type is not JSON serializable

versed python
#

this error occurs in normal django

#

not drf

#

are you sure you are importing the serializer from the correct place?

iron beacon
#

yes, I have all my serializers placed in one file

#

also, this is working for 2 endpoint, but in a third I got this error

#

but I'm doing basically the same thing for all 3 views

red pine
#

Question Model```python
class Question(models.Model):

QSTATUS = [ ('Pending', 'Pending'), ('Accepted', 'Accepted'), ('Review', 'Under Review'), ('Rejected', 'Rejected') ]

question = models.CharField(max_length=140)
improved = models.CharField(max_length=140)
description = models.TextField()
date_added = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
status = models.TextField(choices=QSTATUS, default='Pending')
by = models.ForeignKey(User, on_delete=models.CASCADE, max_length=10)

Following is my Questions formpython
class AskQuestionForm(forms.ModelForm):
fields = ['question', 'description']

class Meta:
    model = Question

``` How to i enter the current logged in user to the Question model's by field.? Do i need to change my model's by field ?

#

could someone please suggest what i need to look up ?

autumn pumice
#

There's not events in django right?

#

You ahve to do that in js? or react/frontend stuffs?

red pine
#

if i submit this form its throwing a NOTNULL constraint violation

twilit dagger
#

@red pine pass in request.user

#

In the form

red pine
#

you mean class AskQuestionForm(forms.ModelForm, user): ?

twilit dagger
#

No when you are passing the form with POST

#

This is another way to do it

regal furnace
#

Hi guys! Can you suggest rather good example of portfolio site?
I want to create own portfolio site, but I don’t know what to take as the basics. there are many different versions. Also please suggest which section is required for portfolio site which is not.

wanton ridge
#

This is the error i am getting when i start my server: Error connecting to MariaDB Platform: Can't connect to MySQL server on
'192.0.2.1' (10060). I am working on windows. If i want to connect on vscode to the mariadb with "mysql -u root" it says error too. I did "pip install mariadb", I would appreciate if someone could help me out. and i have a programm which called "XAMPP" where i can start mysql, but even when i start it, i am getting the same error

native tide
#

Django: If I want to use aiohttp or another async api. Where should I put the ClientSession to keep it alive during the whole session? And how to close it?

#

idk if this belongs here, pls lmk:

Hey, so with the requests library You have the post request, Now to send post data with it you have to do {"info": "something"} wich is like the parsed version of the post data, is there any way i can just use the soucre data of a post request?

molten stag
#

for once and all, prons and cons of flask and django and what is better?

quick cargo
#

@native tide generally wouldnt use asyncio with Django unless its specifically in conjuncture with Channels

native tide
#

doesn't it support async views now?

quick cargo
#

if its via channels

topaz widget
#

Hey just FYI, I DON'T recommend using SESSION_COOKIE_SECURE = True in your settings.py file for a Django website.
I just spent over an hour trying to figure out why my website wouldn't authenticate on localhost in Chrome

native tide
topaz widget
#

It's possible it's not a problem when deployed--I haven't encountered any issues with my deployed website--but it still produces login problems with at least Chrome and "Web" (formerly "Epiphany") browsers on localhost.

native tide
#

^ maybe because your production uses https and your development uses http?

topaz widget
#

possibly

#

It's frustrating spending so much time on something like this.

#

I was not trying to get deep into backend stuff today.

#

I just had to create a database model for a frontend project.

native tide
#

It happened to me last week, now I know FeelsOkayMan

topaz widget
#

Now I have to go clean out all the print statements in all my various files I was using for debugging. Arghhh!!!

#

I should probably just create a git branch when doing such debugging so I can roll back with one command.

vivid canopy
#

Hey guys i have a little problem i m learning with flask to make a site but propably i don't have set right enviroment , maybe u asking why i think its enviroment? For example lets say i have port=300 and in previous doc i had there a image but now i changed that and write something else like deleted the image but when i referesh the site image is still there so i had stop trough cmd localhost changed port to lets say to 500 and start localhost again trough cmd and there was no image anymore. In previous project i didn't have this problem , maybe some shortcut missing there or something else idk. Please if u know what to do or u didn't understand what i writed please let me know.

toxic flame
#

Hello, so I have 2 models, Product and Stock, the stock which each are foreignkey to a product, how can I render out the count of the stock assigned to the product on a template?

#

Please ping me.

trim star
#

Hello

#

How do I update JQuery in Django

#

and how do i see the current version of jQuery that is currently used by Django

acoustic oyster
#

update jquery?

you can use the cdn or download the newest packages and replace them in static

trim star
#

Is there a good tutorial on that?

acoustic oyster
#

I am not sure that django uses any jquery, I am not 100% sure though.

But if you want to use jquery in your templates, you will need to install it/add it to your project itself. It is completely separate from django

trim star
#

(im not a web developer, just patching things)

acoustic oyster
#

Is there a good tutorial on that?
@trim star you would not be adding jquery to django necessarily. You would just be adding it to your html like normal.

#

oh, if you are patching someone else's code: someone should have added jquery to the static folders, or the cdn links in the templates themselves. If the front end is using templates

#

if using local files for jquery, it should be in the app/static folder.

or the cdn may be imported in the template or in a base template

trim star
#

yeah i see in a bash script a command for

download https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js

acoustic oyster
#

yeah, is that in docker?

you could replace those for newer versions (that is the cdn link)

but you will need to do a lot of work fixing deprecated and incompatible code xD

trim star
#

mannn

#

Ok well thanks haha

#

yes its in docker

acoustic oyster
#

actually, that is a pretty new version. It would not be worth upgrading imo and it should not cause many conflicts to do so.

#

(current is 3.5.1)

#

cool, someone was kind to you though, that should be the only place you need to update the install

trim star
#

there is a vulnerability in versions less than 3.5

acoustic oyster
#

oh yeah, makes sense

#

change it and see what happens haha should be fine actually

trim star
#

Haha hope its not too bad..

solemn thistle
acoustic oyster
#

no question? just dropping a link here? xD@solemn thistle

#

do you need help or is this just an ad for your project?

primal grove
#

!warn 704811801166086165 Every message you've sent so far since joining the server have been self-promotion. Going forward, please use this community as intended.

lavish prismBOT
#

:incoming_envelope: :ok_hand: applied warning to @solemn thistle.

trim star
#

@acoustic oyster So luckly the project has very good tests and a build system....Seems that all of the tests have passed after upgrading jquery, bootstrap, and quill

acoustic oyster
#

niiiice, you are being spoiled by whoever made that LOL.

#

Way too common for people to get lazy LOL

trim star
#

yeah 🤣

vestal hound
#

Now I have to go clean out all the print statements in all my various files I was using for debugging. Arghhh!!!
@topaz widget why use print when you can use logger

toxic flame
topaz widget
#

Familiarity I guess.

toxic flame
#

how and why doesn't the flexbox appear on the empty space?

#
``` is the current css code
#

ofc, inside a flex container with flex-wrap: wrap and display: flex

topaz widget
#

Either way, I need to remove the chaff after I'm done debugging.

vestal hound
#

Either way, I need to remove the chaff after I'm done debugging.
@topaz widget the benefit of logger is that you can have debug level logging

topaz widget
#

Okay, I'll have to use that in the future in such instances then.

toxic flame
#

ok i fixed

vestal hound
#

Okay, I'll have to use that in the future in such instances then.
@topaz widget also, it allows you to defer string formatting

#

which might be nice...or it might not. shrug

topaz widget
#

Whatever keeps me from cluttering up my code just to see what it's doing.

#

That little side quest really took the wind out of my sails today; however, I still managed to get some stuff accomplished.

#

Man, doing tricky stuff in CSS can be quite a bitch, though.

#

I have an image gallery with panels that flip over with descriptions on the back. Getting the panels to flip and show the backs properly with perspective as they flip over takes some serious finesse!

fallow silo
#

New to web development here. I'm writing a handbook for work. I would very much like to have every section be it's own html document, and then seamlessly plop that into the main document. Mostly because that would be easier to maintain and organize. I'm trying out <iframe> but it has scroll bars. I really just want to plop the html page into a <div>. Is that a thing that can be done?

versed python
#

@fallow silo There might be better ways to do this, but I am pretty sure it can be done with a templating language like jinja, which is python based. If you are more of a js guy, then I recommend nuxt-content (you'd need to learn vuejs though).

#

I recommend the former because it'd be much easier

fallow silo
#

Yeah, I want to go with as easy as possible. 😄

versed python
#

jinja it is then

untold sluice
#

Hi There! does anyone help me out how to open modal pop-up in django admin

gaunt marlin
#

@untold sluice you need to override specific admin template that you want in django admin, and write modal css and javascript in javascript block

untold sluice
#

Okay do you have any reference ?

untold sluice
#

@gaunt marlin Thanks for your help !

gaunt marlin
#

basically copy paste and customize whatever you want

strange ocean
#

guys are heroku servers considered "fast"??
or is something like AWS faster?
i am getting 0.8 second response times for querying a read of a json file
with 90mb/s internet
json file is 3 kb lol

elder tiger
#

how does countdown timer works

vestal hound
#

guys are heroku servers considered "fast"??
or is something like AWS faster?
i am getting 0.8 second response times for querying a read of a json file
with 90mb/s internet
json file is 3 kb lol
@strange ocean I think most of that is latency vs bandwidth

gaunt marlin
#

@vestal hound based on what tier you using, free tier of course not gonna be fast at all

#

@elder tiger you set an expired time(usually timestamp), and use javascript to do countdown expired_time - now()

vestal hound
#

@vestal hound based on what tier you using, free tier of course not gonna be fast at all
@gaunt marlin of course that is true, but I don't see how that's relevant to what I said

gaunt marlin
#

server spec related to how many RPS it can do, and it's bandwidth speed

elder tiger
#

for e.g

#

static sites can do that or not

vestal hound
#

server spec related to how many RPS it can do, and it's bandwidth speed
@gaunt marlin yes, I know that

#

but I wasn't the one asking the question.

#

and what I was saying was that most of that 0.8s is latency

elder tiger
#

ohh got it thx

gaunt marlin
#

is your expired_time a static variable or from server @elder tiger ? if it's static then it's doable with static site

elder tiger
#

yeah it is static thx

vestal hound
#

i.e. how much data can be moved in unit time

gaunt marlin
#

i think it's based on the transfer bandwith

vestal hound
#

3 KB is very small

elder tiger
#

how i can take variables from url in django

gaunt marlin
#

you mean url parameters?

elder tiger
#

yes

#

like localhost/message?content=this&&?author=that

vestal hound
#

you can access them at request.query_params

elder tiger
#

ohh

vestal hound
#

each View takes a request object

gaunt marlin
#

and you can get in view by request.GET.get('parameter_variable_in_url_for_example')

vestal hound
#

you can access them at request.query_params
@vestal hound oh wait this is for DRF

#

vanilla Django uses GET

strange ocean
#

@vestal hound so there is no way to get some kinda faster server??

sage bluff
#

does anyone know how to get images using flask restful ???

acoustic oyster
#

does anyone know how to get images using flask restful ???
@sage bluff you would probably need to serve the files somewhere (as static files), keep a reference to their path in the db, then serve the url in the api, then get the image from that url.

I do django though.

vestal hound
#

@vestal hound so there is no way to get some kinda faster server??
@strange ocean not really? do you understand what my point is?

strange ocean
#

@vestal hound yes so is the latency cuz of my internet or the server response times?

vestal hound
#

you would need to profile that

#

@vestal hound yes so is the latency cuz of my internet or the server response times?
@strange ocean not physically being where you are, I wouldn't be able to tell

limber laurel
#

Not Found: /media/videos/2020-05-14_18-13-42_sQMWhJL.mp4

#

I keep getting an error like this

#

When I go to check that route everything seems to be there

#

The same happens if I use the MEDIA_ROUTE instead of the url

paper radish
#

has anyone run into an issue with flask_wtf not rendering the <form> tags?

limber laurel
#

I have a feeling that it wpuld have problems if you had csrf token enabled, but why would you run the form without the form tag?

#

@paper radish

paper radish
#

this is using quickforms, It causes submissions of forms to be 'GET'

#

csrf tokens are enabled

#

just disabled CSRF and it is still forcing post requests

native tide
#

Cors or csrf

paper radish
#

I was helping a student with some tutorial work and could not find why it wasnt appearing...Turns out he had a nested form in his header that was missing a closing tag..

#

thanks though

gaunt marlin
#

why....

versed python
#

he right tho

rustic pebble
#

Any ideas on why I could be getting this error?

Traceback (most recent call last):
  File "C:/Users/sn3ak/PycharmProjects/dominusio-website/app.py", line 21, in <module>
    app.register_blueprint(payment_b)
  File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\app.py", line 98, in wrapper_func
    return f(self, *args, **kwargs)
  File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\app.py", line 1168, in register_blueprint
    blueprint.register(self, options, first_registration)
  File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\blueprints.py", line 256, in register
    deferred(state)
  File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\blueprints.py", line 294, in <lambda>
    self.record(lambda s: s.add_url_rule(rule, endpoint, view_func, **options))
  File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\blueprints.py", line 86, in add_url_rule
    **options
  File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\app.py", line 98, in wrapper_func
    return f(self, *args, **kwargs)
  File "C:\Users\sn3ak\PycharmProjects\dominusio-website\venv\venv\lib\site-packages\flask\app.py", line 1275, in add_url_rule
    rule = self.url_rule_class(rule, methods=methods, **options)
TypeError: __init__() got an unexpected keyword argument 'method'
#

Solved it, I had to swap method to methods when creating a route

sick elm
#

Hello guys, I'm learning Django and I would like to know which IDE or code editor is best for Django

blissful slate
#

pycharm is very good.

sick elm
#

Yes, i currently use it, but when i need to edit html, css or javascript the "PyCharm Community Edition" does not support these types of documents, except html files

devout coral
#

Yeah I suggest investing in the pro version if you are serious about developing with Django. It is so nice to use

#

Question, I am trying to find a good way to pass my request object to my clean function in a form. What is the best way to do this?

blissful slate
#

many people like visual studio code. also vim is also very good.

devout coral
#

Actually not my request object. I am just trying to pass an object. I can access request by doing self.request in a form

quick cargo
#

Pycharm does support them but youll need 3rd party plugins

mortal mango
devout coral
#

@quick cargo If you use the django framework there is no need for the third party plug ins

#

It will recognize the DTL as well

#

ImportError: cannot import name 'Employee' from partially initialized module 'employees.models' (most likely due to a circular import)
Could someone help me out with the above error.

peak meadow
#

It's possible that after using python -m pip install --upgrade, my uwsg won't run as it did before and it doesn't find any module

zealous tusk
#

Please help me with django. I am a beginner #help-kiwi

peak meadow
#

and maybe the virtual environement is changed or something ?

stable kite
#

@mortal mango Have you installed Django?

mortal mango
#

yeah

stable kite
#

@mortal mango are you using virtual environment?

#

@devout coral can you share your code?

devout coral
#

Actually I already got it thank you. I was being dumb. Had a model in a app that it was not supposed to be which caused me to have to do the loop import thing. I just moved it to the app it was supposed to be in and it is good.'

toxic flame
#

does anyone know how to select a model inside a class in django?

stable kite
#

@toxic flame wdym?

toxic flame
#

i have a choice field inside product

#

i want it to display on the template

devout coral
#

You want the user to be able to select a product from a drop down and the dropdown would be populated with all the objects for a specific model?

toxic flame
#

yes

#

no

devout coral
#

Lol what

toxic flame
#

i have a custom product create page

#

where the only field missing is the dropdown of all the choices the user want the product to be

devout coral
#

The choices the user want the product to be? I am not quite understanding what you are trying to do. maybe some more context?

stable kite
#

@devout coral @toxic flame wants that the option in a dropdown should come from different model as far as i think so

mortal mango
#

@mortal mango are you using virtual environment?
@stable kite yes

stable kite
#

@mortal mango have you activate the virtualenv?

mortal mango
#

yeah

stable kite
#

can you share a pic of your console

mortal mango
stable kite
#

@mortal mango which python version are you using?

mortal mango
#

python 3

devout coral
#

@toxic flame I would suggest you query whatever model you want the info from in your forms and fill a choices variable. Take a look at below

class EditEmployeeInfo(forms.Form):
    COMPANY_CHOICES = []

    try:
        companies = Company.objects.all()

        for company in companies:
            company_name = (company.display_name, company.display_name)
            COMPANY_CHOICES.append(company_name)
    except:
        pass

    company = forms.CharField(label='Company', widget=forms.Select(choices=COMPANY_CHOICES), required=True)
mortal mango
#

the error's coming from execute_from_command_line(sys.argv)

stable kite
#

which django version are you using?

mortal mango
#

django: 1.11.29
djangorestframework: 3.9.4

stable kite
#

@mortal mango upgrade your django version latest realse is 3.1

mortal mango
#

how do I do that?

stable kite
#

type on console pip install Django==3.1.2

devout coral
#

How did you get v1 of Django installeD?

mortal mango
#

@stable kite requirement already satisfied

stable kite
#

then how do you tell me that django version is 1.11.29?

mortal mango
#

because that's what it says

#

in pip freeze

devout coral
#

do pip show dajngo

#

in your console where the venv is activated

stable kite
#

pip install Django==3.1.2try this

mortal mango
#

Oh I have 1.11.29 and 3.1.2

#

how do I uninstall 1.11.29

devout coral
#

Delete the old one

#

pip uninstall

mortal mango
#

pip uninstall django==1.11.29

#

?

devout coral
#

Yes

mortal mango
#

I still get an error

#

same one

devout coral
#

Did it uninstall?

#

do pip show django again

mortal mango
#

it's returning and it's showing nothing

wanton ridge
#

anyone know how to connect vscode terminal to database mariadb in windows

devout coral
#

@mortal mango You ran the command from the terminal window that the venv is activated correct?

mortal mango
#

yes

devout coral
#

Sorry, I do not use VS Code

#

@mortal mango So now install the right django version now

#

pip install django==3.1.2

mortal mango
#

I'm trying but it says no matching distribution

devout coral
#

just do pip install django

#

Then do the show command again to see what version it installs

mortal mango
#

requirement already satisfied

devout coral
#

do the pip show

mortal mango
#

and pip show django isn't working

#

it doesn't do anything

stable kite
#

do pip freeze

mortal mango
#

it's not showing it

#

and it says requirement already satisfied when I try to install it

blissful slate
#

which python

devout coral
#

Ok, go to a terminal outside your venv and do pip show django

wanton ridge
#

i am getting this error when i start my local server: "Error connecting to MariaDB Platform: Can't connect to MySQL server on '192.0.2.1' (10060) "

mortal mango
#

how do I disable the venv

devout coral
#

Just open a new cmd window

mortal mango
#

ok

#

it's not showing

devout coral
#

@mortal mango Send a screenshot of the terminal window please

blissful slate
#

@wanton ridge do you hve a mysql server running on 192.0.2.1?

wanton ridge
#

yep i start XAMPP and run it