#web-development

2 messages Β· Page 66 of 1

rustic pebble
#

I am planning to rewrite sqlalchemy on async at some point

#

But this is a project for another time

quick cargo
#

i was working on a async version of Django's orm for a bit

rustic pebble
#

I dont like django at all

#

feels really heavy and time consuming

quick cargo
#

I like the orm i dont like how annoying it is to hack

rustic pebble
#

exactly

#

I have some premade templates for most of my services

#

I used to write everything from scratch a while back

#

which resulted in many hours spent on reinventing the wheel

quick cargo
#

Im trying out aiohttp stuff more now lol

rustic pebble
#

I have kind of built an orm for mysql

#

for async

#

I might release it as a module

native tide
#

Hey friends. Quick question, I just installed Django via cmd after setting up they venv. However my question is:

Do I have to create a new venv for every new project?
Do I have to activate/deactivate the venv for lets say my Blog project everytime I restart the pc?

quick cargo
#

that depends

#

if you're running via cmd yes

#

but its pretty easy to make a simple batch strip to activate it

#

and its best practice to use a diffrent venv for diffrent projects

#

to help organise dependencies etc...

#

but no you dont have to

native tide
#

Alright thank you

coral marten
cold anchor
dense slate
#

Is there a way to add a default value to a choicefield in a form in Django? I have a dict of countries with country codes, but I want to include an option that says "all countries" which is actually a null value (and therefore doesn't narrow anything down).

sudden timber
#

Hi

#

I'm trying to do the shopping cart section for a pizza restaurant

#

But I can't figure out how to add the products to the shopping cart

#

Does anyone know how should I get started

#

Btw I'm using django

bronze pond
#

Anyone familiar with the Eel library?

rapid epoch
#

hello guys can anyone help me with selenium?

#

i really need a guy who can help me ?

#

i want to scroll down in my insta followers and following list using selenium

fallow warren
#

can someone help me with css?

#

i want to format an img and paragraph so they are side by side

#

but thye are in different divs

dusk spade
#

use display: flex;

fallow warren
#

@dusk spade wdym

#
<header>
                <h1 class='title'><img src='mapleelectronics.ico' id='title-image' alt='Maple Electronics Logo'>Maple Electronics LLC</h1>
                <div class="img-container"><img src='parts.png' alt='Parts'></div>
            </header>


            <main>
                <div class='content'>
                    <p>Maple Electronics Established on January, 2006 and is located in the heart of Silicon Valley in the state of California.
                Our highly trained and knowledgeable staff with more than 20 years of experience in electronic component sales are able
                to supply the industry with hard-to-find components, surpluses, and generic products. We have access to an extensive,
                high-quality inventory, and a worldwide database of obsolete, allocated, and hard-to-find electronic parts. We offer fast,
                low cost, and high quality services.</p>
                </div>
            </main>
dusk spade
#

if you want two div's next to each other use the css display: flex in the parent

fallow warren
#

i wanna put parts.png and the paragraph side by side

dusk spade
#

so move the imge-container inside of content

#

then in your content class set display: flex

fallow warren
#

ok

#

that did smth weird

#

@dusk spade

dusk spade
#

show me

fallow warren
#

sry abt the cmd

#

@dusk spade heres the pg norm

#

i want the pic and text side by side

dusk spade
fallow warren
#

how do i send it to u

#

?

#

@dusk spade

dusk spade
#

create a post on that site --^

fallow warren
#

im confused

#

how do i post

#

i saved

#

@dusk spade

dusk spade
#

share the link

fallow warren
#

@dusk spade now what?

dusk spade
#

it didn't saave

fallow warren
#

wdym

dusk spade
#

Β―_(ツ)_/Β―

fallow warren
#

what abt now?

#

@dusk spade did it now?

glossy crown
#

hey, im a beginner with python and a complete noob with Django. I was trying to run a project from github, I tried making a virtualenv but Im not exactly sure how this works. Would someone be able to help (or let me know if this is a bad question, oops!)

pliant falcon
#

did you installed virtualenv?

#

@glossy crown

#

first you need to install it same as any package in python.. ```
pip install virtualenv

#

then path to the folder of your project by cd path

#

then create vritualenv by virtualenv virtualenv_name

#

in your project folder a folder created with the virtualenv name that you just created..

#

open the folder then scripts then copy path

#

past it on command line and add \activate at the end

#

virtualenv_name\Scripts\activate

rapid epoch
#

can someone help me with selenium>

ripe ocean
#

is there a good tool that lets me pause a http request before following redirects?

quick cargo
quick cargo
twilit zenith
#

what framework are you using?

rustic pebble
#

aiohttp @twilit zenith

native tide
#

hello, can someone help me with flask, i try to print the username and password form data

quick cargo
#

what about it

native tide
#

can i private msg you?

rustic pebble
#

@native tide whats ur problem?

native tide
#

check dm

bleak bobcat
#

Why not do it here ?

rustic pebble
#

@native tide do it here

native tide
#

ok sure

#
from flask import Flask, render_template, request

app = Flask(__name__)


@app.route('/')
def hello():
    username = request.form["username"]
    password = request.form["password"]
    return render_template("index.html")

if __name__ == '__main__':
    app.run("127.0.0.1", port=5000, debug=True, use_reloader=False)```
#
<!doctype html>
<html>
<head>
  <title>Some title</title>
</head>
<body>
  <h2>Form</h2>
<div class="login-form">
    <form action="/response" method="post">
        <div class="form-group">
            <input name="username" type="text" class="form-control" placeholder="Username" required="required">
        </div>
        <div class="form-group">
            <input name="password" type="password" class="form-control" placeholder="Password" required="required">
        </div>
        <div class="form-group">
            <button name="submit" type="submit" class="btn btn-primary btn-block">Log in</button>
        </div>
</div>
  </div>
</body>
</html>```
#

i need to print the login form data

#

any idea how to do that?

rustic pebble
#

In your html code you have a <form> element which sends the form to /response when its submitted

bleak bobcat
#

action="/response" @app.route('/')

rustic pebble
#

you need to create a coresponding route

#

basically this:

#
@app.route('/response')
def form_data():
    username = request.form["username"]
    password = request.form["password"]
    print(username, password)
native tide
#

400 bad request

#

also, you cant print like that on flask

#

its return

bleak bobcat
#

You can still print data to the console before returning a template render

native tide
#
KeyError: 'username'
#

need to print it on the website

bleak bobcat
#

What's the result of printing request.form ?

native tide
#

your username and password

#

but i couldnt load the websit

bleak bobcat
#

Well, no, otherwise you wouldn't get a keyerror

native tide
#

it went to error

#

yeah

#

rip

#

any idea how to fix?

bleak bobcat
#

What's the result of printing request.form ?

native tide
#

none?

#

no idea

#

you could put the result inside the html

bleak bobcat
#

Just print it to the console for now

native tide
#

gives me error

bleak bobcat
#

Which is ?

native tide
#
KeyError: 'username'
bleak bobcat
#

Print before trying to access username and password

#

If you print after an error then yea you'll never get your print

native tide
#

you just want me to print text?

#

sure

bleak bobcat
#

I want you to print request.form before doing anything else in your hello view

native tide
#

oh

#
from flask import Flask, render_template, request

app = Flask(__name__)


@app.route('/')
def hello():
    username = request.form["username"]
    password = request.form["password"]
    print(username)
    print(password)
    return render_template("index.html")

if __name__ == '__main__':
    app.run("127.0.0.1", port=5000, debug=True, use_reloader=False)```
#

like this?

#

still gives me an error though

bleak bobcat
#

....

#
from flask import Flask, render_template, request

app = Flask(__name__)


@app.route('/')
def hello():
    print(request.form)
    username = request.form["username"]
    password = request.form["password"]
    return render_template("index.html")

if __name__ == '__main__':
    app.run("127.0.0.1", port=5000, debug=True, use_reloader=False)
native tide
#

oh

bleak bobcat
#

So it's empty. Did you change the action on your form or is it still pointing to /response ?

native tide
#

i only visited the website, which shows an error but in console it gave that output, together with errors

#

couldnt access the login form no

bleak bobcat
#

That's not my question

native tide
#

<form action="/response" method="post">

#

this

#

?

#

still pointing to response yeah

bleak bobcat
native tide
#

ah

#

ok i changed it to /

weary bough
#

Hi, can someone help me with django here?

rigid laurel
#

Possibly. Best to just ask the question

weary bough
#

Can someone help me correct that code?

dense slate
#

@weary bough Looks like it has an accepted answer.

burnt night
#

Where can i host a flask app?

quick cargo
#

anywhere?

ashen vigil
#

Hello folks, I am working on an API using Flask and I am stuck at a problem...
the API uses MVC pattern, the routes are defined in the views and call controller methods to get the data necessary. The problem is that the controller methods return either the queried object from database or None to indicate failure, but the view has no idea of what went wrong so it can't distinguish 404 not found from other errors.

#

What/how should I improve to be able to distinguish different types of problems the controller can encounter to return a better HTTP code from the view?

#

I was thinking about returning a tuple containing the object/None and some data but don't know what data would be suitable... returning just the error messages gives the view no hint of what HTTP code it shall return, and returning the HTTP code from controller and just passing it in the view doesn't seem like the right design choice πŸ€”

#

Any input would be appreciated, if you need more context let me know πŸ™‚

midnight kernel
#

@ashen vigil have you tried the @app.errorhandler decorator?

#

I use a bunch of custom exception classes, and with the @app.errorhandler(MyCustomException) decorator, I setup callback functions which return an error message (along with an appropriate status code) whenever MyCustomException is raised.

#

that way, my controller classes don't have to handle anything related to status codes, that job is done with the errorhandler decorator (and the callback functions associated with them)

wise plank
#

With Django, I’m trying to use the last bit of the url as an input (e.g. base/Jeff but I’m not sure how to do it? I’ve managed to make a regex that allows any thing after β€œbase” but not able to find the ending, it’s still localhost and most SO links don’t work for some reason

native tide
#

anyone working with flask and graphql ?

rigid laurel
#

I think that's what you're looking for

#

It's not quite the relevant part of the docs. But it is an example of what you're looking for

vestal hound
#

does anyone know how to get the other side of a M2M relationship including the through model?

#

e.g.:

class LeftSide(models.Model):
    left_value = models.IntegerField()
    rights = ManyToManyField(LeftSide, through=Through)

class RightSide(models.Model):
    right_value = models.IntegerField()

class Through(models.Model):
    left = models.ForeignKey(LeftSide, on_delete=models.CASCADE)  
    right = models.ForeignKey(LeftSide, on_delete=models.CASCADE)
    through_value = models.IntegerField() 

if I were to access the rights RightSide set of a LeftSide instance, each instance would have the right_value model field, but not the through_value field from the Through model. how do I get both of them together?

worn crane
#

Hey guys, I had a quick question about something I'm trying to do in Django...

    {% for article in articles %}
    <h5 class="articleTitleSection"><a href="/individual_blog/?page=1">{{ article.title }}</a><br> by: {{article.author}}</h5>
    {% endfor %}
</ul>```
So basically I have an Article model which contains the title, author, and content. Right now I can view the first article object at `/individual_blog/?page=1`, the 2nd article object at `/individual_blog/?page=2`, and so on etc.

My question is - What do I change in this href attribute (also seen in the first snippet of code) `<a href="/individual_blog/?page=1">` so it doesn't just always go to the 1st page. Instead, if the user were to click on, say, the 2nd link, it brings them to the second page, not just the 1st.
fallow warren
#

can someone help me

#

i want to put a picture and paragraph that are in 2 different divs

#

side by side

#

how do i do that

worn crane
#

@fallow warren just but them in the same row

#

using bootstrap

fallow warren
#

html and css

#

im not using bootstrap

worn crane
#

use it

#

install the cdn

#

thats the best way to do what you're trying to do as far as i know

fallow warren
#

idk that much python tho

worn crane
#

what does this have to do with python?

fallow warren
#

i mean sry

#

lmao i

#

was think django

worn crane
#

??

fallow warren
#

lol ok will do sir

#

thx

worn crane
#

so wrap both images in a div with the class row

#

and in each div containing the image

#

assign the div a class of col-lg-6

#

then it should work

native tide
#

hey

#

do i need a VPS server to get flask working on a public website (not local)

#

also can it be done on a raspberry pi and connect it with domainname?

fast pelican
#

@worn crane you can use page={{ forloop.counter }}

worn crane
#

yeah thats what i ended up doing

#

it worked πŸ˜„

rapid epoch
#

anyone who knows selenium

unique hill
#

how to make a paragraph element responsive (meaning, if i enter 5000 words than it should increase in size to accomodate this may words)

ashen vigil
#

@midnight kernel I have gone through many MVC API projects using flask on GitHub and came to this conclusion too. Majority of them doesn't even use controller with views, or uses views for static .html files. Would you mind sharing your project for reference if it is public?
Also thanks for the reply.

silver plank
#

are there any good python frameworks available for making webinterfaces for python scripts?
i suppose the builtin http.server module is good enough for serving, it's more the content generation i'm interested in.
what are my options for a webapp that is communicating with a script on the server in real time?

rapid epoch
#

self.driver.execute_script('''
var fDialog = document.querySelector('div[role="dialog"] .isgrP');
fDialog.scrollTop = fDialog.scrollHeight
''')
what is this i encountered this while learning selenium

#

noone here replies

silver plank
#

dude, your message didn't even get a second timestamp

#

be patient

bleak bobcat
#

It executes javascript @rapid epoch

rapid epoch
#

@bleak bobcat can you explain what is in there

bleak bobcat
#

Gets an element div with a class isgrP and an attribute role (value dialog) and scroll the page to it ? Maybe

#

@silver plank Flask would probably be the best in your case

faint urchin
#

Hello,
I'm trying to use beautiful soup to do this:

I want to take a large div out of a website and then for every p,h1,h2,h3 element inside the div I want to extract the .string from that element, any idea how I go about that?

This is what I have so far:

def get_full_story(req_content):
    identifier = "story-body"
    soup = BeautifulSoup(req_content,features="lxml")

    found = soup.find("div",identifier)

    for elem in found:```
snow sierra
#

which is the best and easy way to deploy Django app to VPS ???

rustic pebble
#

Use elastic beanstalk @snow sierra

distant trout
#

people who make websites here, do you guys use templates or do u make ur own stuff with html/css?

#

such as navbars and common things in a website

#

navbar/footer

#

or do u make ur own stuff and save it and reuse it?

rustic pebble
#

Depends

#

Mostly use a framework and heavily customize everything

#

I use React for frontend along with material UI @distant trout

distant trout
#

ohh i still havevnt got to that

#

is react relatively easy to learn?

#

i kinda know basics of js, idk if i should learn react yet

rustic pebble
#

No

distant trout
#

oh yikes

rustic pebble
#

React is a hard library

#

You need to make sure you own javascript

#

especially classes and objects

distant trout
#

hmm

#

yeah i got a long way to go Xd

#

is there an easy alternative?

#

or should i stick to css

#

using flexbox/css grids

#

and frameworks like bootstrap

rustic pebble
#

Just learn 2-3 styling frameworks

#

and then start diving into heavy javascript

distant trout
#

styling frameworks?

#

could u name some, not familiar with that term

#

like bootstrap and tailwind?

snow sierra
#

Use elastic beanstalk @snow sierra
@rustic pebble thanks ,

pulsar ivy
#

Where can i find list of modules that i can use in flask like fpaks login and flask socketio

#

???

snow sierra
#

but it is not easy.. i am doing any kind server jobs, but i need for students ..

past cipher
#

I am creating a website that has mini services created using Flask. So far I have URL Shortner, MP4 Video to MP3 Audio, To Do List.

Anyone have any other ideas as to what I could add?

pulsar ivy
#

Crud app?

past cipher
#

yeah

pulsar ivy
#

Or something with scraping

#

Or web streaming service like netflix

#

It would be interesting

#

I saw somewhere post abt it like you need to find a way to protect videos from downloading from your site

#

How to add likes

#

And similar things

#

Pagination

random rose
#

Hey guys, I'm trying to learn Django and am having this weird issue where python manage.py startapp <myAppName> seems to execute twice. Here's what I've done:

  1. Created a virtual environment using python -m venv myVenv
  2. Began using this venv by using source myVenv/bin/acivate
  3. Installed django using pip install django
  4. Created a Django project using django-admin startproject myProjectName
  5. Attempted to create an app using python manage.py startapp <myAppName>

I believe step 5 is executing twice because this is the result inside <myProjectName>. I also double checked that Django is only installed once using pip list

#

Also, which python confirms I am using the Python from my virtual environment

quick cargo
#

why do you have two of every file?

#

oh yes

#

i see

random rose
#

yeah thats my question haha

quick cargo
#

you might need to delete it all and do it again

random rose
#

i tried

quick cargo
#

ive never had that issue before xD

#

it still doing it?

random rose
#

i also tried quitting everything and resourcing my venv

#

yes

molten quarry
#

That is funky.

Not exactly a solution, but I would check out dockers. Started using them myself recently. Amazing. Makes life so much easier. Small curve, but totally worth it.

random rose
#

If it's relevant, I'm using Django 3.0.7 on MacOS 10.15.5

#

ill look into dockers

#

oh docker is a venv thing

#

i dont think its an issue with my venv becuase creating the project itself yielded no issues

#

jk its def a venv thign

#

django-admin yields two of every command available

molten quarry
#

You wouldn't have the venv open twice or something right?

random rose
#

I don't believe so

#

when i deactivate once it returns to my default python environment

#

hmmm strange

#

i called pip uninstall django

#

and it worked

#

and django is no longer working

#

but it still appears in pip list

#

i think im going to generate a new venv

molten quarry
#

Try using pipenv

#

pip install pipenv

#

pipenv install django

#

Once it's done, activate the environment using "pipenv shell"

random rose
#

creating a new venv did the trick

#

super weird

#

django was double installed or something

#

ty for your help though ❀️

molten quarry
#

πŸ•Ί

#

Some tips that helped me out a lot during the Django basics: When following your tutorial/book, use VERY descriptive model names/view names. "model_MODELNAME*, "view_VIEWNAME".

Hardest part of Django (or any framework) at first is learning to separate what's python code and what's Django framework.

#

Everything is gonna feel mixed and it's hard to tell where things are coming from

random rose
#

gotcha good to know ty

#

one quick q as well: I'm following corey schafer's 2.1 tutorial and read there arent a ton of breaking changes in 3.0. Is this true? Or should I just look for a 3.0 tutorial

#

I just like Corey Schafer's teaching style : P

molten quarry
#

The core Django foundations are solid. They haven't changed.

random rose
#

perfect ty

cold rampart
#

How do I find the model class from a DoesNotExist exception instance?

native tide
#

hey guys

#

i got problems deploying my flask app

#
[Tue Jun 23 16:22:58.386914 2020] [wsgi:error] [pid 3033:tid 2970608672] [client 192.168.1.18:48168]   File "/var/www/webApp/webapp.wsgi", line 7, in <module>
[Tue Jun 23 16:22:58.387042 2020] [wsgi:error] [pid 3033:tid 2970608672] [client 192.168.1.18:48168]     from webApp import app as application
[Tue Jun 23 16:22:58.387132 2020] [wsgi:error] [pid 3033:tid 2970608672] [client 192.168.1.18:48168] ImportError: cannot import name app
[Tue Jun 23 16:22:58.537612 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] mod_wsgi (pid=3033): Failed to exec Python script file '/var/www/webApp/webapp.wsgi'.
[Tue Jun 23 16:22:58.537750 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] mod_wsgi (pid=3033): Exception occurred processing WSGI script '/var/www/webApp/webapp.wsgi'.
[Tue Jun 23 16:22:58.537837 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] Traceback (most recent call last):
[Tue Jun 23 16:22:58.537927 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170]   File "/var/www/webApp/webapp.wsgi", line 7, in <module>
[Tue Jun 23 16:22:58.538050 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170]     from webApp import app as application
[Tue Jun 23 16:22:58.538140 2020] [wsgi:error] [pid 3033:tid 2945430560] [client 192.168.1.18:48170] ImportError: cannot import name app
#

this is the error i get

rustic pebble
#

@native tide thats aws?

native tide
#

raspberry pi, i got another error now, i almost fixed it i think

#

mod-wsgi or apache runs my python3 script as python2

#

and i get invalid syntax error

#
[Tue Jun 23 17:01:07.116207 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] mod_wsgi (pid=8519): Failed to exec Python script file '/var/www/webApp/webapp.wsgi'.
[Tue Jun 23 17:01:07.116317 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] mod_wsgi (pid=8519): Exception occurred processing WSGI script '/var/www/webApp/webapp.wsgi'.
[Tue Jun 23 17:01:07.116381 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] Traceback (most recent call last):
[Tue Jun 23 17:01:07.116443 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064]   File "/var/www/webApp/webapp.wsgi", line 7, in <module>
[Tue Jun 23 17:01:07.116608 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064]     from webApp import app as application
[Tue Jun 23 17:01:07.116748 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064]   File "/var/www/webApp/webApp/__init__.py", line 22
[Tue Jun 23 17:01:07.116777 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064]     username.send_keys(f"{username1}")
[Tue Jun 23 17:01:07.116802 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064]                                     ^
[Tue Jun 23 17:01:07.116825 2020] [wsgi:error] [pid 8519:tid 3048207392] [client 192.168.1.18:49064] SyntaxError: invalid syntax
native tide
#

got it working

cold rampart
#

Solved my problem:

class Model(models.Model):
    class Meta:
        abstract = True

    def __init_subclass__(cls):
        if not cls._meta.abstract:
            cls.DoesNotExist.model = cls
            cls.MultipleObjectsReturned.model = cls
fickle fox
#

huys how to prevent user from downloading images and videos on site in flask??

unkempt snow
#

Hi guys, is there a tool where u guys use in order to build web design? For example like there is Elementor for wordpress, so looking for something that is standalone that can generate code (lets say for bootstrap or anything u think)

rigid mist
#

Dont know if this goes into this category, but how do i get rid of everything except the 21 in this line? : <span class="temperature temperature--warm" role="text">21<span aria-label="grader celsius" class="temperature__degree" title="grader celsius">Β°</span></span>

molten quarry
#

@rigid mist Sounds like a parsing job. If you're making a python script, you can use bs4 (BeautifulSoup 4)

rigid mist
#

I am, but i dont know how to "aim in" on the 21, it being text, but not a por h1, h2, h3 or h4.

rigid laurel
#

huys how to prevent user from downloading images and videos on site in flask??
@fickle fox
Impossible

#

By viewing it in the browser, they downloaded it

fickle fox
#

oh i heard netflix protected it from downloading

#

so i was wondering how its possible

unkempt snow
#

I dont think its possible to protect, most of the difficult sites to get the video from use chunks, but its still possible to download it

fickle fox
#

chunks?

unkempt snow
#

as in, send 4-5 seconds in every GET request

#

so its sends the video split into many chunks instead of in 1 file

#

however its always possible to mix those and create it into 1 file

fickle fox
#

oh so thing i saw was lie

#

if there is way to protect it i d like to use it for sure

#

but tq

unkempt snow
#

There are multiple video security providers which makes it hard to do so

#

not sure waht they are using exactly, but there are way to make it difficult to do so

#

however, never impossible

rustic pebble
#

@fickle fox I dont rly thinking netflix uses the request to increase the security of their services but to, rather, increase the performance, by downloading the video in chunks the buffer time is minimal

distant trout
#

can someone tell me if i always have to start off making my website responsive?

#

can i just add in media query when every thing looks fine on a desktop 1920x1080 monitor?

rustic pebble
#

Yes you can add a media query but you will need to adjust the mobile version of your website accordingly

#

it wont magically fit into place

distant trout
#

ahh

#

do people usually make responsive website from the start?

#

or do it at the end of a project

rustic pebble
#

It depends, I usually layout the design at my best capability, making it responsive filling it with demo data - placeholders, then I proceed into building the backend which will then fill the place of the placeholders

#

That is my opinion and method, doesn't mean you have to follow it

#

If you got a solid plan in your head you can jump in the backend, build everything and then just leave the design for last

#

I like to see the frontend rollout as I build the backend, so having an already existing frontend base feelsgood

distant trout
#

ahh

#

sounds very structured

#

the way u do it

#

thank you

rustic pebble
#

Well, yeah

#

I like to structure my development process into models

distant trout
#

models?

#

like the frontend/backend?

rustic pebble
#

I use the MVC model, model - view - controller

#

Basically, view makes a request, a controller takes that request, processes it and updates the model, then the view is updated and user sees the result

distant trout
#

ohh nice

#

i started learning flask for that

rustic pebble
#

Well

#

Once you start scaling things you will refrain from using sync frameworks

distant trout
#

whatever that is πŸ˜… i need to learn a lot

native tide
#

Anyone have a good resource to get a good understanding of using React w/ django?

young gull
#

Is it possible to figure out (with python) which ajax requests are made when i send a http get to an URL?

rustic pebble
#

@young gull wdym?

#

You can't utilize the entire tools of django with react, react is a frontend SPA framework. you can use it with django rest framework

#

@native tide

native tide
#

any good resource for it?

rustic pebble
#

Medium usually posts very good and consice articles

midnight kernel
#

@native tide ive used react with flask. its possible to serve the index.html page that comes with the react build using flask, but its... tricky, and almost always better to just serve that index.html with nginx

young gull
#

@rustic pebble When i browse to an url in chrome i can see multiple xhr requests in the dev tools.

rustic pebble
#

Yes

native tide
#

thanks @rustic pebble and @midnight kernel

#

probably better off using node lol

rustic pebble
#

np

#

Yup

#

You can use react with anything you just need restapi

#

not anything else

#

@young gull

echo ingot
#

hey guys, i want to start making web applications and I've heard you can use herokuapp to make web applications. Should i use that or just use flask?

rustic pebble
#

U can use flask to make webapps and then gunicorn to host them on heroku

hallow jacinth
#

anyone have a good tutorial or know how I can make a web app hosted through amazon s3?

#

or should i be looking elsewhere for the host

native tide
#

Can't you host it on netlify?

#

It's free

hallow jacinth
#

never heard of that i will have to look into it

#

thank you!

native tide
#

Guys I tried to automate my whatsapp with selenium but it didn't work.so I imported a code from online still it didn't work can you help me

rustic pebble
#

!rule 5 @native tide

lavish prismBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, be considered malicious/inappropriate or be for graded coursework/exams.

native tide
#

Does whatsapp automation breaks any of these πŸ™„πŸ™„

#

Sry I didn't know tat

thin spear
#

yo

#

use twilio for whatsapp

snow dragon
#

@native tide

you must not directly or through automated means: (a) reverse engineer, alter, modify, create derivative works from, decompile, or extract code from our Services; (b) send, store, or transmit viruses or other harmful computer code through or onto our Services; (c) gain or attempt to gain unauthorized access to our Services or systems; (d) interfere with or disrupt the integrity or performance of our Services;
https://www.whatsapp.com/legal?doc=terms-of-service&version=20200128

native tide
#

@snow dragonthanks. I didn't really knew tat

silent knoll
#
import random

app = Flask(__name__)


@app.route("/")
def index():
    num = random.randint(0, 1)
    return render_template("index.html", num = num)

@app.route("/bye")
def bye():
    return "<h2>Good Bye</h2>"

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

return render_template("index.html", num = num)
^
TabError: inconsistent use of tabs and spaces in indentation

native tide
#

@silent knoll you have both spaces and tabs mixed

silent knoll
#

where?

#

got it

native tide
#

anyone have a good tutorial or know how I can make a web app hosted through amazon s3?
@hallow jacinth you cant host the web app on S3. S3 is their storage service however you can use Ec2 but i dont recommend it because it is expensive... Use Heroku for now!

native tide
#

Hi, I'm making a simple server with flask and while I'm copy-pasting tutorialimplementing login I found that the session doesn't get saved. What am I doing wrong?

@app.route('/login', methods=['POST'])
def login():
    print("Last session")
    print(session)
    req = request.values
    if 'id' in session.keys():
        return {"message": "Already logged in"}, 200
    else:
        res = helper.login(req['id'], req['password'])
        if res:
            session['id'] = req['id']
            session.modified = True
            print("After changing")
            print(session)
            return {"message": "Logged in"}, 200

    return {"message": "Invalid credential"}, 401

output :

Last session
<SecureCookieSession {}>
After changing
<SecureCookieSession {'id': 'test'}>
127.0.0.1 - - [24/Jun/2020 13:58:46] "POST /login HTTP/1.1" 200 -
127.0.0.1 - - [24/Jun/2020 13:58:52] "POST /login HTTP/1.1" 200 -
Last session
<SecureCookieSession {}>
After changing
<SecureCookieSession {'id': 'test'}>
#

setting secure_key btw

#
app = Flask(__name__)
app.secret_key = ':/'
native tide
#

any idea?

native tide
#

take a look at that and change the secret key

#

What do you guys use to compress images for web (decrease their buffer). Is Pillow good enough or?

#

@native tide

#

I'd recommend you use flask-login

#
Flask-Login provides user session management for Flask. It handles the common tasks of logging in, logging out, and remembering your users’ sessions over extended periods of time.
#

@native tide it was to hide my key xD
ill check out that, thanks

#
import os

SECRET_KEY = os.environ.get('SECRET_KEY')
#

use that to hide the important data

#

a.k.a environment variables

#

thats a good idea

#

why session doesnt work for me tho

rapid epoch
#

who can help me with selenium

#

please guys

grizzled leaf
#

what's the issue ?

rapid epoch
#

how can i scroll down the following/follwers list in instagram using selenium?

grizzled leaf
#

Oof

rapid epoch
#

what?

grizzled leaf
#

you have to focus the window

#

are you using javascript ?

rapid epoch
#

no python selenium

grizzled leaf
#

yeah just like me

rapid epoch
#

to get following and followers list in insta using selenium

#

@grizzled leaf ?

grizzled leaf
#

i'm looking for it

rapid epoch
#

already saw these stuffs nothing works

native tide
#

Guys I got a job interview as a backend dev with django

#

Any tips?

rapid epoch
#

please shut up for a while @native tide ]

#

sorry !

native tide
#

huh?

rapid epoch
#

ANYONE SOLVE MY PROBLEM

native tide
#

The channel doesn't really belong to you

#

@rapid epoch if you wanted a dedicated help you should've asked in help channel

#

Learn how to communicate

rapid epoch
#

noone is ready to help

native tide
#

you're not allowed to crawl/automate smth in instagram IIRC

#

except the api they provide

rapid epoch
#

ok lol

native tide
#
You can't attempt to create accounts or access or collect information in unauthorized ways. This includes creating accounts or collecting information in an automated way without our express permission.
#

@native tide i would ask some fundemental questions ex) design patterns

