#web-development

2 messages Β· Page 109 of 1

summer wyvern
#

I get this error

#

Traceback (most recent call last):
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Owner\PycharmProjects\Django\password_generator\passwordgenerator\views.py", line 25, in get_name
    return render(request, 'name.html', {'form': form})
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\template\loader.py", line 61, in render_to_string
    template = get_template(template_name, using=using)
  File "C:\Users\Owner\PycharmProjects\Django\venv\lib\site-packages\django\template\loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)

Exception Type: TemplateDoesNotExist at /hello/
Exception Value: name.html
native tide
#

do you really need my help on that

#

it literally tells you whats wrong

summer wyvern
#

how do I create a template

native tide
#

use django docs

sacred gull
#

<input type="text" name="text" width="150" height="50">
shouldn't this be working?
it's been...20 years since I last used html :\

smoky carbon
#

Finally a django community! πŸ™‚ Is there a dedicated django server on discord? Would love to join one.

native tide
#

@sacred gull width and height are css properties, either refer to them in a style = height: x, width: y or a seperate css file

sacred gull
#

so I can't really adjust height/width within the html?

#

oh, kind of miss-read your answer
I'll try that, thanks

remote ruin
#

hey i hae a question ^^
So i have a small laptop and i wondered when to set the max-width for my html-tag, so the website doesnt expand to the full screen-size on large screens

native tide
#

@sacred gull yeah np, just look up on the style attribute in html and it'll explain how you can introduce CSS into HTMl

swift sky
#

@polar trellis this is way more complex, i didnt realize you needed to do so much security

zinc sphinx
#

I am considering using python and django to create an affiliate marketing website

Is this recommended or must I consider other programming language / web framework? Why

polar trellis
#

python/django will get you the backend you still need a front end language

tribal void
#

hello please listen i am making a website project and i need some help in http and css script

stone ledge
#

Hey, so I am trying to use a bot to post my server member count on my website, using flask and discord.py. Here is my code: ```py
from flask import Flask, render_template
import discord
from discord.ext import tasks
from functools import partial
from flask import Flask
from threading import Thread

client = discord.Client()

app = Flask(name)

members = 0

@client.event
async def on_ready():
print('Ready!')

@app.route("/")
def index():
global members
guild = client.get_guild(id)
members = guild.member_count
channels = len(guild.channels)
print(members)
return render_template('index.html', members=members, channels=channels)

if name == "main":
partial_run = partial(app.run, host="0.0.0.0", port=80, debug=True, use_reloader=False)
t = Thread(target=partial_run)
t.start()

client.run('token')``` When I type flask run in terminal, it works completley fine. But since that is just a developement server, I installed gunicorn and then typed gunicorn app:app in terminal. Then it went into a big loop of starting and crashing. It eventually gave the error: RuntimeError: Event loop stopped before Future completed. but that was probably because I stopped the code. Any ideas on running this?

zinc sphinx
#

@polar trellis front end such as JavaScript and HTML5? Is there a preference for django or just whatever I’m comfortable with?

mental prawn
#

i have a question about building a website, First; can i build a website using python? Second; im just a begginer to python so i know a little of variables and for, if, while statments (can they be used with building sites?) Third; where can i write my code so it becomes like a website.

tall plaza
#

Learn python oops concept.

#

And then give a shot to django framework which is based on python. With the help of django you can build a website

tribal void
#

hello please listen i am making a website project and i need some help in http and css script

polar trellis
#

@zinc sphinx html and javascript are oke

versed python
#

@mental prawn

  1. Yes it's absolutely possible
  2. Yes you need conditionals, while loops etc for websites ofc
  3. In a very basic way, a website is an html file and you can write one using a text editor and open it using a browser.
mental prawn
#

so then how will i be able to paste my code and turn it iinto a website, and also i can use pycharm right?

native tide
#

yep

#

but you need pycharm pro for django/flask prebuilt boilerplate

#

@tribal void so ask your question instead of saying that you have a question 2x

tribal void
#

@native tide ok bro can i ask my foubt tomorrow because it's too late and i am gonna sleepπŸ‘

#

@native tide bye and goodnight buddyπŸ‘β€οΈ

upbeat imp
#

How do i update a form field on POST request in Flask?

cold socket
#

Can anyone give me some direction/advice to best containerize my app via Docker for easy deployment to a remote server. My stack is Flask and Redis which I'm running using python-rq. In order to start my app locally I have to start the redis-server then run "python app.py" (Flask) and then "python worker.py" (Redis worker). I've been struggling to really create a good image for this.

wanton ridge
#

How to i check if the email is already exists in database with flask and sql?

west crown
#

django or flask which one is better?

zealous siren
#

Gates two separate containers

cold haven
#

I just sucessfully set up a microservice using Django

#

My main focus is on DaaS

#

anyone familiar with that?

prisma jackal
#
class Meta:
model = User
fields = ['username', 'email'] ```
Someone explain the meaning of the above snippest in django I don't understand their actual purpose and meaning.
native tide
#

@wanton ridge just see if the object is None or not

#

@prisma jackal if you're using ModelSerializer, the Meta class states its metadata

You state the model and fields it will serialize with model and field variables

cold haven
#

I have no idea.

prisma jackal
#

I need help

cold haven
#

look like setting meta data at the sub-file level

native tide
#

Yep

#

You can make a model serializer then in the python console do print(repr(your_serializer)) and you will see its fields. It's just like a model

cold haven
#

oh ...

#

If you understand MVC logic then it is easy then.

native tide
#

MVC?

cold haven
#

that's a methodology for web development, no?

#

model view controller it is.

native tide
#

Also the fields that you state will be required by that serializer when you make API requests. But you can set them yourself if you want them to have any extra validation different to your model which it's trying to replicate.

#

Oh never heard of it

cold haven
#

you should get to know that methodology I suppose.

#

it helps in web dev

#

it helps you break sub-level objects into components and such.

native tide
#

django handles that already πŸ˜„

cold haven
#

that's true...why reinvent the wheel.

#

If you want to know what the term model comes from.

native tide
#

it makes sense why django has views... I never knew why they used the word "views" when Flask refers to it as a function (I think)

#

Yea and models

cold haven
#

yeah

native tide
#

interesting

cold haven
#

it's good to keep up with the terminologies because they are redundant across systems.

#

cross-platforms

#

and I don't think that terminology is going to change any time soon.

native tide
#

yeah interesting, I barely know of any theory/methodologies so thats cool

cold haven
#

yeah I also know CRUD

#

that one is pretty helpful as it relates to RESTful API

#

I just don't like that it spells CRUD like poo

#

maybe they could of tried harder on that acronym specifically

#

unless a troll made that specific terminology up which is possible.

#

maybe the guy that came up with CRUD was getting sick of all the methodologies

warm igloo
#

well, CRUD isn't really a methodology I'd argue. Create. Read. Update. Delete. Those are the basic functions that almost every single app you use do. Even if your app to your clients only shows a READ state, you probably have a CRUD admin interface. And if you don't you're still doing those actions.

cold haven
#

well said...that almost every single app you use do...doodoo

#

no, with all jokes aside. I think it is good to have in checking states.

#

why not CRWD

#

create, read, write, delete?

#

because writing is updating

wanton ridge
#

i am working with flask and why i have no picture in my homepage, in my homepage.html i have picture but if i start my server then i have no picture. How to insert pictures

cold haven
#

why does the flask homepage look so ghetto?

#

well, the logo looks pretty old.

native tide
#

because flask is ghetto πŸ˜„

cold haven
#

nice nice

#

a ghetto coding language

native tide
#

that would be php 😳

warm igloo
#

flask is great, its just no batteries included whereas django is here is everything AND the kitchen sink

native tide
#

lmao

cold haven
warm igloo
#

flask's logo is an old wood carving of a flask

native tide
#

flask doesn't even provide you with the controller, nevermind the batteries

#

i always thought it was a chilli...

warm igloo
#

and also please don't use ghetto like this ... ghettos are real things and not the best way to describe something just cause you think it is poorly done

#

yeah not a chili though I've heard that before

upbeat imp
#

Can i update form on a post request in flask? and update the html?

cold haven
#

sorry, I just watched Uncut Gems the movie a couple days ago.

warm igloo
#

correct flask doesn't give you a "controller" cause it is not specifically MVC .. but you can do MVC as a pattern in flask for sure

cold haven
#

Uncut Gems was a really good movie.

native tide
#

@upbeat imp You could render another HTML page populated with your form's input once it's submitted, maybe?

quick cargo
#

would only take some simple ajax

native tide
#

React type beat πŸ™‚

upbeat imp
#

@upbeat imp You could render another HTML page populated with your form's input once it's submitted, maybe?
@native tide So i need to redirect to another url with a new html?

#

on post

quick cargo
#

would only take some simple ajax

native tide
#

No, you can re-render a HTML page on the same URL

quick cargo
#

Look at what AJAX is

upbeat imp
#

How do i re-render the html?

quick cargo
#

either by render the page again from the POST request if you're doing it like that

#

or AJAX if its being POSTed to it like that

upbeat imp
native tide
#

is AJAX only for APIs?

#

Ohh. nvm

#

Stupid question

quick cargo
#

AJAX just refers the dynamic re-loading of front end code

upbeat imp
#

So i put render_template inside both get and post?

quick cargo
#

e.g. sending POST requests without reloading the page, changing html etc...

#

@upbeat imp yeah ig

native tide
#

Implementing AJAX would just be on the frontend JS though right?

quick cargo
#

yeah cuz the backend can just interact with it as a api

native tide
#

Ah gotcha

#

Been working with react and I didn't know that was ajax πŸ˜„

quick cargo
#
$("button").click(function(){
  $.post("demo_test_post.asp",
  {
    name: "Donald Duck",
    city: "Duckburg"
  },
  function(data, status){
    alert("Data: " + data + "\nStatus: " + status);
  });
});```
#