#

i'm not specialized in web dev but at least that's what i heard of from my friends

#

Thanks :)

quick shuttle
#

Hi, simple question. Do you know if there is a parameter that can be placed in a field to prevent the Chrome proposal list?

wispy tinsel
#

Try putting autocomplete="off" attribute in the input

quick shuttle
#

@wispy tinsel Thx you, it's working πŸ™‚

wispy tinsel
#

No problem πŸ™ŒπŸ»

dreamy pecan
#

Morning!

#

So i', getting this error from my model.

#

ValidationError(
django.core.exceptions.ValidationError: ['β€œβ€ value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.']

rancid crane
#

can you send me the snippet ?

dreamy pecan
#

class Promo(models.Model):
user = models.CharField(max_length=50)
passwd = models.CharField(max_length=50)
pub_date = models.DateTimeField(auto_now=True, null=True, blank=True)
image = models.ImageField(upload_to='images/')
nif = models.CharField(max_length=9)
promo_redeem = models.CharField(max_length=20, null=True, blank=True)

rancid crane
#

for forms handing??

dreamy pecan
#

No forms.

#

Just started out with the project.

rancid crane
#

ok then can you tell me the line where exactly this error is

#

ValidationError(
django.core.exceptions.ValidationError: ['β€œβ€ value has an invalid format. It must be in YYYY-MM-DD HH:MM[:ss[.uuuuuu]][TZ] format.'] this error appears when you fill the form or when the model is just excuted??

dreamy pecan
#

When i try running manage.py migrate

rancid crane
#

ok

#

pub_date = models.DateTimeField(auto_now=True, null=True, blank=True) this is where is comes right>>

#

??*

dreamy pecan
#

When i did the first makemigrations thats the line the error popped but now it does not specify which line throws the error.

rancid crane
#

can you remove blank=True and then give it a try?? from pub_date

#

and make migration again

dreamy pecan
#

Let me check.

rancid crane
#

if your pub_date is auto_now then why u need it null?

#

database can auto fill this field when u submit the data

dreamy pecan
#

I had it like that checking some stuff from stackoverflow.

#

Did the change but same error.

rancid crane
#

pub_date = models.DateTimeField(auto_now=True)

#

and try add default=None

#

like this

dreamy pecan
#

Before adding the DateTimeField it was smooth then added a couple more fields. That's when the error popped out, then django started whinning about setting defaults to each field.

rancid crane
#

models.DateTimeField(auto_now=True, default=None

like this
@rancid crane )

#

models.DateTimeField(auto_now=True, default=None) try this

#

then make migration

dreamy pecan
#

K.

#

ERRORS:
promo.Promo.pub_date: (fields.E160) The options auto_now, auto_now_add, and default are mutually exclusive. Only one of these options may be present.```
rancid crane
#

models.DateField(auto_now=False, auto_now_add=False, default=None, null=True)

#

now

dreamy pecan
#

k.

rancid crane
#

haha now this is interesting

dreamy pecan
#

I do live in the caribbean, wouldnt it has something to do with timezone format django expects?

rancid crane
#

did the last one worked??

#

or not?

dreamy pecan
#

It threw the same error.

rancid crane
#

ok then tell me what database you are connecting with??

dreamy pecan
#

Postgres.

rancid crane
#

mmm

#

these code i send you worked very well in mysql

#

idk if it is a timezone related issuue\

#

never happened to me

#

can u send me the full errors

#

?

dreamy pecan
#

Yeah.

rancid crane
#

models.DateTimeField(auto_now=True) you can try this also

#

let me know it this worked

#

if it works*

dreamy pecan
#

Threw me this: ```(django3.0.7-3.8) E:\Dev\fritolaypromo\LandingPage>python manage.py makemigrations
You are trying to change the nullable field 'pub_date' on promo to non-nullable without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:

  1. Provide a one-off default now (will be set on all existing rows with a null value for this column)
  2. Ignore for now, and let me handle existing rows with NULL myself (e.g. because you added a RunPython or RunSQL operation to handle NULL values in a previous data migration)
  3. Quit, and let me add a default in models.py```
rancid crane
#

models.DateTimeField(auto_now=True) you can try this also
@rancid crane if this didnt worked then in case

#

models.DateTimeField(auto_now=True, default=True) should worked 😦

dreamy pecan
#

Hope all these previous migrations i have done are not getting in the way. Should i rollback to when it worked fine then apply your suggestions?

rancid crane
#

if you dont have any existing records and this is your testing server then you can

#

just delete a migrations EXCEPT init.py ie in the folder migrations

#

all migrations*

#

then

#

u need to delete the table in the postgres

#

tables

#

all tables in the postgress

#

@dreamy pecan can you share you screen

#

this can be more helpfull

#

this might be helpfull

dreamy pecan
#

Alright, gonna check that in a bit.

#

i'll let you know.

rancid crane
#

ok πŸ™‚ GL

dreamy pecan
#

Thanks for the assistance thou. @rancid crane

hallow jacinth
#

Thank you @native tide

opal robin
#

hello how can i use css on pycharm

#

i have added django and css in project interpreter but it seems django is not recoginsing css

native tide
#

use style tag

#

in html

#

and put your css code there

#

don't use inline css

#

u could better just link them

dry pawn
#

Anyone experienced with Django, and maybe even DRF ? I have developed a REST API and would appreciate some feedback to see if I'm not going in the wrong direction before carrying on. Not my first website, but is my first Django project (Java/Spring guy here). Project is still very small: 993 LOC.

raw drum
#

Hi guys,
I have a model, called "Blog", which has a date property. I need to order my blogs by date, descending. Why is this so difficult? At the moment I do the following:
Blog.objects.order_by('date').reverse()
How do you use the asc() and desc(). I do not understand the Django documentation regarding this.

dry pawn
#

@raw drum You can use Blog.objects.order_by('-date').

raw drum
#

@dry pawn Damn. Thanks for that. Now that I read the documentation again, slowly, I see the "-" is used for desc:

dry pawn
#

You're welcome.

snow sierra
#

i am trying get image ..

{% for i in profile.all %}
<p>{{i.name}}</p>
<p><img src={{i.photo}}></p>
{% endfor %}

{{i.photo}} getting photo url.. but when using img src does not show .. any idea?? (i want without static)

dry pawn
#

@snow sierra If you browse the url directly, does it work ?

snow sierra
#

also not, but url is correct

dry pawn
#

How ?

snow sierra
#

ok wait.. i'll screen

dry pawn
#

src is meant to tell the browser where to find the picture. If browser cannot open url specified by src, it cannot work.

snow sierra
dry pawn
#

Yeah, so src is not correct, that's my point.

snow sierra
#

admin site is working correctly... image is in uploads/ folder..

dry pawn
#

I don't deny the picture is where you think it is

bleak bobcat
#

Is uploads folder being served by your webserver ?

snow sierra
#

Is uploads folder being served by your webserver ?
@bleak bobcat what i do for it?

#

did you mean MEDIA_ROOT in settings?

dry pawn
bleak bobcat
#

Yea but not only

snow sierra
#

ok ok ... i was trying without static .. i'll do with that django docs ..

#

i through if HTML gives me path of image then <img src ... > must work :d

dry pawn
#

The idea is that browser will fetch html, analyze html, see the src attribute and then fetch picture using provided url. So provided url must serve picture.

snow sierra
#

thank you mates πŸ™‚

#

look at this

{% load static %}
<img src="{% static "my_app/example.jpg" %}" alt="My image">

but here i want dynamic image as said above ... {{i.photo}} because every student have own pic ..

bleak bobcat
#

Then it's media, not static. You need to add uploads dir to the media files django should serve

snow sierra
#

Then it's media, not static. You need to add uploads dir to the media files django should serve
@bleak bobcat right! can you give me good link about it? πŸ˜—

#

around ImageField docs i did not get enough recourses for my brain :X

native tide
#

I want to save images in the static directory (situated in the root directory of my application).
What works for me is creating an image path like this

image_path = os.path.join(current_app.root_path, current_app.config['IMAGE_DIR'], safe_filename)

However, if I try to use url_for for relative paths and say

image_path = os.path.join(url_for('static', filename='assets/images'), safe_filename)

it doesn't work anymore. Anyone knows why?

#

PS: Working with Flask

sullen roost
#

Fussing with Django REST. Is there a good method for serialization for extra actions? Because I can specify this:

@action(detail=False, serializer_class=MySerializer, methods=['post'])
def my_extra_action(self, request):

But it'd still need to be consumed by MySerializer and checked with is_valid

#

Mostly doing that so it'll self document because I'm lazy

native tide
#
@app.route('/profile')
def me():
    discord = make_session(token=session.get('oauth2_token'))
    user = discord.get(API_BASE_URL + '/users/@me').json()
    guilds = discord.get(API_BASE_URL + '/users/@me/guilds').json()
    connections = discord.get(API_BASE_URL + '/users/@me/connections').json()
    return render_template("index.html", content=user["username"])

error:
jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'string'

#

show us the template

#

@native tide

random rose
#

Forgive my naivety, but I'm trying to follow Corey Schafer's "Learning Django" series and am having an issue when calling python manage.py makemigrations. I get the following error:

CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0001_initial 3, 0003_logentry_add_action_flag_choices in admin; 0001_initial 3, 0011_update_proxy_permissions in auth; 0001_initial, 0001_initial 3 in sessions; 0001_initial 3, 0002_remove_content_type_name in contenttypes).
To fix them run 'python manage.py makemigrations --merge'
#

It says to call python manage.py makemigrations --merge, so I do. Doing that yields another error:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/base.py", line 83, in wrapped
    res = handle_func(*args, **kwargs)
  File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 133, in handle
    return self.handle_merge(loader, conflicts)
  File "/Users/Justin/Documents/learningDjango/venv/lib/python3.7/site-packages/django/core/management/commands/makemigrations.py", line 260, in handle_merge
    raise ValueError("Could not find common ancestor of %s" % migration_names)
ValueError: Could not find common ancestor of {'0001_initial 3', '0002_remove_content_type_name'}

Is anyone familiar with this kind of error? I know that it has something to do with the management of databases in my project. However, I haven't even touched any of that yet; I've only had it serve some static html pages at different endpoints.

native tide
#
{% extends "base.html" %}
{% block css %}
{{ url_for('static', filename='style.css') }}
{% endblock %}
{% block title %}Home{% endblock %}

{% block content%}

    <p>Hello, {{ content }}!</p>

{% endblock %}

@native tide

#

Is this the only .html file you have?

#

no

#

I see no errors in here, give me the traceback of the error.

#

one moment

#
    return _render(
  File "/home/luke/.local/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
    rv = template.render(context)
  File "/home/luke/.local/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/home/luke/.local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/luke/.local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/media/luke/TOSHIBA EXT/Developing/Flask/User/templates/index.html", line 1, in top-level template code
    {% extends "base.html" %}
  File "/home/luke/.local/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/luke/.local/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/media/luke/TOSHIBA EXT/Developing/Flask/User/templates/base.html", line 23, in template
    <li><a href="{{url_for("index")"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
jinja2.exceptions.TemplateSyntaxError: expected token 'end of print statement', got 'string'
#

oh wow

#

i think i might see it

#

{{url_for("index")

#

i didnt know a traceback logged πŸ€¦β€β™‚οΈ

#

πŸ™‚

#

so it should be

#

{{ url_for('index') }}

#

{{url_for('index')}}

#

yep

#

thats what im trying

#

wow dude

#

thanks

#

πŸ™‚

#

amazing

#

np

#

have an amazing day

thin spear
#

Hello guys, I want to get a job as a web developer later in my life but I want to learn it from basics first. Can someone please help me with free courses and the correct sequence of learning. By the way, I know the basics of HTML, CSS, jinja 2, python, flask and SQL.

#

Please tag me as well so that I get a ping

native tide
#

how can I embed a variable in url_for

#
src="{{ url_for('static', filename='assets/images/projects/image_path') }}"
#

image_path is my variable

#

and the line above doesn't work

#

nvm found out ```
src="{{url_for('static', filename='assets/images/projects/')}}{{image_path}}"

vague bison
#

Hi guys, I'm trying to get started with Python and my main goal is to make little **online ** projects for practice and obviously if I'm going to get better, I'll do more complicated things. However as a complete beginner I'm not really sure if Python is a correct language for this matter. My friend who is working at my company's IT department said that for Python you usually need to use Linux for things to work 100%. But I don't really want to use Linux, is that really a thing?
Also if it's not the case, could anyone give me a roadmap or some kind of guide on what are the most important things to understand and what beginner projects usually people make to practice?

Well sorry for the wall of text, but I got addressed here from an another forum to chat :d

wind escarp
#

Python can be installed on Windows and so works on it, I don't know what your friend really meant.
For online projects, do you mean websites? Desktop apps? Mobile apps? Scripts?
These all can be done with python and since it's a scripting language, it can be used for building websites as well, I have had some experience with it but it's not solid yet and I haven't work on my own projects.

verbal obsidian
#

Python is not a scripting language.

#

You don't need to run it in linux to make 'things work 100%'

#

For your use, it'll be allright to use any os, it is true that there might be a few OS dependant libraries but you will most likely not be affected by this.

wind escarp
#

Not a scripting language?

vague bison
#

@wind escarp I don't know what my friend meant either, he said usually python developers using Linux. And yes as for my goals I mean websites and different things on websites, like little programs or things like that. It's important for me to be globally accessable not only at my PC or after installation

verbal obsidian
#

General purpose laguage

wind escarp
#

General purpose laguage
Right, but still a scripting language.

verbal obsidian
#

Maybe in 1991

#

but no today

#

doesn't matter how you try to look at it

#

it is not

jaunty plover
#

Python works fine on either os. It really doesn't have that many differences, certainly not for more users.

#

Most*

wind escarp
#

@wind escarp I don't know what my friend meant either, he said usually python developers using Linux. And yes as for my goals I mean websites and different things on websites, like little programs or things like that. It's important for me to be globally accessable not only at my PC or after installation
@vague bison
Yeah gotcha, head for python docs, then "automating the boring stuff with python" (book)

#

doesn't matter how you try to look at it
O.K.

echo ingot
#

guys does it ever become natural for y'all

#

making web apps

native tide
#

?

dreamy pecan
#

@rancid crane Solved my issue this morning, had something to do with the pycache storing dump data from previous postgres models. Once i removed them your suggestion worked.

rancid crane
#

Yaya

#

That was the issue

#

:)

#

:+1:

#

@dreamy pecan

echo ingot
#

idk for me rn if sat me down in front of a computer and told me to make a web app i would not be able to do it without a video guide

native tide
#

There are plenty "video guides" online, free and premium. Depends what you're looking for.

opal robin
#

hello how can i use css code inside django

echo ingot
#

lol im doing the corey shafer flask guide

native tide
#

yeah, that's perfect as a starting guide

opal robin
#

hm can someone help me please

native tide
#

@opal robin wait for someone to help you, don't spam pls

#

look at that

opal robin
#

actually i'm doing it another way

#

i'm followng a tutorials

#

this is my settings .py file

#
STATIC_ROOT= ''
STATICFILES_DIRS = (
    os.path.join(BASE_DIR,'assets'),
)```
native tide
#

hello, i am working with the discord oauth. i was wondering how do i check if the user that verified with there oauth has manage_server permission? (btw im using flask)

opal robin
#
    background:blue;
}
#

this is my css

#
<html>
    <head>
        <link rel="stylesheet" href="/static/styles.css">
        <title>Articles</title>
    </head>
    <body>
    <div class="wrapper">
        {%block content%}
        {%endblock%}
    </div>
    </body>
</html>```
#

and this is my html

native tide
#

what is your issue

opal robin
#

i seems like the django has recognised a background color but i can;t make any changes to it

#

i can't use css

#

on django

native tide
#

background-color: blue;

opal robin
#

i don't think that's the problem

native tide
#

send us a tree of your app

opal robin
#

because i previously set it to green and now it's green

#

but i can't change it

native tide
#

restart your app

opal robin
native tide
#

and see if the changes apply t hen

opal robin
#

how can i do that

native tide
#

try restarting your app everytime you change the color

#

don't see any static folder tho'

#

you don't need one in django iirc

opal robin
#

what

#

don't see any static folder tho'
@native tide i have one called assets

#

should i make assets inside of static?

native tide
#

yes

#
STATIC_ROOT= ''
STATICFILES_DIRS = (
    os.path.join(BASE_DIR,'assets'),
)```

@opal robin what's then with that file path pointing to static

opal robin
#

what

#

sorry

native tide
#

bruh

opal robin
#

i just followed a tutorials

native tide
#

learn more python before trying to learn django

#

or python in general

#
{% load static%}
<html>
    <head>
        <link rel="stylesheet" href="assets/styles.css">
        <title>Articles</title>
    </head>
    <body>
    <div class="wrapper">
        {%block content%}
        {%endblock%}
    </div>
    </body>
</html>
opal robin
#

can you please just say what i'm doing wrong

native tide
#

try this

opal robin
#

ok

#

should i remove ything on settings folder?

native tide
#

leave it for now.

#

try that

opal robin
#

ok

native tide
#

hello, i am working with the discord oauth. i was wondering how do i check if the user that verified with there oauth has manage_server permission? (btw im using flask)

opal robin
#

it removed the green background which i was having before and now it's only white

#

but i get no error

native tide
#

white is the default πŸ€¦β€β™‚οΈ

#

learn html and css before attempting to learn django aswell

opal robin
#

i know that

#

i'm just saying that django isn't showing an error

#

but i's not changing color as i wish

native tide
#
{% load static%}
<html>
    <head>
        <link rel="stylesheet" href="/assets/styles.css">
        <title>Articles</title>
    </head>
    <body>
    <div class="wrapper">
        {%block content%}
        {%endblock%}
    </div>
    </body>
</html>
#

try this

#

did you save the file

opal robin
#

pycharm saves them automatically

#

it's the same

native tide
#

idk bout that

opal robin
#

@native tide

native tide
#

press ctrl+s

#

then refresh the page your working on

opal robin
#

i tried that

#

too

native tide
#

@opal robin I m not sure then, but review the tutorial you might have missed sth

#

you don't have a static directory, but still you are mentioning it in the html file

#

btw learn html, css, and python before going further, its just extremely dumb not to

#

you can add a js script reloading it when submitted

opal robin
#

you don't have a static directory, but still you are mentioning it in the html file
@native tide i aslo tried creating a directory named static

native tide
#

okay byeee

opal robin
#

and than placing assets isntead of it

#

anyway thank you

#

okay byeee
@native tide why do you have to be so rude

native tide
#

@barren salmon you need to use redirect instead of rendering the template again

#

@opal robin dude your literally coming here with absolutely no knowledge

opal robin
#

that's not true

#

i'm new to django

#

not to python

native tide
#

lol all good

opal robin
#

yeah everybody can seem to be another person on online forums

native tide
#

I know it shows that, but use redirect(url_for('[the view function]')) @barren salmon

opal robin
#

that's how it works

#

this days and since the forums were inveted

#

it's hard to be nice

native tide
#

lol

opal robin
#

:/

native tide
#

when forums weren't invented, people actually learned the language lmao

opal robin
#

anyway goodbye

snow sierra
#

Laravel or Django?? which is strong in web what you think guys ..

native tide
#

laravel is more common

snow sierra
#

same ..

#

but php vs python πŸ™‚ is not compareable thing ...

native tide
#

php is still more common

#

if you ran into any issues you would most likely have better luck finding them if you were using php

#

and it is easier to host on a web server

snow sierra
#

sure !... why i asked it :dd i don't know, just was typing something :dd

#

i think we can compare Laravel to Wagtail and not to django.. πŸ™‚

echo ingot
#

guys idk if making a webapp is the most efficient way to do this
but
all i want to do is have an interactive GIS on a website that maps out real time data
how should i approach this project?

velvet vale
#

what is class based view?

fallow warren
#

can someone help me

#

when ever i shrink my screen the footer breaks

#

how do i fix that

#

in css

distant trout
#

is it better to use explicit or implicit css grids?

#

rows/columns numbers VS naming them in grid-template-areas

eternal frigate
#

Anyone know other ways beyond HTTP interfaces to integrate a django app with other softwares?

native tide
#

I really don't know if this is considered Advertising,

#

But is there a web dev / web designer here I am looking to commission one for a project

native tide
#

hello

limpid verge
#

Does anyone know what is the Purpose of Using DurationField in django

native tide
#

@distant trout this is not a CSS group but it depends on what you actually do. Naming columns might be really useful if you have a repetitive design on multiple pages.

#

example

#
    grid-template-columns: [sidebar-start] 8rem [sidebar-end full-start] minmax(6rem, 1fr) [center-start] repeat(8, [col-start] minmax(min-content, 14rem) [col-end]) [center-end] minmax(6rem, 1fr) [full-end];
#

here you know that the first column from sidebar-start to sidebar-end you have the navigation bar; then full-start to full-end you have an entire section spanning from the navigation bar to the end of the document width

#

You can get more organised if you know what you're doing.

native tide
#

Trying to get a Flask app to work. It runs with flask's dev server but not in apache

#

~/ansura/ansura-website/ansurasite.wsgi

import sys
sys.path.insert(0, "/home/crazygmr101/ansura/ansura-site")
from main import app as application
#
~/ansura/ansura-website
β”œβ”€β”€ ansurasite.wsgi
β”œβ”€β”€ main.py
#
<VirtualHost *:80>

        ServerAdmin webmaster@localhost

        ServerName ansura.xyz
        ServerAlias www.ansura.xyz

        WSGIDaemonProcess ansurasite user=crazygmr101 group=crazygmr101 threads=5
        WSGIScriptAlias / /home/crazygmr101/ansura/ansura-website/ansurasite.wsgi


    <Directory /home/crazygmr101/ansura/ansura-website>
        WSGIProcessGroup yourapplication
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =ansura.xyz [OR]
RewriteCond %{SERVER_NAME} =www.ansura.xyz
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
#

/etc/apache2/sites-available/ansura.conf

#

no matter what page i access, I get a 404 (apache's default 404, not my flask app's)

#

if anyone needs to see other files, lmk

#

"If you access the server via IP address, Apache will return based on its default site configuration in /etc/sites-available/000-default.conf. So if you want to access your WSGI server via IP address, you should disable the Apache default site configuration first:"

#
sudo a2dissite 000-default.conf
service apache2 restart```
#

what if im trying to use the url tho?

#

and i will do that

#

elaborate pls

#

"If you access the server via IP address, A

#

nothing is enabled except for ansura.conf and ansura-le-ssl.conf, it's SSL counterpart

#

WSGIScriptAlias / /home/crazygmr101/ansura/ansura-website/ansurasite.wsgi

#

why do you have 2 /

#

in the alias

#

im assuming / (site root) is being mapped to "/home/crazygmr101/ansura/ansura-website/ansurasite.wsgi" (location)

#

i just followed flask's documentation on the matter

#
        WSGIDaemonProcess ansurasite user=crazygmr101 group=crazygmr101 threads=5

seems like it should create a process called ansurasite under my user and group, and htop shows no such process

#

yeah, that's quite odd. I ll come back if I have other ideas. If you find out tho' let me know as well, I m curious

#

alr

#

ty

#

maybe try and put __init__.py

#

in your ansura dir

#

and do what with it?

#

idk maybe is not read by python as a dir

#

if you don't have that

#

look at this

#

alr

#

still nothing

#

ansurasite.wsgi

#
import sys
import importlib
sys.path.insert(0, "/home/crazygmr101/ansura/ansura-site")
#from main import app as application
app = importlib.import_module("ansura-website").main.app

#

i tried each of the last 2 lines

#

same error?

#

yup

#

do you have a route in your main file

#

?

#

Assuming the main.py script you posted is not redacted, you're potentially missing the actual route.

#

put

#
@app.route('/')
def hello_world():
    return 'hello world!'
#

in your main

#

as said above, this site works on flask's dev server

#

so i have everything set up on the flask side of things

#

mhm, mkay. Anyway, let me know if you figure it out

#

if ):

#

post on stackoverflow, maybe the boys will help

#

I ll help you with an upvote

#

:))

#

i mean i could just run waitress

#

and sudo start it

#

so it can bind to port 80

#

xD

steady agate
#

This an HTML and not Python

bleak bobcat
#

What do you mean by "error" ?

steady agate
#

my background image is not appearing

native tide
#

the path is wrong

#

That's an html related question, but whatever. The best you can do is get an IDE and structure you files as follows

#

.
β”œβ”€β”€ images
β”‚Β Β  └── library.jpg
└── index.html

#

then you can point to your image like this src('/images/library.jpg')

#

it also broke my term encoding :S

#

the heck did you do :))

#

idek

#

so like, im just trying to see if i can get my flask app running standalone firstt

#

except, ya know, HTTPS

#

can i just like.. run it like this and pretend wsgi doesnt exist owo1

native root
#

have you tried testing wsgi standalone

native tide
#

as in gunicorn or something like uwsgi?

native root
#

basically, uwsgi --http 127.0.0.1:5000 --module myproject:app that

native tide
#

yea

native root
#

does that work?

native tide
#

"could not load config" or someth

#

sec

#

thats with -http and -https-socket

#

also --module isnt a thing apparently

native root
#

-.-

native tide
native root
#

hmph