simple POST request without reloading the page using JQuery

native tide
#

jquery still used? 😳

quick cargo
#

very much so

wanton ridge
#

i have in my index.html some images. And i have a flask server and once i start it i ave on my site no images, anyone can help me

warm igloo
#

@wanton ridge do you have a route for your static files?

upbeat imp
wanton ridge
#

i have a route with render_template("index.html") @warm igloo

warm igloo
#

right, but flask is now serving and it needs to know how to get to your images/css/etc

native tide
#

@wanton ridge Just do the img src={{url_for}} tag with your image filepath

cold haven
#

that looks like it should work...

wanton ridge
#

ah thanks

native tide
#

So you're gonna need to store it somewhere like a static or media directory, I wouldn't know πŸ˜„

warm igloo
native tide
#

@upbeat imp wdym? When the user makes a post request, what do you want to happen? Just refresh the page?

warm igloo
#

Flask treats static as a special place and routes for it. If you didn't want static as your place and had your own, you'd have to let Flask know that.

native tide
#

Or populate the form with the information that the user inputted?

upbeat imp
#

@upbeat imp wdym? When the user makes a post request, what do you want to happen? Just refresh the page?
@native tide Yes, i want to update a value in the form object and refresh the page with new values

native tide
#

hmm in your if block that handles POST requests, set form=ProgrammingForm(request.POST)

cold haven
#

i'm not sure of the reasoning behind such a thing.

native tide
#

Also instead of saying if request.method == "POST" you can use the inbuilt Flask functionality to check whether a form was submitted.

wanton ridge
#

@warm igloo i don't use javascript

native tide
#

I think it's if form.is_valid()? I don't know, I don't use flask

cold haven
#

@wanton ridge what u use? bootstrap or Material UI?

native tide
#

You should use JS πŸ˜‰

warm igloo
#

@wanton ridge okay? css is static. images are static. Any file like that.

native tide
#

Python + JS are a killer combo

wanton ridge
#

bootstrap @cold haven

upbeat imp
#

@native tide I get "AttributeError: 'Request' object has no attribute 'POST'"

cold haven
#

you can use media queries instead of javascript.

warm igloo
#

<img src="{{ url_for('static', filename = 'hello.jpg') }}" alt="my image about whatever">

native tide
#

@upbeat imp could you show the code?

wanton ridge
#

@warm igloo thanks

cold haven
#

I would probably use Material UI in the future, but have been using bootstrap @wanton ridge

upbeat imp
cold haven
#

Material UI is much more pluggable I believe.

#

requires less code

native tide
#

I think request.POST is for django, might've mixed that one up

cold haven
#

Bootstrap requires javascript in some cases I believe, but Material UI is completely CSS.

upbeat imp
#

Can't find anything on google about this either.. wierd

#

Someone must have had the same problem

cold haven
#

See here: Bootstrap uses JQuery

#

but Material UI is CSS only. that's the big difference

dapper tusk
#

try request.form

quick cargo
#

Bootstrap has a dependency on JS yes

upbeat imp
#

Okay, but how do i change the value in a form field before re-rendering the html?

quick cargo
#

Material UI However is designed for React and therefore is also pretty JS heavy

cold haven
#

no you are wrong

#

doesn't use any JS

#

it is CSS only

upbeat imp
cold haven
#

it isn't built just for React and you can use it for any framework.

native tide
#

@upbeat imp To access data of the form after it's submitted you can do form.your_field.data

#

Material UI is pretty big in the react field

#

never used it tho

dapper tusk
#

bootstrap does have some JS

native tide
#

still dreading on how i can implement bootstrap with it πŸ˜„

#

@upbeat imp You could get the user's inputs, and then render them somewhere else (it doesn't have to be in the same form).

quick cargo
#

if you're just using it for css components probably better to use TailWindCSS, Bulma or another pure CSS framework

native tide
#

Or even better do it on the clientside but that is extra.

upbeat imp
cold haven
#

Material UI is built mostly for React, I agree

#

who here uses React?

native tide
#

@upbeat imp Yeah, so you got your data out of the form. What do you want to do again? I'm a bit confused

#

I use react

upbeat imp
#

I want the IntegerField value to update, then refresh the website

#

with new value

cold haven
#

yeah, React is cleaner, but it takes longer to set up.

#

bootstrap is pre-build with lots of functionality that you would need to set up in React.

native tide
#

@upbeat imp You can render a HTML page with the form fields as read-only with the submitted values within them.

#

I remember I did that long ago

#

and it was a headache

upbeat imp
#

Do you remember how?

native tide
#

are you using WTforms?

upbeat imp
#

Yeah

native tide
#

tbh I can't remember

#

and maybe it was with divs

upbeat imp
#

I tried adding an argument to the init function and passing that, but i can't seem to refresh the website

native tide
#

do you specifically need to render it in the form again?

#

You could just have a seperate hidden div which is populated when the form is submitted.

upbeat imp
#

The value that needs to be in this integerfield will change at every post of the form

#

So yeah kinda

#

the default is 00000000, and when a button is pushed, aka a post request, a function is called that gets a serial number from a database, and needs to display this in the field on a refresh

swift sky
#

could someone explain to me what is meant by app.instance_path here in the docs

native tide
#

I remember I did that exactly but it was a pain and it took like 2 days

upbeat imp
#

fuck

#

lol

native tide
#

But I can't remember how

#

lmao

#

But,

upbeat imp
#

I'm a completely newb at this aswell

#

Is there a more dynamic way to do this?, like web-sockets or something?

#

you mentioned something about ajax?

#

Or

native tide
#

I think I had the form, and if that form was submitted, it would render divs with the form's values to replace the form 1:1. Then at the bottom it would have a button to "submit" again so the user could change those values. I might've been WTForms read-only fields or divs, I really can't remember

upbeat imp
#

i guess i could worst case, redirect to a new url that is identic with a new form πŸ€”

native tide
#

Uhhh you could muster something up on the frontend with JS but then you'll have to implement some APIs

swift sky
#

anyone πŸ˜„

native tide
#

i wouldn't know

#

@upbeat imp this is how I handled your issue, with Flask. I actually don't think there's a proper way unless you clobber it up yourself

#

I just replaced all the form fields with divs with the submitted values

#

Then at the bottom there is a submit button (of another WTForm) to refresh that form to make it POSTable once again

upbeat imp
#

πŸ‘

native tide
#

Obviously not the best way around but I couldn't find anything online too, as you said

#

But it replicates the feel of what it should be instead of a div to the left/right of the form πŸ˜„

#

You could probably use React for that

upbeat imp
#

So the submit button makes profile_confirmed == true?

native tide
#

Yea in my case

#

I used that to check whether the page should render divs (with the populated info) or a form (to input data)

#

and that profile_confirmed is a part of my User model

#

So you could have something much simpler

cold haven
#

a view you mean, but a model in a view ;D

#

that's where the naming gets misconstrued

#

I would like to say just another namespace for simplicity sake.

native tide
#

huh?

cold haven
#

Really...what you are dealing with is server software that can read multiple file types, you could even call the files as file-level objects themselves.

#

I mean in reference to server-side and client-side rendering

native tide
#

Imo model == database

#

or at least a representation of a database

cold haven
#

each and every one of them is a microservice in a server container.

normal kite
#

Is this chat currently being used?

#

Oh guess it is @_@

cold haven
#

that's why you can render html pages as whole objects so I believe they should be treated as such.

#

I would call objects of MVC as sub-file level components and should be treated as such.

native tide
#

@normal kite wym

cold haven
#