#

Try this:

#
uwsgi --http :9090 --wsgi-file foobar.py
native tide
#

and gunicorn just complained no matter what i did

#

alr

#

also

#

--http-socket?

native root
#

that's for something else

#

but that's irritating

#

try --http-socket anyway

native tide
#

well it complains if i use --http

#

and same error

native root
#

--http is supposed to start a server in wsgi

#

?

#

unable to load configuration?

native tide
#

i linked main.py and __init__.py above

#

if it helps

native root
#

try just main not main:app

native tide
#
Package: uwsgi
Version: 2.0.15-10.2ubuntu2.1
Priority: optional
Section: universe/web
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: uWSGI packaging team <pkg-uwsgi-devel@lists.alioth.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 109 kB
Depends: uwsgi-core (= 2.0.15-10.2ubuntu2.1)
Homepage: http://projects.unbit.it/uwsgi/
Download-Size: 16.9 kB
APT-Manual-Installed: yes
APT-Sources: http://us.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages
Description: fast, self-healing application container server
 uWSGI presents a complete stack for networked/clustered web applications,
 implementing message/object passing, caching, RPC and process management.
 It uses the uwsgi protocol for all the networking/interprocess communications.
 .
 uWSGI can be run in preforking, threaded, asynchronous/evented modes and
 supports various forms of green threads/coroutines (such as uGreen, Greenlet,
 Fiber). uWSGI provides several methods of configuration: via command line,
 via environment variables, via XML, INI, YAML configuration files, via LDAP
 and more.
 .
 On top of all this, it is designed to be fully modular. This means that
 different plugins can be used in order to add compatibility with tons of
 different technology on top of the same core.
 .
 This package depends on uWSGI core binary and installs:
  * init.d script for running uWSGI daemon(s) with options defined in custom
    user-created configuration files
  * infrastructure for running daemons (like common locations of communication
    sockets, logs)