You can refer to objects in scope of the file-level or sub-file level.

normal kite
#

@native tide I had a question about heroku local hanging when I'm using waitress-serve

#

so I'm waiting until the discussion ends

#

before asking

native tide
#

become a part of the discussion πŸ˜„

#

with your question

normal kite
#

cool :D

#

Ok, I was trying to deploy my django app to heroku using waitress cause I'm on a windows machine.

#

This is my proc file

#

but it hangs when i do heroku local

#

and I get this error

quick cargo
#

why not use docker to test it on a linux env

normal kite
#

how do I do that

upbeat imp
#

uhh @native tide , when i changed the form field from IntegerField to StringField, the form.SN_single.data = '123' worked perfectly

native tide
#

it worked with request.post?

quick cargo
#

https://docs.docker.com/compose/django/ very basic example of docker setup for Django

Docker itself:
https://docs.docker.com/

Download for Docker (Requires virtualisation enabled in BIOS will probably be on by default):
https://docs.docker.com/docker-for-windows/install/

normal kite
#

Thanks!

upbeat imp
#

@native tide

native tide
#

Ok πŸ‘ and that updated it on the clientside after the form is submitted?

upbeat imp
#

Yeah

#

But with StringField i can't do max min validation tho

#

But it's better than nothing

native tide
#

ok

#

So when you submit a normal form in Flask, you end up with that form with the submitted values in the fields?

#

didn't know 😳

cold haven
#

I must be out of the loop...I thought the purpose of a form was to receive input.

#

you talkin like a form is supposed to come with values before putting them in.

quick cargo
#

They can do

#

not uncommon

upbeat imp
#

I explained it further up in chat. The form comes with default values on first get request, then the user push a submit button, and the website should refresh with some new values in the forum @cold haven

quick cargo
#

especially when they're for things like settings where they might already have a set option

cold haven
#

you probably looking for a read-only form then.

#

@upbeat imp yeah, I wonder if you can use a read-only form or if there is one that exists?

quick cargo
#

think he wants it to be editable

upbeat imp
#

Yes, the user should be able to edit the changed value if desired, the new value is only a suggestion

quick cargo
#

e.g.

Something is originally blank
they set the thing
form is re-rendered with Something pre set
then they can edit it again and repeat should they choose

#

basically a settings form

#

which tbf i wouldnt personally use WTForms for but then i dont use that in general, i would just use regular HTML as a block with a fillable pre-set

cold haven
#

@upbeat imp that sounds to me like the job of a login page, and not the functionality of a sub-page.

upbeat imp
#

login page? What do you mean?

quick cargo
#

Why would that be a login page pithink

#

He's not logging into anything 🀣

cold haven
#

i didn't say it is a login page.

#

I said similar to*

quick cargo
#

that sounds to me like the job of a login page

cold haven
#

why not make a separate component for that sort of thing? I would

quick cargo
#

Thats what WTForms does anyway

#

when its rendered by Jinja

cold haven
#

I'm still learning about Django

quick cargo
#

but yeah i would personally do it raw HTML

native tide
#

I feel like this would be something simple in React

quick cargo
#

this is Flask just btw

cold haven
#

oh, I probably won't try to use flask at all.

native tide
#

you're not missing out on much πŸ˜„

quick cargo
#

generally its alot more malleable that Django

#

which has its ups and downs

#

great if you know what you're doing but generally a pit fall for beginners with poor organisation of files

cold haven
#

sounds like Django comes with built in stuff that would do what he is trying to do in flask automatically

quick cargo
#

Flask has that

#

which is WTForms

native tide
#

you're very knowledgeable mr. CF8

quick cargo
#

I have experienced many of le framework work

#

Writing my own but i cant work out why Asyncio is bullying me 😩

native tide
#

😳 damn

upbeat imp
#

So flask is shit?

quick cargo
#

Flask is great

native tide
#

There's really not a big of a difference

cold haven
#

you say it doesn't come with controller logic though?

#

that's a huge deal breaker for me

quick cargo
#

Django is a full framework
Flask is a micro framework

#

there is a big difference to distinguish between them

#

Flask will let you do stuff that DJango will never let you do but that comes at a price of you are expect to setup alot of stuff

#

Django is more of a batteries included system as long as you confide by there rules

cold haven
#

what is it that flask can do that Django cannot?

native tide
#

^

#

Imo from projects w/ Django and Flask I found django to be much faster to build with. But Flask was an amazing starter framework to learn I guess

quick cargo
#
  • Anything requiring a Custom DB backend generally,
  • modifying of rendering engine,
  • inbuilt cron tasks (Django has this but can be a pain)
  • Flask is alot lighter weight than Django (less bloat)
  • You're not required todo things like X and Y like in Django
#

Django is very fast to setup generally

#

because it does alot of boilerplate for you

#

which is fine for alot of people

native tide
#

Yea

quick cargo
#

hence why it's slogan is The web framework for perfectionists with deadlines.

#

But equally it is very rigid and rather Slow with how it wants you todo things

native tide
#

Once you step out of what Django offers then it's essentially Flask... with you writing everything that you want from your program

#

Both are good

quick cargo
#

Its Django's way or the highway which is the biggest distinction between picking a Micro Framework or a Full framework

native tide
#

But by that, do you mean you have to use what Django offers?

#

Because you could just DIY it, no?

#

Make your own auth / models etc

quick cargo
#

You have to layout things How Django wants, setup the ORM design use the DB's it provides etc...

#

im not saying its impossible

#

but its considerably time consuming battling with the system

cold haven
#

Django has it's own built in ORM kind of which makes database management easier I bet.

native tide
#

Have you chosen a favorite? @quick cargo

#

Yea but for flask it's no different, u just import something like SQLAlchemy and get to learn that lib

quick cargo
#

i think overall Sanic is my favourite or FastAPI with my custom Backend wrapped over it

#

depends what im doing

native tide
#

le senior dev 😳

cold haven
#

you guys have jobs in coding web services?

native tide
#

no I'm 17 haha

quick cargo
#

Django generally isnt used for things which rely on multiple systems combined, say something like Discord. Django would be pretty un-usable due to its nature,

#

Same

#

lol

native tide
#

damn bro

#

I took you for a senior dev haha

cold haven
#

he is chinese...what do you expect because they learn young I guess

quick cargo
#

Just that sweet sweet boredom of passing time and try everything out πŸ˜‰
pst its not Chinese its Japanese but πŸ‘Œ

cold haven
#

I think people from India are even better at coding, or they do start at a young age too.

native tide
#

Yea CF8's english is pretty good

#

I'd say US or UK

quick cargo
#

Cuz i live in the UK lol

native tide
#

my g

cold haven
#

India has the biggest tech consulting firms on the planet I believe...

native tide
#

same haha

quick cargo
#

which is about to go into Lockdownℒ️

native tide
#

Bojo moving mad

cold haven
#

I worked for Tata Consultancy services

#

trillion dollar company

native tide
#

@quick cargo U done UCAS and stuff?

quick cargo
#

hehehe Nope

#

i should but im lazy 😩

native tide
#

yeah bro I applied like 2 weeks ago

quick cargo
#

especially when i dont plan on going to uni

cold haven
#

I would be careful working for a firm that is not based in your own Country.

#

You can't really file for unemployment if you get laid off.

native tide
#

I mean, I'm tryna get them US big bucks if you know what I mean

cold haven
#

yeah, I'm trying to get an IT Consulting job atm.

#

maybe at one of those big job search firms

quick cargo
#

Work Experience > Degree generally
except when talking about Big Data or AI due to the nature of how hard the maths is generally

native tide
#

I just plan on going to university, acing them algos/data structures and getting an internship at a big corp.

#

It's such a bummer though, in the US these big companies target schools for interviews. In the UK not so much

cold haven
#

you want to be careful about internships...They go by very fast.

native tide
#

Yah but I'm talking about the ones at faang

quick cargo
#

US companies target schools because they're not paid lmao

cold haven
#

yeah, I think they only hire people that graduate from Princeton or Harvard or Yale honestly

#

FAANG

native tide
#

Naw the interns get paid

quick cargo
#

UK Internships are generally Paid aswell while US are generally not

native tide
#

big time

quick cargo
#

its basically Slave labour US wise

native tide
#

Google interns get like $100k / yr

#

they get paid very well

quick cargo
#

thats google though lol

native tide
#

at least at faang

#

a lot of the major software corps go ham on the pay

#

but say you work for google in the UK it's like 60k GBP

cold haven
#

if I had 100k to go to Yale or Harvard I would to get a Masters degree in Computer Science.

native tide
#

it's a big difference

#

yeah I should've applied to US universities, missed a big oppotunity there

#

i heard their tuition costs are massive though

#

like $50k a year

#