N: There is 1 additional record. Please use the '-a' switch to see it

not sure if the version matters

#

and oki

#

=/

native root
#

shouldn't matter that much

#

Ah, I see

#

you forgot to add --wsgi-file to the parameters

native tide
#

told meit wasnt a valid param

native root
#

Well

#

I want to say just running uwsgi alone will give valid params, which I'd want to see now

#

but I cant get my copy to run because someone doesn't support virtual environments correctly

native tide
#

well i did discover a thing

#

there's an apt version

#

and a pip version

#

could that be why?

native root
#

Maybe but I find that unlikely

native tide
#

I want to say just running uwsgi alone will give valid params, which I'd want to see now
i yeeted the apt version before you said that

#

also

#

both pip and sourcec

#

whine about this

#

is there a python-devel package or someth?

#

:o it's building

native root
#

yes, there's a python-dev package you'll need

native tide
#

yea i got it

native root
#

oh nice

#

now try it

native tide
#
crazygmr101@crazygmr101:~/ansura/website$ uwsgi --http :9090 --wsgi-file main.py
uwsgi: option '--http' is ambiguous; possibilities: '--http-socket' '--http-socket-modifier1' '--http-socket-modifier2' '--https-socket' '--https-socket-modifier1' '--https-socket-modifier2'
getopt_long() error
native root
#

use --http-socket

native tide
#

alr

#

--wsgi-file not recognized

#

:o

native root
#

uwsgi --help

native tide
#

i rebuilt it with libssl-dev

native root
#

ll, however you ran that

#

is right

#

You can't bind to ports < 1024 if you're not root

#

which is expected

#

apache should be handling that for you

#

probably

native tide
#

i was trying to bind to 9090 tho

native root
#

Well, you can see in the error message flask is trying to bind ssl to port 443

native tide
#

oh

#

true

native root
#

do you have an ssl package enabled?

#

shouldn't have that if you're using a proxy server

native tide
#

yea, it was the only thing that would get uwsgi to work

#
apt-get install libssl-dev
pip install uwsgi -I --no-cache-dir

found this on SO

#

so

#

i see it loading flask, then dying

#

(also i forgot, in my messing, i tried to run flask with SSL earlier)

#

which did work, to run flask standalone

native root
#

right, so the deal here is it's unable to find the stuff that tells it what to run

#

normally there's an ini file but you SHOULD be able to just point it at your file with a wsgi app in it

native tide
#
import sys
import importlib
sys.path.insert(0, "/home/crazygmr101/ansura/website")
from main import app as application
#

thats my ansurasite.wsgi

#

in same dir as main.py

native root
#

What's the command you're using?