i'd rather just go to st andrews or durham

quick cargo
#

Their system is generally very wack

native tide
#

facts

cold haven
#

it's ass backwards

quick cargo
#

tbh Uni's in general are pretty wonky considering that the UK system has a government appointed 3rd part exam board uptop but not including degree / bachelor level

#

Uni's self regulate though

#

they can choose and make what exam they do and what marks they give

#

two uni's can have entirely different papers or exams and give you the same degree. πŸ™ƒ

warm igloo
#

most companies with unpaid internships are doing so illegally .. just not enough enforcement

We don't even mess with the potential of screwing that up so our interns are definitely paid. I think the most recent one I have is $16USD/hour. 20ish hours during school, but he was with us full time during summer.

quick cargo
#

Summer jobs are pretty nice if you can get them

#

no enough people do them tbh

warm igloo
#

yeah

native tide
#

yeah but still unis are regarded for jobs. I'm just going to a hopefully prestigious uni for the peice paper at the end with jobs in mind

quick cargo
#

fairs

native tide
#

I was just flicking through indeed

#

and a lot of them were asking for it

warm igloo
#

I don't see a point in having a short term intern. It'd waste my time and resources. I only want to open intern positions on my team if I get to have the role through summer and semesters. Previous to this one, I had one intern for 18 months and now she's about to get a lead role at a company larger than one I'm at. I'm so proud of her.

native tide
#

otherwise i wouldn't be assed

quick cargo
#

Indeed is pretty poor for jobs

native tide
#

what would be an alternative?

quick cargo
#

Seen alot that basically ask you for experience you litterally cant have

cold haven
#

it's funny, I get emails from head hunters that ask 5-10 + yrs experience in technologies, and I respond with requesting an interview to be a job hunter at their firm because it's ass backwards. They probably get paid nicely to perform DaaS on different job sites and write emails to people that just get out of college that are looking for jobs.

warm igloo
#

recruiters get paid nicely when they place people AND the people stay

typically recruiters charge 15-20% of the salary for the placement

haughty turtle
#

Best practice to accept PayPal in Django ? Preferably no libraries outside of Django

native tide
#

@quick cargo have you applied to any software jobs yet? Or emailed any companies? I think you'd have a great chance

warm igloo
#

but if a recruiter places someone and they leave or get fired in a certain time frame that money isn't paid

cold haven
#

which is why it pays hansomely.

native tide
#

lots of people go into consulting too

#

never understood what that means.

warm igloo
#

or both work full time and do consulting

cold haven
#

it just means a job reference to a job.

native tide
#

essentially... freelance?

warm igloo
#

I do consulting occasionally.

cold haven
#

if you know the technologies out you can simply know what to expect of companies requesting them.

warm igloo
#

er, yeah, basically freelance though I bill as my company and not as myself

#

it could be on contract or not

#

we are WAY off topic for web dev though

cold haven
#

well, it's all related I suppose

native tide
#

Ah ok, so you'll just do a project for a company, like a subcontractor?

warm igloo
#

yes but there is a careers channel too

native tide
#

Yeah true. Interesting talk tho πŸ™‚

warm igloo
#

do a project, or in my case, work with a team who's doing the building and I act as a subject matter expert, architect, principal engineer, or something like that

#

rarely do I write the day to day code for them anymore

cold haven
#

well, let's get off the subject of job hunting then πŸ™‚

warm igloo
#

I think I write way more prose than code anymore. And diagrams. So many diagrams. πŸ˜„

native tide
#

That's actually really cool

cold haven
#

what if we talk about python technologies that are related to certain careers?

#

I suppose that's fine

warm igloo
#

I still freelance for some work for KFC which is funny. Like seriously little stuff like fix some html or js, or some data viz stuff. They're one of the few clients I bother with anymore cause my time is limited and I don't enjoy freelance much anymore. But I like the people I used to work with there.

native tide
#

Yeah. I guess. I saw lots of jobs increasing to take up React (w/ Django) as a requirement

#

Haha wow.

quick cargo
#

😩 Companies becoming too reliant on React

native tide
#

React πŸ˜‹ It's quite nice tbh

#

I don't see a point in having a short term intern. It'd waste my time and resources. I only want to open intern positions on my team if I get to have the role through summer and semesters. Previous to this one, I had one intern for 18 months and now she's about to get a lead role at a company larger than one I'm at. I'm so proud of her.
well you dont really give them actual work

cold haven
#

I like it too

quick cargo
#

Never tried it tbh

#

Generally use Vue.js

native tide
#

😳

#

you more just get to meet them and see if they culture fit, then make them an offer if u like em xD

warm igloo
#

front end framework (vue, angular, react) plus a solid backend framework (.net, django, etc) is the combo to set you up for success

native tide
#

@cold haven have you had a React + Django MPA?

#

ye

warm igloo
#

if I never write front end code the rest of my career I'll be a happy camper

native tide
#

Since you know react, meaning javascript, get node exp because why the hell not its all just javascript. then we are in python so you have two backends and react and you are golden

#

yeah that's a good idea

#

if I never write front end code the rest of my career I'll be a happy camper
i actually really enjoy writing in react, but most front end is straight cancer

#

id rather kms then write more normal non react frontend js/html/css

#

how do you go about structuring your React page? Do you use bootstrap?

warm igloo
#

I'm not a fan of css-in-js or jsx syntax. I much prefer the single file component system of vue.

quick cargo
#

Same

native tide
#

vue might be more than fine ive never used it, i meant compared to like 5-10 years ago old school ways

warm igloo
#

oh yeah I see ya on that

quick cargo
#

You can potentially make use of Both Front end and backend rendering should you need it with vue

warm igloo
#

though I do get lazy and just fuck it I'm using bootstrap and some theme I buy

native tide
#

Ya'll buy themes? πŸ˜‚

warm igloo
#

like I built warcache.com on flask and just didn't want to think about the front end code so it is mostly borrowed/bought and on its own

native tide
#

b-buying a theme?

cold haven
#

I am new to Django but I'll catch on quick. I'm also pretty new to React, but I would rather just use bootstrap for now.

native tide
#

just steal a theme from some open source project ayyy

#

Yessir πŸ˜‚

cold haven
#

you mean just buy a theme and sell it to a firm for a retail price of your salary? Cool Idea.

native tide
#

Lots of people fall into the trap of buying wordpress plugins, racking up literally a thousand or two in costs when it can all be found free

#

GPL license baby

warm igloo
#

eh, I own a license to tim's whateveryoucall it and the themes are nice and one cost and I own them all. Plus they're generally offered in plain html, or with vue ANd angular AND react. More than you get from free stuff.

#

and source files for all the art as well

native tide
#

wow!

#

assuming thats not much i mean thats a decent gain

warm igloo
#

and since I couldn't design a button to save my life, nor do I want to hire a designer, I'm totes fine with buying a template for my personal stuff

native tide
#

Doesn't it take away from actually coding though?

#

good?

#

Maybe that's why it's chosen πŸ˜„

#

who the hell enjoys coding designs

#

hmmm is this the right blue

#

hmmm

#

lemme slightly change its blue

#

hmmmmmm

#

Bro you're unleashing some kraken rn

cold haven
#

the bootstrap grid system is pretty easy. I can set up beautiful templates with grid and it's all based on div containers and setting up columns or nesting them.

native tide
#

hey 10 of my friends, what is your opinion on this blue vs that blue shade??

#

spends 6 hours through the night coding a dashboard

#

hmmmmm

warm igloo
native tide
#

6 hours? meant to say 60 πŸ˜„

warm igloo
#

even backend code for a lot of them

native tide
#

oooh yea I saw that before

warm igloo
#

so you can buy laravel and flask skeleton projects with the html and templates ready for you

native tide
#

so how does that stuff work?

#

once you buy the skeleton can you like, not post your project on githubb?

warm igloo
#

I wouldn't buy from say themeforest. But Creative Tim? Anytime.

#

sure you can, it is licensed for you to use in any project opensource or closed source

#

in fact, he open sources a ton of stuff too

native tide
#

but

#

if its on github

#

then anyone can just use it

warm igloo
#

yup

native tide
#

but

#

how does he get more than 1 sale

warm igloo
#

and if you don't have a license, he can come for you πŸ˜‰

native tide
#

but its on github

warm igloo
#

so its a bit of honesty as well

#

so

native tide
#

and your code is gpl or whatever

#

so

warm igloo
#

no

native tide
#

without a license

#

i can use it?

warm igloo
#

I can put code on github right now that you can read but if I don't give it a OSS license you can't use it

#

you CAN but then I can sue you

native tide
#

but you will give a oss license

warm igloo
#

it isn't automatically "free" cause it is on github, even if it is publicly readable

native tide
#

its your code and you want to

warm igloo
#

I can give it a closed source license

native tide
#

ok but its your code and you want to oss it

#

assume you do

warm igloo
#

so, I can't change someone elses license

#

just like GPL

cold haven
#

you can trademark code or something?

native tide
#

how do you like oss your parts and not his theme?

warm igloo
#

I can't take GPL code, change it, change license, and sell it with different license

#

the gpl code must remain gpl

quick cargo
#

There are certain OSS licences that require you to keep the same lience

#

and some licences require X and Y use case

#

which is the whole point of them

cold haven
#

so I can get GPL on my code and people can't use it unless I give permissions?

warm igloo
#

no, we're confusing some of this with a few conversations

native tide
#

so if you want to build a big open thingy that anyone can take and use and stuff

#

you are just limited to not buying a theme?

quick cargo
#

There's one which im a pretty big fan of that basically is OSS and free to users developing or testing but requires a paid licence for commercial deployment

warm igloo
#

no, buying the theme could allow me to use it .. it'll be in the terms of the license

#

it will vary project to project, seller to seller, etc

cold haven
#

I have question. What is complete opposite of GPL? is it the default if you make code?

warm igloo
#

the default is "no license"

cold haven
#

meaning?

native tide
#

you dont have to include a license on github

#

it asks if u want to and gives you some selections

cold haven
#

code by default on github can't be used for profit?

#

unless you have GPL?

native tide
#

code by default cant be used or taken at all by anyone for any purpose

#

you did not grant anyone the ability to, you just posted it online but its still yours

#

this goes over a bunch of licenses u can choose to grant permissions

cold haven
#

GPL is a left copy

#

I see that and understand

native tide
#
#

this goes over if you dont have one

warm igloo
#

I do most of my stuff MIT now

#

but I also work on a lot of closed source stuff with no license at all in private repos

quick cargo
#

MIT is pretty decent yeah

warm igloo
#

MIT is simple and clean and no ambiguities imho.

quick cargo
#

Most of my stuff is open even if the code is truly awful because im too lazy to deal with login into git on every machine when i deploy 😩

warm igloo
#

GPL2 is complicated. GPL3 is problematic cause it tried to fix for "saas" usage of GPL code but I think it got it wrong.

native tide
#

i use gnu gpl3. because if im coding something and you want to use it, fuck you i dont want you to close source it im sharing now you share

#

!

cold haven
#

after years of using git, I finally learned how to use it properly.

#

I took the time to learn finally because I was too busy trying to code.

quick cargo
#

Git is great for versioning

native tide
#

i dont know how to git but github gives me a gui

quick cargo
#

bloodly annoying though if your branches get desyncd

cold haven
#

They should have professional jobs that hire you for managing git code.

warm igloo
#

learn the git CLI

#

advice ^

native tide
#

but why

cold haven
#

I use git CLI

native tide
#

my IDE gives me all the info i need

quick cargo
#

lmao knowing VSC is a practically under most Developers stack

warm igloo
#

because you might be at a job that doesn't use github

native tide
#

i can even have the IDE give a git blame for every line

quick cargo
#

or imo should be under most developers stack

#

because VSC is incredibly important in the real world

native tide
warm igloo
#

or doesn't give you a gui

native tide
#

ill build a react gui then

cold haven
#

I use VSC

quick cargo
#

you wont apricate it until you have a rewrite branch of code going - > make a error and need to roll back

native tide
#

vscode lets me view the rollback inside of vscode though

warm igloo
#

sure, I'd like to see your react interface to git that covers merges, rebases, cherry picking, etc

native tide
#

left to right seeing both versions

#

sure, I'd like to see your react interface to git that covers merges, rebases, cherry picking, etc
@warm igloo nvm

warm igloo
#

haha

quick cargo
#

the CLI isnt even very hard to use

cold haven
#

you have way more control with the git CLI, it is less prone to errors over using the GUI git version.

native tide
#

im not saying cli is hard

warm igloo
#

the guis are good for the simple stuff

native tide
#

im just saying vscode and pycharm have alwasy let me do what i want

#

including seeing git blames, versioning, rollbacks, etc

quick cargo
#

I should get a bit more comfortable with Git Kraken but its a bit of a monster on larger projects

warm igloo
#

not like you need to memorize all of it .. there are hundreds of commands and most people use like ... 10?

#

πŸ˜„

#

I liked gitkraken till they went subscription model

native tide
#

and git lens extension is AMAZING

#

honestly, everyone on vscode needs it

quick cargo
#

most common are probably

pull, clone, push, commit, stash

cold haven
#

I think I want to try git in VSC next.

native tide
#

it lets you see a shitty coded line

cold haven
#

I think it would be easier

native tide
#

and you go this is garbage what idiot wrote this

#

and then you look at the name to the left on your editor

#

and its u

#

πŸ™‚

quick cargo
warm igloo
#

damn, I wonder why I don't have git lens anymore

#

used to

#

new machine who dis?

cold haven
#

in my last project, someone yelled at me for not creating a new branch and instead I forked the repo. He said you shouldn't do that, but I caught him not knowing what RESTful API is so...

#

it was some trolling

native tide
#

uh

cold haven
#

I was invited to a project on discord at a discord server.

native tide
#

but u cant create a branch without forkin

#

i mean unless you own it but

quick cargo
#

well that depends

cold haven
#

you can create a branch w/o a fork

native tide
#

im assuming he didnt have ownership perms

#

Β―_(ツ)_/Β―

#

i guess he did

cold haven
#

you can git checkout -b <branch name>

#

and it creates a new branch out of master

#

you don't push the branch to master though

#

I would rather just make a fork of the repo

quick cargo
#

generally you can fork it -> do the edits as a contributor -> make a PR and a branch will created

native tide
#

^^

#

thats how i know

cold haven
#

you can push to your own fork, that's the difference

#

it's better

native tide
#

i know you could clone > branc > edit > but how do u pr???

#

how do you upload? you dont own the repo

quick cargo
#

its a weird system

cold haven
#

you get your own copy of the code on the server

native tide
#

o this was some self hosted git server thing?

#

πŸ‘

haughty turtle
#

Best practice in implementing PayPal in Django without the use of libraries outside of Django?

quick cargo
#

How familiar are you with Oauth2

#

i think paypal uses oath atleast

karmic egret
#

Hello, does anyone knows how to upgrade your pandas to the newest version on python anywhere?

quick cargo
#

@karmic egret pip install -U pandas

karmic egret
#

@quick cargo It does not work on python anywhere website

#

the version still shows 0.24

cold haven
#

Get Started
Before you can integrate a PayPal product or solution, you must set up your development environment to get OAuth 2.0 client ID and secret credentials for the sandbox and live environments. You exchange these credentials for an access token that authorizes your REST API calls. To test your web and mobile apps, you create sandbox accounts.

Logging into the Developer Dashboard to get credentials and create sandbox accounts requires a developer, personal, or business account. Each account provides different levels of access to PayPal functionality.

#

this is where I would start

#

Oauth2.0 yeah

quick cargo
#

If you're not massively familiar with Oauth2 Directly i'd probably say to use a 3rd party lib for now

cold haven
#

I have to go. This was fun

#

I'll bbl

#

see you later

quick cargo
#

Its not necessarily hard but its a bit awkward todo if you're not similar with the flow

#

cya

#

@karmic egret do you have a requirements.txt

native tide
#

ew

#

pipfile :^)

karmic egret
#

no, I do not have it.

#

What should I do to add

quick cargo
#

if you dont have one i would worry

#

im not familiar with Python Anywhere so i dont exactly know what you can do

#

you could try force a update

#

doing pip install pandas >= latest.version.here

karmic egret
#

do you know anyother website that will also do the same thing for free?

#

But seems like repl.it does not work anylonger

quick cargo
#

Most things that are free are generally not great

karmic egret
#

I am only doing a student project, so

quick cargo
#

you could try a free google cloud or aws teir

karmic egret
#

could you send me a link.

#

Thanks

deft urchin
#

what is an api request?

cold haven
#

hello

devout coral
#

Does this mean I am not receiving the object back? I used $('#id') to get the object

#
$.each(data.responseJSON, function (key, value) {
                    var id = '#id_' + key;
                    var parent = $(id).parent();
                    var p = $("<p>", {id: "error_1_id_" + key, "class": "invalid-feedback"});
                    var strong = $("<strong>").text(value);

                    console.log($(id));
                    console.log(parent.id);
                    console.log(p);
                    console.log(strong);

                    p.append(strong);
                    parent.append(p);
                    p.show()
                });
#

That is the jQuery

#

It does not seem to be returning a value for the parent

#

Anyone have any idea?

cold haven
#

no idea

#

$.each looks like a for each loop, no?

#