native tide
#

i tried uwsgi --http-socket :9090 --wsgi-file ansurasite.wsgi

#

not sure how else i'd 'point' it at the wsgi

native root
#

Well, we can see here it's looking for "/ansura/website/uwsgi" despite you passing in ansurasite.wsgi

#

those are quite different

native tide
#

/ansura/website/uwsgi also doesnt exist

native root
#

Try specifically doing ansurasite/wsgi.py

native tide
#

that doesnt exist either tho

#

ansurasite.wsgi - thats not a literal *.wsgi file?

native root
#

right

native tide
#

uh no

native root
#

oh

native tide
native root
#

yeah

#

exactly

native tide
#

should i try enabling ssl or

native root
#

wsgi-file expects a config file

#

and an app name to load from it

native tide
#

ah oki

native root
#

no, if you're using wsgi apache does ssl for you

native tide
#

alr

#

uh

native root
#

Now that you've got wsgi working you should be able to use a unix socket and point apache at it

native tide
#

except

native root
#

Bleh

#

are you in the directory with your main.py?

native tide
#

ye

native root
#

Hm.

#

Bleh

#

dur

native tide
#

" !!! no internal routing support, rebuild with pcre support !!!" does this matter

#

o

#

ok

#

nope

native root
#

why's it looking for uwsgi again

native tide
#

cuz i removed the :app presumably

#

" !!! no internal routing support, rebuild with pcre support !!!" does this matter
@native tide ^^ and this?

native root
#

Unlikely

#

the :app shouldn't matter

native tide
#

so.. what do i do :S

native root
#

Here's something straight from the wsgi docs that should work:

#
uwsgi --socket 127.0.0.1:3031 --wsgi-file myflaskapp.py --callable app --processes 4 --threads 2 --stats 127.0.0.1:9191
native tide
#

uh ok

native root
#

Well, of course change myflaskapp to your main file

native tide
#

oh.

#

right.

native root
#

alright

#

next step, is to try basic flask app

native tide
#

that works

#

o wait

#

nvm misread

native root
#
import flask
app = Flask()

@app.route("/")
def do():
  return "Test"

native tide
#
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello, World, from Flask!"
#

something li- yeup

native root
#

Yeah

native tide
#

he d o

#

i can just do this in /tmp right

native root
#

probably

#

but I'd do it in the same folder

#

just name the file flask_test or something

native tide
#

hmmm

native root
#

should use the --wsgi-file test.py --callable app format

native tide
#

alr

#

same thing

#

wait

#

you gave me bad code >:(