I would convert the response to a json object first. I think you are missing that part

#

you need to make a controller for it.

#

you need it to pass the model logic to the view.

#

@devout coral The reason a controller exists on the client is to convert json string to an object

devout coral
#

@cold haven That is not the issue as it works on another part of the site.

#

Also the response is a json object

cold haven
#

ok

#

I have used jQuery a little bit.

#

I may still have some code somewhere to look on as a reference

#

nope.

#

I deleted it.

devout coral
#

Lol

#

It is ok

#

I just changed how the form was created

cold haven
#

actually I saw that you were using key as a param.

devout coral
#

I think it had something to do with the script that crispy forms uses for file fields when using the crispy tag as opposed to the filters

cold haven
#

you need to use it to reference the each loop

#

key, value

devout coral
#

@cold haven The code I have is working lol. I am pretty sure each is sort of llike a pythin .items on a dict

cold haven
#

The each function will return a set of key, value pairs

devout coral
#

Yes, that is what I have in the code

#

It gets passed to the function

#

Then I use Key and value in the function

cold haven
#

ok, so to get #id would be directly from the dom I believe.

devout coral
#

@cold haven Yes, the selector looks for that element in the dom with the id. However what I think was happening was that this function ran when the element did not exist.

cold haven
#

i see

#

it's working now?

devout coral
#

Not entirely sure tbh but I do know I changed the form definition and it fixed ti

#

Yeah

#

The only issue is it does not look as nice

cold haven
#

oh I might be able to help with it since I'm pretty good at CSS

#

well, bootstrap now

devout coral
cold haven
#

let's see just by looking...

devout coral
#

The ugly one's work. The other one does not

#

Granted it technically isn't even implemented but if it were it would not work

cold haven
#

no, I can't tell. They all look good to me.

#

you may want to put those on 3 separate html files

devout coral
#

Lol the left ones are the ugly ones that do not work. The one on the right is what I wanted but does not work.

#

@cold haven Why?

cold haven
#

well, I would put them on separate pages because one isn't related to the other.

#

I would on submit, submit the form and move on to the next page.

#

but that's just me

devout coral
#

No this is like a import data portal

cold haven
#

ahh

devout coral
#

User clicks on import data

#

Then they are brought there

cold haven
#

oh ok it's a portal

devout coral
#

While we are on the topic of all this, Want to give me some feedback on what I have so far?

cold haven
#

ok sure

#

anyone ever think about making a site like d2jsp.org?

#

forum gold?

devout coral
cold haven
#

it's nice, You might want to just create one search by phone number since everyone has a unique number.

#

then you really wouldn't need to search anything else.

devout coral
#

I see where you are coming from but no one really knows everyone's phone numbers

cold haven
#

you ask for it

#

or is that not an option?

devout coral
#

Well no, I mean if someone were to search it is most likely to get their phone number

#

It is easier to remember a name than the phone number.

cold haven
#

oh alright

devout coral
cold haven
#

the CSS looks nice

devout coral
#

Thanks

cold haven
#

the first row of CSS looks like it's not aligned on the first page

#

maybe I would put that in a drop down or hamburger

devout coral
#

Which row?

cold haven
#

the one where you sort through

#

with all the drop downs

devout coral
#

Oh it is centered aligned.

cold haven
#

I would try a different UI to search

devout coral
#

Yeah, did not know what else to do tbh.

#

Seemed like the most practical

cold haven
#

you could actually put the searching on a sidebar.

#

that's what most sites do

#

that would make it look clean

#

everything else looks pristine

devout coral
#

Thanks, I honestly thought about a sidebar. Just my execution of it was bad lol

#

Could not come up with something that did not look terrible and did not take up too much room

cold haven
#

question

devout coral
#

Yes?

cold haven
#

let me say if I wanted to search a range of employees that work at a company. I could do that?

devout coral
#

As in multiple companies?

cold haven
#

all the employees that work in one company

devout coral
#

Oh yes

cold haven
#

I would do a search on a company then

#

then it would give me a list of all the employees working at that company.

#

that's cool

devout coral
#

Yes the filter company dropdown does just that

haughty turtle
#

@quick cargo @cold haven I'll check into Oath2

#

Better to learn it now then later, shouldn't take to long for me to get a hang of it

devout coral
#

@cold haven On Thursday or Friday I plan to have this deployed and I would like some people to test the site. Would you be willing to be one of my testers?

#

@cold haven The plan is to have some small instructions on what the site is for and how to do a few things. I will also provide some instructions on how to do certain tasks so you have a starting point. Then there will be an optional survey to take to give me some feedback.

humble mirage
#

hello

#

trying to run my app with : gunicorn Appname.wsgi
getting this error :

gunicorn Patent_Trademark_Manager.wsgi.application
[2020-11-03 00:21:01 +0000] [16692] [INFO] Starting gunicorn 20.0.4
[2020-11-03 00:21:01 +0000] [16692] [INFO] Listening at: http://127.0.0.1:8000 (16692)
[2020-11-03 00:21:01 +0000] [16692] [INFO] Using worker: sync
[2020-11-03 00:21:01 +0000] [16695] [INFO] Booting worker with pid: 16695
[2020-11-03 00:21:01 +0000] [16695] [ERROR] Exception in worker process
Traceback (most recent call last):
.....
ModuleNotFoundError: No module named 'Patent_Trademark_Manager'
[2020-11-03 00:21:01 +0000] [16695] [INFO] Worker exiting (pid: 16695)
[2020-11-03 00:21:01 +0000] [16692] [INFO] Shutting down: Master
[2020-11-03 00:21:01 +0000] [16692] [INFO] Reason: Worker failed to boot

I am very confused as to why I am getting this error if I'm only putting in the name of my App.

What am I missing ?

haughty turtle
#
Page not found (404)
Request Method:    GET
Request URL:    http://127.0.0.1:8000/media/image/Clothing.jpg
Using the URLconf defined in BolemVenture.urls, Django tried these URL patterns, in this order:

[name='index']
admin/
The current path, media/image/Clothing.jpg, didn't match any of these.```
#

Storage location is MEDIA_ROOT

#

but I see that it works the same as STATIC_ROOT it creates a folder in the same location... then what am I missing do I need to classify STATIC_ROOT or MEDIA_ROOT in my setting as I do not see it defined in there

#

?

long vale
#

does anyone know a good server for questions about HTML/CSS/JS or is it ok to ask here?

devout coral
#

@long vale Ask here

long vale
#

I want to include a bunch of text on a webpage, but I can't easily serve it from a text file or something because it's on GitHub Pages... Is there any good way to do it without filling like 99% of my HTML file with text?

#

I had an idea to do it in a .js file and make a bunch of variables containing strings, then plop them in as needed

haughty turtle
#

But are you using Django @long vale or Flask?

long vale
#

Nope, so I recognise it's not quite on topic

haughty turtle
#

@devout coral why is my image not being accesed? Do I really need to add it into my urls file? For Static files it not necessary

#

@long vale I mean how would you be gathering this data?

devout coral
#

Did you add the routes for static and media for development ?

long vale
#

I'm just gonna type it, because it's a portfolio site

devout coral
#

@haughty turtle in your urls.py that is

haughty turtle
#

If it's something that you can manually fill in I don't see why it would be a problem to put it in your HTML file, JS is for dynamic content, no reason to place static content in there, as your just going to end up filling the js content with text

#

@long vale so then you are really not resolving anything

quartz crane
#

What

haughty turtle
#

Wrong ping mb

#

A text filled js file would look way worse then a js one

#

Unless you only wanted them served at a certain time and point which then makes it dynamic

#

@devout coral will add it

devout coral
#

Once you do you’ll be good

long vale
#

Ok. I've barely done any HTML before. I have the Python mentality of separating long strings from the logic, but I guess HTML is completely different in many ways

haughty turtle
#

@quick cargo Hmm, but isn't Oath2 a 3rd party package?

waxen mirage
#

is this channel free for a question about DJANGO?

#

Apologies, Just read the rules and how to get help

haughty turtle
#

This isn't a help channel it's a general help channel

#

Ask your question @waxen mirage

waxen mirage
#

Context: I have a running API that pulls data from a website and presents it in a template.html in a django web application. This is one application in a broader project and I now need to add the data preseneted in template.html to my database.
Question: where do I need to look in to django documentation to find the process to add this data from the template.html to my database

swift sky
#

umm

#

trying to do this

#

this portion

#
filename = secure_filename(f.filename)
        f.save(os.path.join(
            app.instance_path, 'photos', filename
        ))
        return redirect(url_for('index'))```
#

f.save(os.path.join( app.instance_path, 'photos', filename ))

warm igloo
#

and what happens

swift sky
#

lmao sry

#

wormhole

#

so

#
    @app.route("/uploadusers", methods=["GET", "POST"])
    @login_required
    def upload_user():
        form = UploadForm()
        print('hi')
        if form.validate_on_submit():
            print('hello')
            f = form.form.data
            print(f)
            filename = secure_filename(f.filename)
            f.save(os.path.join(os.path.join(app.instance_path), 'update_users', filename))
            flash('loaded users')
            return redirect(url_for('upload_user'))
        return render_template('upload_new_user.xhtml')```
#

is my views

#
from flask_wtf import FlaskForm
from flask_uploads import UploadSet, DOCUMENTS
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import SubmitField

document = UploadSet('somestuff', DOCUMENTS)

class UploadForm(FlaskForm):
    file = FileField('File', validators=[FileRequired(), FileAllowed([document, 'Only xlsx files!'])])
    submit = SubmitField('Submit')

#

my form

#

it's not validating on submit

#

like i get no error, but it doesn not print hello only hi

#

any ideas?>

#

nothing appears in my instance file

#

and it's prib cuz it's not validatin

waxen mirage
#

thanks @devout coral

gaunt marlin
#

@swift sky because flask-wtf is an integration if wtforms , i think you can get error(invalid reasons) in your view like so

for fieldName, errorMessages in form.errors.items():
    for err in errorMessages:
#

to check why your form got invalid

swift sky
#

uhh stupid question

#

what do you mean fieldname

#

@swift sky because flask-wtf is an integration if wtforms , i think you can get error(invalid reasons) in your view like so

for fieldName, errorMessages in form.errors.items():
    for err in errorMessages:

@gaunt marlin

#

and where would i place this for loop

#

before or after the validation

gaunt marlin
#

@swift sky before because you already knew that validation failed

swift sky
#

this syntax is kinda weird

gaunt marlin
#

try printing it and see why the validation failed

#

you can use any syntax you want

swift sky
#
    @app.route("/uploadusers", methods=["GET", "POST"])
    @login_required
    def upload_user():
        form = UploadForm()
        print('hi')
        for fieldName, errorMessages in form.errors.items():
            for err in errorMessages:
        if form.validate_on_submit():
            print('hello')
            f = form.form.data
            print(f)
            filename = secure_filename(f.filename)
            f.save(os.path.join(os.path.join(app.instance_path), 'update_users', filename))
            flash('loaded users')
            return redirect(url_for('upload_user'))

        return render_template('upload_new_user.xhtml')```
gaunt marlin
#

actually you missed the print line

#

@swift sky

for fieldName, errorMessages in form.errors.items():
    for err in errorMessages:
       print(err)
swift sky
#

so can you explain what you meant by because flask-wtf is an integration if wtforms

#

oh u mean because it's an integration

#

you believe you can get the error messages by doing xyz

gaunt marlin
#

well yeah it's from their document
Simple integration of Flask and WTForms, including CSRF, file upload, and reCAPTCHA.

swift sky
#

i just didnt understand what you were writting

#

one sec testing

gaunt marlin
#

you current debug process is :

  • you already knew that the validation failed -> now you need to know why the validation failed
swift sky
#

so this

#
            for err in errorMessages:
                print(err)```
#

didnt do anything

gaunt marlin
#

yes

#

oh ok so it doesn't seem to work

swift sky
#

the full view

#
    @app.route("/uploadusers", methods=["GET", "POST"])
    @login_required
    def upload_user():
        form = UploadForm()
        print('hi')
        for fieldName, errorMessages in form.errors.items():
            for err in errorMessages:
                print(err)
        if form.validate_on_submit():
            print('hello')
            f = form.form.data
            print(f)
            filename = secure_filename(f.filename)
            f.save(os.path.join(os.path.join(app.instance_path), 'update_users', filename))
            flash('loaded users')
            return redirect(url_for('upload_user'))

        return render_template('upload_new_user.xhtml')```
gaunt marlin
#

since i can't find any thing related to showing form error in flask-wtf documents

swift sky
#

:/

gaunt marlin
#

let me look ups more about this package

#

@swift sky found it https://hackersandslackers.com/flask-wtforms-forms/#building-forms-in-jinja
this is how you display error in your html template

<div class="form-field">{{ form.email.label }} {{ form.email }}
    {% if form.email.errors %}
        <ul class="errors">
            {% for error in form.email.errors %}
                <li>{{ error }}</li>
            {% endfor %}
        </ul>
    {% endif %}
</div>
Hackers and Slackers

Learn how to build complex form logic in Flask using the WTForms Python library! Cover the backend logic as well as best practices for form Jinja templates.

#

wait

#

let me check

#

you can test if you want

#

oh ok its correct

#

it used flask_wtf

swift sky
#

trying

#

running it now

#

some syntax stuff 1 sec

#

1 sec

#

hmmm

#

yeah dude but this is for just a fileupload field

narrow jasper
#

hey guyz i want to remove hardcoded urls of id in template

<a class="nav-link" href="#contact">Contact Us</a>
gaunt marlin
#

@swift sky the one i posted above just an example for you to implement for your code here what you supposed to write in your templates

<div class="form-field">{{ form.file.label }} {{ form.file }}
    {% if form.file.errors %}
        <ul class="errors">
            {% for error in form.file.errors %}
                <li>{{ error }}</li>
            {% endfor %}
        </ul>
    {% endif %}
</div>
<div class="form-field">{{ form.submit.label }} {{ form.submit }}
    {% if form.submit.errors %}
        <ul class="errors">
            {% for error in form.submit.errors %}
                <li>{{ error }}</li>
            {% endfor %}
        </ul>
    {% endif %}
</div>

again this is an example because i haven't see your templates code but this is what it should be

nimble epoch
#

im using flask class based views but in post method it gives error ""TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement."" but im not sure where is wrong because it seems right to me.

#

class Register(MethodView):
def init(self):
self.form = RegisterForm()
def get(self):
return render_template(
'register.html',
title='Register',
form=self.form
)
def post(self):
if self.form.validate_on_submit():
first_name = form.first_name.data
last_name = form.last_name.data
username = form.username.data
email = form.email.data
password = generate_password_hash(form.password.data)
user = User(first_name=first_name, last_name=last_name, username=username, email=email, password=password)
if form.profile_picture.data:
profile_picture = form.profile_picture.data
filename = secure_filename(profile_picture.filename)
path = os.path.join('C:\Users\Programming\blog\static\profile-pictures', filename)
profile_picture.save(path)
models.session.add(user)
models.session.commit()
return redirect(url_for('login'))

gaunt marlin
#

@nimble epoch you have no return on the else statement of

if self.form.validate_on_submit():
nimble epoch
#

then if i do, it wont return wtforms validation errors. i just tried it.

#

how about using function based views?

#

or is there any solutions?

granite loom
#

please happen to ping me for an answer

gaunt marlin
#

@granite loom # in css is for id attribute, you have class = "main-header" so use .main-header{} instead

granite loom
#

ohh that's for an Id

#

thankyou @gaunt marlin I apprecieate it

gaunt marlin
#

glad to help

static harbor
#

How can I get empName and Their role from this model

class Employee(models.Model):
    empName = models.CharField(max_length=50)

class Role(models.Model):
    roleName=models.CharField(max_length=50)
    description=models.TextField()
    roleReportsTo=models.ForeignKey('self',null=True,on_delete=models.SET_NULL) 


class EmployeeRoleMap(models.Model):
    empId=models.ForeignKey(Employee,on_delete=models.CASCADE)
    roleId=models.ForeignKey(Role,on_delete=models.CASCADE)

I am new to Django that's why I am confused

balmy stag
static harbor
#

@balmy stag I need a field like cuz I have to store start_date and termdate for that intermediary job

like he can manager for start_date to end_date
and ceo for start_date to end_date

#

can you tell how can I quey it?

#
class EmployeeRoleMap(models.Model):
    empId=models.ForeignKey(Employee,on_delete=models.CASCADE)
    roleId=models.ForeignKey(Role,on_delete=models.CASCADE)
    startDate = models.DateField(default=now)
    endDate = models.DateField(null=True, blank = True)
#

something like this

#

also that way I will have history of that employee

balmy stag
static harbor
#

@balmy stag can't we join 3 tables on the basis of their id?

balmy stag
#

You can have a third ForeignKey on your intermediary model and add a UniqueContraint on the three fk to avoid duplicates but I'm not sure if that's what you want to do

primal kernel
#

Anyone acquainted with django object querys could help me with this? thank you πŸ™

https://stackoverflow.com/questions/64662944/django-how-can-i-filter-an-object-filtering-by-another-object-filtered/64663416#64663416

swift sky
#

i got a ```TypeError: can only concatenate str (not "UploadSet") to str

#

probably because of this

#
from flask_wtf import FlaskForm
from flask_uploads import UploadSet, DOCUMENTS
from flask_wtf.file import FileField, FileRequired, FileAllowed
from wtforms import SubmitField

document = UploadSet('somestuff', DOCUMENTS)

class UploadForm(FlaskForm):
    file = FileField('File', validators=[FileRequired(), FileAllowed([document, 'Only xlsx files!'])])
    submit = SubmitField('Submit')```
#

the article you linked didn't deal with file uploads through flask

native tide
#

Django 3 is too easy llol

jolly matrix
#

What is the data type of the data that is sent through a post request?

balmy stag
#

Anyone acquainted with django object querys could help me with this? thank you πŸ™

https://stackoverflow.com/questions/64662944/django-how-can-i-filter-an-object-filtering-by-another-object-filtered/64663416#64663416
@primal kernel I'd set the related_name to "consumptions" in Consumption.client field. (https://docs.djangoproject.com/fr/3.1/ref/models/fields/#django.db.models.ForeignKey.related_name) (I've been taught to almost always set it).
Then you can do Client.objects.filter(consumptions__status='pendant', consumptions__access_date__range=(start_date, end_date)).distinct().count()

primal kernel
#

@primal kernel I'd set the related_name to "consumptions" in Consumption.client field. (https://docs.djangoproject.com/fr/3.1/ref/models/fields/#django.db.models.ForeignKey.related_name) (I've been taught to almost always set it).
Then you can do Client.objects.filter(consumptions__status='pendant', consumptions__access_date__range=(start_date, end_date)).distinct().count()
@balmy stag YEAH! the distinct is what i was missing! thank you sooo much 😘

maiden crag
#

Hello everyone!!

#

I'm new to web development could you guys suggest the best way to learn web development

#

I'm sitting home and really want to gain this skill

balmy stag
haughty turtle
#

The path its pointing to is correct

maiden crag
#

Thanks:)

wanton tulip
#

Hello #web-development , I am working on a REST API in Flask, now I am on a point where I can post json data, but I want to automatically give every json data post an ID, currently I need to give them by hand an ID.. Is there any logical way to automatically give everytime a post an ID? Thanks in advance.

static harbor
#

can I rename the values that I need
for example i.values("id","some_long_name")

this will give json response like
{
"id":1,
"some_long_name":data
}

I want some_long_name to be renamed AS i wasnt

#

@wanton tulip are you saving in a database?

wanton tulip
#

No I am not. Otherwise I could use auto increment. Sorry for not adding @static harbor

#

would you recommend saving it in a DB @static harbor ? Like, how are all the bigger REST API's doing this with JSON data? I have been searching on the internet, but a lot don't use an ID.

warm igloo
#

does it have to be sequential like 1,2,3,4 @wanton tulip ?

#

or just unique?

static harbor
#

@wanton tulip yes definetly save it in DB, because if you
're creating an rest api you need data to save and then post it when needed

warm igloo
#

what do you do with your data if you aren't saving it in a db

if I send your API data where do you store it? If I request data, where do you pull it from?

opaque ermine
#

Hi, I want to deploy my django app on namecheap cpanel. Please help me to learn how to deploy my djanog app

#

Please

ionic idol
#

Hello, can you limit the size of an image in django rest framework without uploading the whole file?

wanton tulip
#

Thanks @static harbor for your reaction, it's helpful.

cold haven
#

hello

wanton tulip
#

Hello!

young oyster
#

How can I have nested data inside my view but not in the serializer in django rest framework? (to reduce db queries).. I have this:```class UserDataSerializer(serializers.ModelSerializer):
transactions = serializers.SerializerMethodField()
class Meta:
model = User
exclude = ('password',)

def get_transactions(self, obj):
    request = self.context['request']
    transaction_objs = Transaction.objects.filter(user=request.user)[0:35]
    return TransactionSerializer(transaction_objs, many=True).data```Transactions model: ```class Transaction(models.Model):
user = models.ForeignKey(User, related_name='transactions', on_delete=models.DO_NOTHING)
//other fields...``` but of course is querying multiple times, I want to use prefetch_related an select_related with all my foreign/manytomany fields is this possible?
devout coral
#

Anyone here ever used Sphinx for documentation of a django project?

opaque ermine
#

How I link my django app with cpanel postgresql?

cold socket
#

What's easier to setup and use, uWSGI or Gunicorn?

sturdy pike
#

my opinion Gunicorn

#

@opaque ermine Cpanel?

opaque ermine
#

Like I’m using namecheap to up my django app so how I connect postgres with it?

grizzled sand
#

Hey everyone! Could someone explain what does means and how it use.

STATICFILES_DIRS = [
   # ...
   ("PREFIX", "staticfiles"),
]``` 
**Prefixes (optional)** 

I've tried use how it said in Django documentation. but it hasn't any difference. 

As i understand that should create extra folder inside STATIC_ROOT directory as 'PREFIX' but it doesn't 

Where do i wrong?
Thanks
devout coral
#

@grizzled sand What this basically does is tell Django where any other static directories are. So as the Django documentation states you can do something like:

STATICFILES_DIRS = [
    "/home/special.polls.com/polls/static",
    "/home/polls.com/polls/static",
    "/opt/webfiles/common",
]

Which will tell dajngo that you have some static directories at those locations for when you run the collectstatic command those can be included. If you want additional organization you can provide a prefix for all these files. Following the previous example if I did.

STATICFILES_DIRS = [
    ("downloads", "/opt/webfiles/stats"),
]

Once you run collectstatic it will put all the files inside of that stats directory into static but now it will put it in a directory called downloads.

Does this all make sense?

cold haven
#

hello

ruby palm
#

Hello!

#

Got a simple question

#

I'm using Flask

#

See when you click on a link and then automatically a jpg file starts downloading?

#

How do I do that?

cold haven
#

I want to learn Django

ruby palm
#

Thank you very much beforehand :)

cold haven
#

I have no idea.

#

I would like to learn this as well.

cold haven
#

does anyone know how to create a pipeline to write to a file in Django?

grizzled sand
#

@devout coral
Yeah but in my case when I try use prefix, it doesn't create any sub directory like downloads in example.

Django just collect all into one folder

devout coral
#

@grizzled sand Interesting. Can I see the settings you have

#

Also, if you do not mind your directory tree for the project.

cold haven
#

hi @devout coral

#

good evening

devout coral
#

Good Evening

night spoke
#

Hi, anyone know if there's a simple way to handle this scenario in django... let's say model A needs to also have 3 + of model B pointing to model A before users can take some action. model form is great but it doesn't allow this behavior, from what I understand.

toxic flame
#

OneToManyFields

#

Or you can make the Model B have a foreignKey to the Model A and make.it run a query to check if there are any pointing at Model A before running any

night spoke
#

I think I understand how that is supposed to work, but I don't know how to make them one combined form on creation

grizzled sand
#

@devout coral okay it was my foul i didn't set sub dir for path.

Extra places for collectstatic to find static files.

STATICFILES_DIRS = [
    ("my_app1", os.path.join(BASE_DIR, 'my_app1/static')),
]

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

But anyway with this settings I am getting two copy of my static files from my_app1, one in root 'staticfiles' folder and second one in 'staticfiles/my_app1/'

So as i understand prefixes doesn't work properly with static folded my_ app?

#

Sorry already off system, but tree someting like that.
project/
-my_app/static/css
-django_project/settings.py
-staticfiles

devout coral
#

@grizzled sand so everything is good now right?

night spoke
#

I guess my question is, can I have say, modelA form and 3x modelB forms at the same time, and submit them all as one post?

#

(still django)

cold haven
#

hi @night spoke. If I know anything about this. I would say it is best to bind a specific form to one database query.

#

I would separate them into different objects

#

or components

night spoke
#

that's what i'd like to do, some sort of post containing form A, and 3 form B's, but I don't really know if django has some easy way of doing that

cold haven
#

I don't know because I have never used Django's built in ORM

#

I would like to learn more on this too.

#

Sounds like you want to run a one to many or many to many query

#

you can do it in the Django built-in ORM i'm sure.

night spoke
#

For now, I can certainly perform these actions independent of each other.

next tree
#

anyone knowing docker, i am trying to understand the COPY command in the dockerfile.

#

if the root folder of my app is backend, and I want to copy the contents into the container, I can just do COPY backend conatinerFolderName?

cold haven
#

I thought Django sets up a coding environment by default so that Docker isn't even needed

warm igloo
#

hold up, I'm wrong --- EDITED

#

I had it backwards. By default it just copies contents. So you're correct, you just do COPY backend containerFolderName and the contents of your local backend folder will be copied to the container.

#

Sorry, had rsync on my mind and I've forgotten way too many / and had it not do what I was expecting.