#web-development

2 messages ยท Page 111 of 1

native tide
#

any solution for extends ?

#

or humanize?

devout coral
#

@native tide There is no real built-in way to do this unless you want to write your own template loader function. With that said however I do not see any benefit in doing something like this. Other django developers are used to this convention will be expecting it and will make things easier for the next person reading it since it is explicit.

#

@native tide Did you have a question?

#

I personally have not used it so I cannot have a very good opinion. Maybe someone else here can.

late gale
devout coral
#

@late gale Lets give it a try.

late gale
#

?

devout coral
#

You are using crispy forms correct?

late gale
#

yes

devout coral
#

using the |as_crispy_field filter right?

late gale
#

yes

devout coral
#

Cool, are you passing it the entire form?

#

Or a specific field?

late gale
#

entire form

#

each input has |as_crispy_field| so i can organize them

devout coral
#

Yeah that is the problem. If you want crispy forms to render your entire form for you then use the crispy tag. If you want to have your individual fields to organize them yourself then you need to use |as_crispy_field and pass it each field you want to display with the crispy forms css/js

late gale
#

yes i want that to display with each field

#

srry

#

so i can add css and javasript yes

devout coral
#

Cool, no need to be sorry. Do you understand how to sort of do it now?

#

Yes, you could add css and js to if you want.

late gale
#

yea i sorted just between an open div tag and close i add the field with the crispy field with it

devout coral
#

Yep, and ensuring you pass a field as opposed to the entire form will get rid of that pesky error you were getting.

late gale
#

still i dont know what i do wrong

#

did u look at the html ?

#

there

lavish prismBOT
#

Hey @late gale!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

devout coral
#

No, did you post the HTML?

late gale
#

there

#

yes i did

devout coral
#

Where is it?

late gale
#

there

devout coral
#

Thanks

#

You are receiving the same error?

late gale
#

yes

#

although it was working very perfectly and i didnt even touch it

devout coral
#

Could I see the error again?

late gale
#

sure

devout coral
#

Alright, so let the debugging begin.

Go ahead an comment out every single field but the first one please

late gale
#

you mean i comment every field and run the server and see if thats working ?

gaunt marlin
#

i think boundfield is in django.forms, not in django.forms.forms

late gale
#

i cant find find boundfield

#

there is no bound field in my models or forms.py in all apps lol

gaunt marlin
#

oh ok then forget what i said

late gale
#

programming is hilarious

devout coral
#

Have you tried commenting all the fields but one?

late gale
#

i am trying now

#

wait

devout coral
#

Ok

late gale
#

ok i commented the whole form

#

and the error didnt remove

#

so i believe the error doesnt come from the template

#

wait

#

yea no change

#

so the error is not in the template file

devout coral
#

Ok cool

stable kite
#

@late gale your error is in your form not in template

native tide
#

Yea but django.forms.forms doesnt have that

#

Rught

devout coral
#

So put it back to normal. and lets go look at your views really quick (granted the issue is probably in forms but better safe than sorry)

native tide
#

Shouldn't it be django.forms

late gale
#

@native tide ik i swear but i dont even have boundfield

#
from django import forms
from django.contrib.auth.models import User 
from django.contrib.auth.forms import UserCreationForm
from .models import Profile

class UserRegisterForm(UserCreationForm):
    email = forms.EmailField()
    class Meta:
        model = User
        fields = ['username', 'email','password1', 'password2']


# USER UPDATE FORM!!
class UserUpdateForm(forms.ModelForm):
    email = forms.EmailField()
    class Meta:
        model = User
        fields = ['username', 'email']

#PROFILE UPDATE FORM
class ProfileUpdateForm(forms.ModelForm):
    Committees = (
        ('IT','IT'),
        ('Design','Design'),
        ('ER','ER'),
        ('Design','Design'),
        ('Marketing','Marketing'),
        ('Coaching','Coaching'),
        ('Media','Media'),
        ('Branding','Branding'),
    )
    committee = forms.ChoiceField(choices=Committees, required=False)    


    class Meta:
        model = Profile
        fields = ['bio', 'image', 'position' ,'committee', 'achievement','awards', 'experience']
#

ok gonna show u my views

#
@login_required
def update_profile(request):
    for userp in User.objects.all():
        try:
            u = userp.profile
        except ObjectDoesNotExist:
            u = Profile.objects.create(user=userp)


    if request.method == 'POST':
        user_form = UserUpdateForm(request.POST, instance=request.user)
        profile_form = ProfileUpdateForm(
            request.POST, 
            request.FILES,
            instance=request.user.profile,
            )
        if user_form.is_valid() and profile_form.is_valid():
            user_form.save()
            profile_form.save()
            return redirect('/profile')

        
    else:
        user_form = UserUpdateForm(instance=request.user)
        profile_form = ProfileUpdateForm(instance=request.user.profile)

    context = {
        'user_form': user_form,
        'profile_form': profile_form,
        'title' : 'Editting Profile'
        }

    return render(request, 'users/update_profile.html', context)

Views

#

there

#

thats the part where django refers to the url

#

and thats all the import things

from django.shortcuts import render , redirect
from django.contrib import messages
from .forms import UserRegisterForm , UserUpdateForm, ProfileUpdateForm
from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.models import User 
from .models import Profile
from django.core.mail import send_mail ,EmailMessage
from django.template.loader import render_to_string
from django.conf import settings
from .token_generator import activation_token
from django.contrib.sites.shortcuts import get_current_site
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from django.utils.encoding import force_bytes, force_text
from django.contrib.auth import login, authenticate
native tide
#

@late gale you're using crispy forms?

late gale
#

yes

#

i hope we can fix this error

#

idk why this error refers to a thing that doesnt exist in my code

#

its like my computer wants to make an error without even know why

#

lol

stable kite
#

@late gale the error is not in your code it is in crispy forms i think so

late gale
#

maybe it needs an update

#

let me see

devout coral
#

Well you would not get the error unless you used the filter tag. So I am not sure why you are still receiving the error. Try commenting out the include for the crispy filter.

late gale
#

ok

gaunt marlin
#

they fixed it by updating crispy form

late gale
#

as i said

#

let me try now

gaunt marlin
#

are you using conda to manage your package ?

late gale
#

nope

#

i am using pip

gaunt marlin
#

oh ok

late gale
#

pip install django-crispy-forms should i update it by this?

gaunt marlin
#

pip show django-crispy-forms to show which version you have first

devout coral
#

do a quick pip show django and pip show django-crispy-forms

late gale
#

k

#

django version 3.1.3

#

the latest cool

#

the cirspy forms

#

version is

#

1.8.1

gaunt marlin
#

from crispy form django
django-crispy-forms supports Django 2.2, 3.0 and 3.1 with Python 3.5+. Note: Django 3.1 requires `django-crispy-forms` version 1.9 or higher.

devout coral
#

Yeah update to 1.9.2

gaunt marlin
#

yeah you need to update

late gale
#

using this pip install django-crispy-forms

#

?

#

right?

devout coral
#

That should install the latest but just to be sure do pip install django-crispy-forms==1.9.2

late gale
#

ok

gaunt marlin
#
``` will update your package to latest version too btw
late gale
#

cool let me try now

#

omg

#

it worked

#

xDDDDDD

#

Thank you all of you

#

so it was that thing

#

stupid packages

devout coral
#

How long have you been working on this project

#

Did you upgrade Django recently or something? Just seems odd this happens out of the blue.

late gale
#

like 5 months i believe and even more

#

yea i just upgraded recently

#

didnt believe that packages need to be updated too

#

lol

#

silly me

gaunt marlin
#

for development i recommend not using the latest version of your django, as latest version would sometime required other packages to update their package to support latest django version too

late gale
#

how to know if a package need to be updated

#

without getting into errors

#

and yea thank you as well

gaunt marlin
#

you could use a package manager

late gale
#

you too @devout coral

gaunt marlin
#

like pipfile

#

in pipenv

#

because everytime you update pipfile other package get updated too

late gale
#

can conda update them as wel

gaunt marlin
#

i don't used conda, i used it once and stop using it XD

#

i just use pipenv or poetry for packages managers XD

late gale
#

but most ppl seems to say

#

DOWNLOAD ANACONDAA

#

its perfect for python

#

and it seems its not

gaunt marlin
#

nothing is perfect, based on people opinions

late gale
#

how to use pipenv or poetry then

#

i download them and ?

#

thats it

#

?

gaunt marlin
#

those should have documents on how to use

late gale
#

oh thank you

#

what do u recommend and easier to use

#

poetry or pipenv

gaunt marlin
#

poetry is newer, but i'm not familiar with. Pipenv is easier to use for me

#

just install pip env and go into a folder type pipenv shell in terminal

#

it will auto create virtual env for you

late gale
#

great let me try it now

gaunt marlin
#

but still better to follow pipenv document

late gale
#

i will

#

i installed it now

#

let me try to use it

devout coral
late gale
#

the latest

#

3.1.3

#

mine

#

it looks cool

devout coral
#

That is so weird. I just updated too, not used to it.

late gale
#

yea same

#

u can customize ur admin page

gaunt marlin
#

3.1 @devout coral

devout coral
#

Granted I am going to replace my admin page soonish so I will just leave it.

late gale
#

i had 3.1.2 and didnt see that change

devout coral
#

Well I have 3.1.1

late gale
#

so it is 3.1 +

#

then

#

and wait

#

u can change ur admin page ?

devout coral
#

Yes

devout coral
#

You can overwrite the admin templates.

late gale
#

how so

#

i just saw a youtube link of that

#

but believed that was fake

gaunt marlin
#

you can override it

#

django document has a section about overriding admin templates

late gale
#

let me see

devout coral
#

Yeah, so just go into the venv to find all the template names and pick which one's you want to override. From there in the django projects template directory you can make a folder called admin and put whatever templates you decide to override.

gaunt marlin
late gale
#

if my admin page is like this

#

i will die proud

#

xDD

devout coral
#

Yeah there is a few packages out there to do that. However, you probably want to just have it styled to what your page normally looks like so users do not feel a disconnection when going to the admin page.

late gale
#

baton package has a tour

#

lol

#

and also seeing google analytics is super helpful

#

in admin page

gaunt marlin
#

it's all javascript

late gale
#

instead of having it on another link

#

yea @gaunt marlin

devout coral
#

Also, to not violate the django license I believe you need to at minimun remove/replace the text that says Django administration.

gaunt marlin
#

@devout coral really? where does it mention D: ?

late gale
#

I renamed it

#

to my website name

#

are all these charts working or just javascript

#

like if a user viewed my website will these charts changes

#

or just a look

stable kite
#

@devout coral do you use any cryptography for storing data in databse with django?

devout coral
#

@gaunt marlin It does not explicitly mention it anywhere but by reading their license I get that.

#

@stable kite Nope

stable kite
#

@devout coral ok because i created one

devout coral
#

@stable kite Created a what?

gaunt marlin
stable kite
#

@devout coral a django app that uses cryptography to store & retrive data

gaunt marlin
#

oh i also made a hash data system before, but it's for a project so i didn't make it a package

stable kite
#

@gaunt marlin i did'nt use django-cryptography because it does'nt allow us to filter data

gaunt marlin
#

yeah crypting data have trouble with searching for it in database

#

because hash data are randomly hashed

stable kite
#

yes but in my one you can do that also

gaunt marlin
#

you use key pair crypting way ?

#

like 1 key to 1 data

stable kite
#

you use key pair crypting way ?
@gaunt marlin no

gaunt marlin
#

or just 1 key for all data ?

stable kite
#

or just 1 key for all data ?
@gaunt marlin yes

gaunt marlin
#

oh cool i would check it out

stable kite
gaunt marlin
#

my previous system don't have the search system because i can't filter on it

stable kite
#

my previous system don't have the search system because i can't filter on it
@gaunt marlin that's why i created my own

gaunt marlin
#

nice

#

i gave it a star

stable kite
#

@gaunt marlin thanks

#

@gaunt marlin do you think i should make JSON &CSV field also?

#

because i don't think many people use it

gaunt marlin
#

json field i think maybe, but it's only if people use postgresql

stable kite
#

ok

devout coral
#

@stable kite Very cool.

stable kite
#

@devout coral what?

devout coral
#

The package. I responded late because I stepped away from my computer. I am at work so yeah.

stable kite
#

ok

gaunt marlin
#

@stable kite suggestion maybe add a function to decrypt and encrypt data too

stable kite
#

@gaunt marlin which string?

gaunt marlin
#

mistype i mean data

stable kite
#

what data?

gaunt marlin
#

any type like string, integer

#

take arg of those

#

and can encrypt it

stable kite
#

ok but i think you mean not to store it in database

gaunt marlin
#

yeah

#

just return the encrypted string or decrypted string

stable kite
#

ok but you can do that easily

#

with lot's of packages

gaunt marlin
#

it's just a suggestion

vernal furnace
#

yo

#

I have some concerns

stable kite
#

it's just a suggestion
@gaunt marlin ok i will think on it

vernal furnace
#

So I'm making a website with Django, but later on I want to turn the same website to an app on Android

#

Is it possible to use the same code or..?

stable kite
#

@vernal furnace you can use react as frontend if you want to do so

vernal furnace
#

What is that

#

react.js?

stable kite
#

@vernal furnace because django is backend & do stuff related to server

#

yes react.js or react native

vernal furnace
#

lol I suck at java

#

wait so I have to redo everything from scratch

#

?

#

ohh

#

So I can turn my website to an application but that will cost me performance

modest shale
#

guys

#

i need help

#

I wanna learn python authentication

#

can u help me

stable kite
#

guys
@modest shale what type of authentication?

modest shale
#

umm

#

web application

#

signup

#

login

stable kite
#

ya but we have different authentication method so which one?

modest shale
#

which one ?

#

sorry i'm new for web development

#

im learning flask

stable kite
#

like session based,token based, jwt based ?

modest shale
#

session based

stable kite
#

i don't know about flask as i use django sorry

modest shale
#

oh...

#

thank you :3

stable kite
modest shale
#

Ou thank you again

#

dudddd

#

im looking this btw

#

but i get the

#

internal server error

#

hell...

stable kite
#

paste your error and code someone who know flask will help you

modest shale
#

i cant paste

stable kite
#

why?

modest shale
#

internal server error not showing my error

#

just shows 'internal server error'

#

i must do debug

devout coral
#

@modest shale You deployed using apache2?

modest shale
#

what is that

devout coral
#

How did you deploy your application?

#

Or are you still running this locally?

modest shale
#

im usin localhost

#

am i getting wrong ?

devout coral
#

You are not getting anything in your terminal?

modest shale
#

nope

devout coral
#

When you get the error I mean

modest shale
#

just code

#

oh

#

im getting error at the sign up page

#

im entering email

#

name

#

and pass

#

and clicking enter

#

BOM

#

Internal server error

#

I- I dont know the error

#

cuz im new at the web programming

#

and i wanna learn authentication

nimble epoch
#

@modest shale what framework youre using? or you want to choose?

modest shale
#

Flask framework

nimble epoch
#

still need help with auth?

#

@modest shale?

modest shale
#

still need help with auth?
@nimble epoch yes

#

im stucked

#

cant fixing error

nimble epoch
#

so you need some extensions like flask_sqlalchemy(for storing the data in the database) and flaask_login(to login the user)

#

whats the error?

modest shale
#

so you need some extensions like flask_sqlalchemy(for storing the data in the database) and flaask_login(to login the user)
@nimble epoch i did that

nimble epoch
#

ok i got it whats the error?

modest shale
#

my error at the signup page

#

im entering email, name, password

#

and clicking enter

nimble epoch
#

ok...

modest shale
#

getting Internal server error

#

:c

#

and i cant create any table at the database

#

maybe this is the problem

#

?

nimble epoch
#

you using sqlalchemy?

#

for database right?

modest shale
#

yes

#

yes !

#

sorry for late answer

nimble epoch
#

no problem, did you do something like db.create_all() command because maybe it couldnt find the database

modest shale
#

hm

#

you maybe right

#

cuz i have'nt any table

proper owl
#

include code please, it is guessing game

nimble epoch
#

ok to make sure do a query on the use table

modest shale
#

listen guys

#

hold on

nimble epoch
#

ok to make sure do a query on the use table
Sorry i meant User table

modest shale
#

from project import db, create_app

nimble epoch
#

just db

#

then db.create_all()

modest shale
#

db.create_all(app=create_app()) (pass the create_app result so Flask-SQLAlchemy gets the configuration.)

#

look at this

#

i writed this = db.create_all(app=create_app())

nimble epoch
#

no passing nesaccery

#

just create_all()

modest shale
#

oookay -,+

nimble epoch
#

๐Ÿ‘

proper owl
#

I am trying to save session variables from being deleted on server reboot or session close. Can I use pickle to serialize it and save to database? Bad/good idea?

nimble epoch
#

@proper owl sorry havent used pickle

proper owl
#

@nimble epoch have you ever tried to save session like that?

#

i just have that pickle idea, not sure what else is possible

nimble epoch
#

somethin like session['username']????

proper owl
#

more complex

nimble epoch
#

what you mean cause i dont use session myself i do it using flask_login

modest shale
#

guys !

nimble epoch
#

yep?

modest shale
#

i get new error

#

haha...

#

sorry

#

:(

#

but i want to fix my problems

nimble epoch
#

its ok

#

just whats that?

modest shale
#

i wrote 'flask run' to cmd

#

and i get this

#

hold on

#

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

proper owl
#

why cant you just paste code?

nimble epoch
modest shale
#

i writed

#

(venv) C:\Users\Cireael\Desktop\code\blog>set FLASK_APP =project

(venv) C:\Users\Cireael\Desktop\code\blog>set FLASK_DEBUG = 1

nimble epoch
#

no probably not because the error occures when you havent

#

ok ok wait

modest shale
#

?

nimble epoch
#

instead of doing this...

modest shale
#

w-what ?

nimble epoch
#

in your file where you have the app veriable type if name == 'main': app.run()

modest shale
#

im curious

spare marsh
#

0-o

mental prawn
#

is there any free and easy use website to learn and code a website?

modest shale
#

but im using lot of file

#

...

nimble epoch
#

so find it where you have the flask app var @modest shale

modest shale
#

ohoh, okay

nimble epoch
#

is there any free and easy use website to learn and code a website?
@mental prawn like what html css javascript??

mental prawn
#

python

modest shale
#

is there any free and easy use website to learn and code a website?
@mental prawn i was do the learn at youtube

nimble epoch
#

flask or django @mental prawn ?

modest shale
#

my advice watch youtube first

#

:3

mental prawn
#

cuz i know the basics of python so i want to use my knowledge to do a website

#

flask or django @mental prawn ?
@nimble epoch not sure

nimble epoch
#

flask is for beginners mostly but you can do a lot of thing with that and django is another popular one

mental prawn
#

which one is easy, free to use?

nimble epoch
#

both are free

#

and flask is easier

mental prawn
#

i heard that django is difficult to use

#

but flask is a bit easy for begginers

#

thank you for your help

nimble epoch
#

and if you need any resources i recommend...

#

or

#

@modest shale fixed it?

mental prawn
#

Thanks alot

nimble epoch
#

@mental prawn yw

modest shale
#

im trying

nimble epoch
#

๐Ÿ˜† bro its just a file

mental prawn
#

my advice watch youtube first
@modest shale do you have any videos you recommend?

modest shale
#

wait i will send u at dm

mental prawn
#

ok

modest shale
#

@nimble epoch I did that

#

problem solved

nimble epoch
#

ok

#

good

modest shale
#

thanks #_#

narrow jasper
#

guyz i have question regarding django forms

#

can anyone help me with it

#

i have template with form

#

with two submit buttons for different purposes

#

both requires post data for calculation

#

so how do i differentiate it

stable kite
devout coral
#

I would say yes for JSON and hold out on csv until someone requests it unless you have spare time. Won't hurt to have but I do not think it is essential.

near bison
#

guyz i have question regarding django forms
@narrow jasper a way is to have different values for each submit button and check what the value of button is in the view.

#
<input type="submit" name="calc" value="add">
<input type="submit" name="calc'" value="sub">

do this and check what the value of calc is in the view @narrow jasper

toxic flame
#

how do I homehost django sites

native tide
#

Do I have to get an error when I open a local link

#

It says

#

dial tcp [::1]:80: connectex: No connection could be made because the target machine actively refused it.

#

When I open a localhost

obtuse lion
#

a

full steppe
swift sky
#

any tips on integrating slack channels into a webapp

#

i need to build some chatrooms for some staff to communicate in

toxic flame
#

yes make seperate applications and merge them

tardy heron
#

In Flask and with flask-jwt-extended how do i get JTI of a JWT outside of the method handling that endpoint/http method? Without app.app_context it says no context, but if i do with that, i get an empty jwt ๐Ÿ˜„

rancid juniper
#

Hello people I set-up a django signal following the tutorial video of Corey Schafer to create profiles when a user registered. I checked the documents too everything seems fine and development servers runes no error. But when I register a new user the signal does not create a profile model

#

what could be wrong

#

okey guys I fixed it myself add the appconfig to the settings.installed apps properly lol :7

native tide
#

how do I reset my main.py file everytime my json file is edited?

#

I'm using flask

tardy heron
native tide
#

I'll check

#

@tardy heron I already do app.extra_files=['./json/data.json']

#

but that doesn't work

#

so idk

tardy heron
#

me neither :]

native tide
#

Guys

#

Can I get help from here?

#

Please someone say yes

#

@native tide I can try to help maybe

warm igloo
#

@native tide Instead of asking for help or asking to ask, just like .. ask

#

state the problem, we'll see if we can help

native tide
#

Okay it's just because this

#

do you know what's ngrok?

warm igloo
#

yes

warm igloo
#

I don't use it anymore but yes

native tide
#

I'm having same problem as the link I sent

#

error 502 bad getway

warm igloo
#

do you know your service is running

native tide
#

What do you mean

#

I'm new to it

#

Please don't be angry

#

Just try and understand

warm igloo
#

not angry, did I come off like that?

#

So, you wrote a python app running on a port of some sort (let's say 5000).

Flask? Django? Let's start there so I can help more.

#

Here's how ngrok works with one of those:

  1. I make a Flask app that listens on port 5000
  2. I use ngrok to do their port forwarding magic so that http://blahblahblah.ngrok.io forward internet traffic to my localhost:5000

If you don't know #1, #2 isn't forwarding anything.

native tide
#

Look,

#

I use ngrok

warm igloo
#

sure

native tide
#

I'm making a collaborative note taking app. But I just want to know which would be a better idea...

On the dashboard, there is a sidebar which lists the notebooks linked with a user's account. Once they select a notebook, it will show the notes associated with that notebook.

Should these notes be rendered in the same sidebar? Or should they be rendered in an adjacent div?

I'm thinking of rendering the notes in the same sidebar, and removing the notepads once something is selected.

onyx crane
#

I think you're more concerned about design decisions. As far as im concerned this is more about technical questions

swift sky
#

yes make seperate applications and merge them
@toxic flame was this in response to me

onyx crane
#

Django Channels:
All tutorials and blogposts always put Django with Docker and Redis. Is there a particular reason for that or is it possible to use django channels without it ?

civic kiln
#

hi guys need some help here

#

Briefly select two transaction handling criteria that they may want to evaluate in selecting the appropriate RDBMS, and provide a comparison of how Oracle and PostgreSQL support these features

i found some answers but not sure, the first one is ACID
A- Atomicity
C - Consistency
I - Isolation
D - Durability

the second answer is from my notes
Backup, checkpoint and recovery facilities
โ€“Database log facilities
โ€“Concurrency methods and granularity
โ€“Deadlock resolution strategies
โ€“Advanced transaction management
โ€“Parallel/distributed query processing

#

thats the question ๐Ÿ‘† but dont know how to compare, im not getting the answers

#

anyone willing to help

onyx crane
#

anyone willing to help
@civic kiln Go to #databases pls.

nova shadow
#

Is it possible to update a flask blueprint without restating the whole application?

native tide
#

Hi, so i am using this to make animation on button click. However the button can only be clicked once. The second time the animation doesn't appear.
Its because the clicked class is added to the button, if this is removed then it can be clicked again? How could i change it so i can achieve this?
https://codepen.io/MinzCode/pen/pogqVVX

mint folio
#

You can always remove a class, from an element, which would fix that.

native tide
#

yo

#

is it a way to see how much percentage an action in django has taken?

#

and send it back to frontend?

#

example this is started with a put request

#

---->Last visit for 195506055044 remain at 2019-12-13 00:00:00+01:12, with 9.328641413095976% done

#

how can i get the 9.3

#

alright thanks

#

@native tide is your output like this each time?

#

like same format?

#

@native tide DRF and return JSON I guess

wanton tulip
#

Hello #web-development , I got a question relating to "cursor.execute()". I think I am a little stuck over here: cur.execute("SELECT id FROM persons WHERE id LIKE (?)", (id)) I've seen a lot of examples online, where they show something with the question mark and with the percentages like: (%id) although I can't get my head around it.. Can someone please give me the right directions on what I do wrong? Thanks in advance.

mellow granite
#

(id,) ?

wanton tulip
#

Hello, @mellow granite I am sorry, I don't understand your answer.

mint folio
#

@wanton tulip It's known as a parameterised query. It's a way of pre compiling the SQL statement so that all you need to supply is the parameters. It protects from things like SQL injection too. So the ? is just a placeholder for the parameter that you will pass there. There's more to it that this but that's the basic for this channel.

mellow granite
#

Hey I think you should put a comma after the id in parantheses

wanton tulip
#

Oh yes, thats what I read, because of injections and stuff. @mint folio Thanks for your wide answer.

#

@mellow granite But If I dont add any more, why would I need a comma? If id is the only value?

mint folio
#

And try your query like this:
cur.execute("SELECT id FROM persons where id like ?", ('%'+id+'%',))

#

You add the comma because the function expects you to pass a tuple

mellow granite
#

I don't really remember the reason, sorry

#

Oh yeah !

mint folio
#

(123) is an integer whereas (123,) is a tuple of 1 element.

#

This way the placeholder ? can be replaced with the first element of this tuple

wanton tulip
#

aahh! Thank you very much for your example code and answer. So this would be the most secure way of using it, right?

mint folio
#

Secure from SQL injections yes

native tide
#

Can you guys please let me know in what situations you would use raw SQL (like that), rather than an ORM?

wanton tulip
#

I don't know why, but the ('%'+id+'%',) part looks a bit cumbersome.. Am I right? Or are there other solutions for?

mint folio
#

@native tide If you use a mixture of Orms and raw SQL, then generally the raw SQL will be used for when you want better performance from certain queries.

native tide
#

Ah okay

#

Does working with raw SQL help you learn specific DBs, like postgres?

mint folio
#

SQL is just query language, to be used with databases

#

Will it help? It will definitely make you understand more on how they work.

native tide
#

Yea I guess that was what I was going for. Alright, thanks for that. I'll do some internal debating...

quick cargo
#

Tbf most orms now can write faster sql than most devs who don't actively work in it

#

Sure you can write raw sql to apply indexes and the likes but equally you can set that up on le orm as well if you're a orm user

native tide
#

I need help

#

Someone understand in port?

#

and ngrok

wanton tulip
#

@mint folio Hello, by using your example it's returning this example cur.execute("SELECT id FROM persons where id like ?", ('%'+id+'%',)) TypeError: can only concatenate str (not "int") to str What does he see as an int here?

mint folio
#

Then your id is an integer so you must convert it to a string

wanton tulip
#

Oh.. ofcourse! haha sorry..

mint folio
#

Cast it to string

#

str(id)

wanton tulip
#

Thank you! ๐Ÿ™‚

torpid pecan
#

What is the best way to deploy a Django server?

#

Can u use something like blue host?

devout coral
#

@torpid pecan Yes, blue host should work.

native tide
#

Am I the only one that people dont answer my questions..

acoustic oyster
#

I do not see your question

#

@native tide feel free to ask your question. It looks like you asked if someone knows a specific tech, if you have a question about web dev, feel free to ask it here.

native tide
#

ngrok

#

Do you understand on it

#

I mean I made a localhost link using a port, but now the link is stuck on that port forever

#

I want to change the link from that port

#

Like for example

#

This port contains a link, but this link is stuck on port 4444 forever

#

I want to change that link from the port

acoustic oyster
native tide
#

What do you mean?

acoustic oyster
#

If you are already running ngrok on one port, you need to restart and change the port.

native tide
#

Yes, how to change it is the question

acoustic oyster
#

The article i sent shows how to set up a config file

native tide
#

Yes I'm following it

#

Or the command is ngrok http <your port here> to run it using http on a specified port. https://ngrok.com/docs
@acoustic oyster This is not my problem, my problem is that I want to make a HTML file listen to the port

acoustic oyster
#

I am not familiar with ngrok, to make your html listen to a port and accept events, I would use some sort of backend, such as Express.JS or django/flask

native tide
#

flask

#

yes

#

But how exactly..?

acoustic oyster
#

Are you using flask?

native tide
#

It's actually coded in bash

acoustic oyster
#

I am confused. Are you trying to change the port ngrok is running on? Or you are trying to point it towards a web app you have?

native tide
#

I'm trying to change the port that the code port

acoustic oyster
#

Well, if you programmed your webserver, you should have specified what port it is listening on. Then you would run ngrok with whatever port your webserver is listening on. From what I can see from the docs.

native tide
#

So it's specified inside the script?

acoustic oyster
#

Your webapp/webserver should be listening on a specific port that you probably would have to specify, depending on what framework you may be using, that port may be automatic and may vary

native tide
#

Can I change the port?

acoustic oyster
#

You should be able to. It should depend on your webserver/app. I am not sure what stack you are using though.

native tide
#

Inside the script?

acoustic oyster
#

I am not sure.

Typically you would use environment variables and specify the port when you run your webserver.

The default ports are 80 for http and 443 for https

#

What are you using as a webserver?

native tide
#

can I type netstat

#

to check what port its listening?

acoustic oyster
#

Hmmm, I think netstat may show that. You should really be specifying in your server.

What webserver are you using?

#

I.e nginx, apache, gunicorn?

native tide
#

ngnix i think

#

no listening

acoustic oyster
#

Well, you need to configure nginx to listen to ports 80 and 443. As well as setting up your firewall to give permissions.

It sounds like you just want to host static html, so you need to tell nginx where to find those static files and you probably need a config for them.

You would be better off following a tutorial for this.

native tide
#

Look, it's already listening to the port

#

but i need more HTML links to listen to the port too

acoustic oyster
#

Well, html does not "listen to a port"

Servers listen on a port to redirect traffic to html.

#

So in order to add html, you just need to add more html files whereever you need them

native tide
#

I already have them

acoustic oyster
#

If you already have the webserver setup and serving html where you expect it, then you just need to use "hrefs" to link to other html, or manually enter the path into the browser to see a complete website.

native tide
#

If you already have the webserver setup and serving html where you expect it, then you just need to use "hrefs" to link to other html, or manually enter the path into the browser to see a complete website.
@acoustic oyster But HTML Doesn't load pictures..

#

And stuff like that

#

How can I make HTML load pictures?

#

How I can make a localhost public?

vestal hound
#

How can I make HTML load pictures?
@native tide what do you mean HTML doesn't load pictures

native tide
#

@native tide what do you mean HTML doesn't load pictures
@vestal hound That's what I mean.

vestal hound
#

@native tide well, most websites use HTML to display images, so...

#

how are you trying to do that?

native tide
#

I saved the website as .index file

#

And it didn't load the pictures..

vestal hound
#

I...am not sure what you're saying

#

like you saved the HTML of another website?

#

one that exists on the Internet?

native tide
#

I noticed Facebook is the only website that doesn't load the pictures when you save it as .index

gaunt marlin
#

you said you used nghix right? did you served your static files with it ?

narrow jasper
#

@narrow jasper a way is to have different values for each submit button and check what the value of button is in the view.
@near bison can you explain me that .. ping me whenever you r free

jade salmon
#

After python what should i learn for web dev? ping me wid reply

mint folio
#

@jade salmon Web development consists of front end and back end. Python is only for backend so you will need to be familiar with front end technologies (the bare minimum is HTML and CSS), and some JavaScript would also help.

jade salmon
#

Oh

#

So, should I pick up JS next?

gaunt marlin
#

yes JS is also used alot in frontend and backend too @jade salmon

jade salmon
#

Oh, that's nice!

sweet yarrow
#

How can i send variable from a flutter app to python?

bronze oak
#

Just a general question, any of you django developers ever used any JS frameworks/libraries like React or Vue as front end with django?

dapper tusk
#

I used alpine.js, but generally with the frameworks that require compilation you just make an API in django and serve the react/vue website as static files

bronze oak
#

So you mean, front end frameworks make api calls for any backend stuff and the api itself is written in Django

dapper tusk
#

yes

bronze oak
#

Actually, I am new to Django, have been thinking of some project ideas to work on using django and had this thought if we could do, what i just asked you.

gaunt marlin
#

i tried to serve React spa with my django server once, the url paths of those 2 really conflicting with each other. I would just use django as an api for React SPA

buoyant shuttle
#

hey guys, for some reason my static css file is not rendering it?

#

even when i loaded static

gaunt marlin
#

@buoyant shuttle which framework are you using ?

buoyant shuttle
#

django

#

My css worked in one of my templates

gaunt marlin
#

did you set debug=False ?

buoyant shuttle
#

and in the other it didnt

#

i dont think so, lemme check

gaunt marlin
#

just check what it's currently being set right now, don't change it

buoyant shuttle
#

CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False.

#

this what happened

#

when i set it to false,

#

it was true before

#

for some reason the css rendered, once i set it back to True

gaunt marlin
#

oh then you was on development environment

#

don't change it to False

buoyant shuttle
#

ok

#

thanks alot @gaunt marlin

gaunt marlin
#

i just want to know

#

can you post the static related settings in your settings.py ?

buoyant shuttle
#

yeah

gaunt marlin
#

ok i see, can you post the html templates code where the css is not applied ?

#

just the lines with {% static '' %}

#

if you wrote it correct in your template it should be like this

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

make sure that all your css is in a folder name static

#

in the root of your project

buoyant shuttle
gaunt marlin
#

oh then try to restart your server

buoyant shuttle
#

ok

gaunt marlin
#

you running with python manage.py runserver right ?

#

ctrl + c on the running terminal to stop the server

#

and run it again

nova nacelle
#

@buoyant shuttle Also use ctrl f5 to reload the page

buoyant shuttle
#

it worked when i used ctrel f5

#

@buoyant shuttle Also use ctrl f5 to reload the page
@nova nacelle Thanks

#

by bg color is back to black, just testing to see if it will render.

nova nacelle
#

Yeah, it clears the browser's cache on reload.

buoyant shuttle
#

ah ok

#

learned something new today ๐Ÿ™‚

gaunt marlin
#

yeah browser save previous css loaded so ctrl+f5 clear the cache

nova nacelle
#

@nova nacelle Thanks
@buoyant shuttle Np

vernal furnace
wanton tulip
#

wadddupp

vernal furnace
#

so this my post creating form

#

what I want to do is to add a submit buttons with integers to the field list

class PostCreateView(CreateView):
    model = post
    fields = ['title', 'content']

#

for example a submit buttons with the number 3 - 4 - 5 just under the content

wanton tulip
#

Why would you want that?

nova nacelle
#

@vernal furnace What would that do?

wanton tulip
#

^^ haha

vernal furnace
#

I want these to be the number of bedrooms,bathrooms etc

#

so when I create a search bar later on the search engine will search for these variables

#

I'm not sure if i'm doing it right tho

#

:c

nova nacelle
#

Forget that method for now, and explain me what you exactly wanna do.

vernal furnace
#

Lemme send you a picture

nova nacelle
#

you can simply add a field that says no. of bedrooms in your model

vernal furnace
#

can u show me how to do it

nova nacelle
#

wait

vernal furnace
#

All I want to do now is the beds(just one field)

nova nacelle
#
bedrooms=models.CharField(max_length=2, choices=(("2","2"),("3","3"),("4","4")), null=True, blank=True)
#

add this to your model

#

and then add the field bedrooms in your view

#

@vernal furnace

vernal furnace
#
 bedrooms=models.CharField(max_length=2, choices=("2","2"),("3","3"),("4","4"), null=True, blank=True)
                                                                                                        ^
SyntaxError: positional argument follows keyword argument```
nova nacelle
#

blank's in the same line

#

wait

#

@vernal furnace you missed brackets for choices

vernal furnace
#

Bruh

#

lof

#

โค๏ธ

nova nacelle
#
bedrooms=models.CharField(max_length=2, choices=(("2","2"),("3","3"),("4","4")), null=True, blank=True)

@vernal furnace read it properly

vernal furnace
#

Dude this is so cool

#

Wait can I make it more user friendly?

#

like just buttons

nova nacelle
#

This is for posting a post. It's fine... on the user's side you can add buttons as filters

vernal furnace
#

oh nice

#

Thanks again, lemme go finish the tutorial okhandbutflipped

nova nacelle
#

Alright, bye.

#

Thanks again, lemme go finish the tutorial okhandbutflipped
@vernal furnace Np.

red perch
#

Hi, im working on a project what can compare TechProducts using webscraping. I created the website using just plain html and css but i wanted to do the webscraping using bs4 because i did not know how to do this with javascript. After i did this i tried Flask for the first time so i can render my html template using render_template but when i do this the localhost "server" keeps loading, if i remove the render_template and just return text it loads instandly. ```py
from flask import Flask, redirect, url_for, render_template

app = Flask(name)

@app.route("/")
def home():
return render_template("index.html")

if name == "main":
app.run(debug=False)```This is my simple Flask code. And yes index.html is in the folder templates

proper owl
#

Try creating your app like:

#

app = Flask(name, template_folder='templates')

verbal linden
#

I have a function that gets every filename from a directory, reads it, converts it to base64 and then returns it into an <img> tag that is served to the user, but it only returns 1 image, and not all of them, but if I have the function print every filepath, that works fine.

def getPosts():
    for filename in os.listdir(image_dir):
        if filename.endswith(".DS_Store"):
            continue
    else:
        with open(os.path.join(image_dir + filename), "rb") as img_file:
            image_data=(base64.b64encode(img_file.read()).decode(charmap))
            image_element=("""<img src="data:image/png;base64, {}">""".format(image_data))
            image_container=("""<div class="image">{}<br><p>filename: {}</p></div>""".format(image_element, filename))
            return image_container```

```python
image_list=("""<div class="images">{}</div>""".format(getPosts()))```
#

yes I'm aware it's horribly inefficient, but for the purpose it's serving and the http.server module I used, it's what I'll have to put up with

near bison
#

How are svgs made ?

native tide
#

Hey guys I need help in Django project
I thought to develop a chat application with Django
So What front-end I can use for it
Pls help me it is my first project

verbal linden
#

How are svgs made ?
@near bison complex math

near bison
#

Damn

#

@verbal linden Are you sure ? You mean all those symbols and logos in svg out there are made with code. i don't think so

verbal linden
#

math, not code

near bison
#

You can't just draw ?

verbal linden
#

that's why you can rescale them without losing quality

#

and why you can't convert a png to an svg(?)

near bison
#

Because it's vector

verbal linden
#

yes

near bison
#

I made some simple svgs in figma. so i don't think it's just math. there must be way's to draw it or something

balmy stag
#

@native tide You need to make your chat interactive so you'll need JS. You can go old school and use plain JS or jQuery, but it's highly recommended to use a JS Framework. The most famous are Angular, Vue and React (React is the most popular).
There are 2 main solution to use Django with a JS framework : Django serves as an Restful API and the front is independant, or you can integrate the compiled JS in your Django template with the help of webpack

native tide
#

@balmy stag Thank you

#

so it will take couple of months to complete

near bison
#

What are some apps (open source) to work with SVGs ?

#

Create , Edit etc

native tide
#

are you in windows

#

or linux

dapper tusk
#

inkscape is the most popular one

balmy stag
#

Yeah it's a common projet but not the easier

native tide
#

I agree

#

for @dapper tusk and @balmy stag

near bison
#

linux

native tide
#

ok

#

then Inkspace

#

or check this out

near bison
#

what is that device you use to draw called ?

native tide
#

I don't touch that part

#

because learning backend

mortal mango
#

does anyone know if you can put asp.net files on GitHub Pages?

near bison
#

I don't think you can. it's just for static documents as far as i know

native tide
#

yeah
@buoyant shuttle your python file should prolly be called main.py, but also the main html file is index.html not main.html

jolly bone
#

does anyone know if you can put asp.net files on GitHub Pages?
@mortal mango are you asking about blazor, or the db connection and alll?

cold haven
#

hi

nimble epoch
#

@cold haven hi

#

@limber edge im using flask_sqlalchemy but i have no idea about your question but in the same site that youve posted there was a solutionmaybe thatll help

mortal mango
#

@mortal mango are you asking about blazor, or the db connection and alll?
@jolly bone just a static .aspx website

jolly bone
#

Static sites are possible, but any dynamic content is not hosted by Pages

#

I'll suggest you see this guide

#

Hope it is what you were looking for

swift sky
#

hello

#

im trying to figure out how to pull multiple fragments into my html

#

basically, i have a webpage that gets updated by using mysql queries

#

currently i had only one section that needed to be updated

#

I was going to now add another section, using a different query

#

I thought that I could just duplicate the code, this didn't seem to work

#
@app.route("/")
    @login_required
    def staffdashboard():
        connection = db_connection_content()
        cursor = connection.cursor(pymysql.cursors.DictCursor)
        sql_query1 = "SELECT date_format(load_date, '%m-%d-%Y') as the_date, content from notification_content order by load_date desc limit 5"
        sql_query2 = "SELECT date_format(load_date, '%m-%d-%Y') as the_date, content from roll_call order by load_date desc limit 5"
        cursor.execute(sql_query1)
        cursor.execute(sql_query2)

        data1 = cursor.fetchall()
        data2 = cursor.fetchall()




        try:

            fragment1 = render_template_string('''
            
            {% for item in data %}
                <p class = "notification">{{ line }} </p>
                <p class = "load_date">{{ item[ 'the_date' ] }} </p>
                <p class = "content">{{ item[ 'content' ] }}</p>
            {% endfor %}
            ''', data=data1)

            fragment2 = render_template_string('''
            
            {% for item in data %}
                <p class = "roll_call">{{ line }} </p>
                <p class = "load_date">{{ item[ 'the_date' ] }}</p>
                <p class = "conent">{{ item[ 'content' ] }}</p>
                
            {% endfor %}
            ''', data=data2)

            return render_template("staffdashboard.xhtml", dict_to_be_passed=parse_311_sitemap(load_articles()),
                                   fragment=[fragment1, fragment2])```
#

how do i refference multiple fragments in my code

#

fragment=[fragment1, fragment2] is this viable?

#

because it seems to be placing the same fragment into both divs

#
<section class="hero is-info welcome is-small" style="height:200px; ">
                    <div class="hero-body">
                        <div class="container">
                            <h1 class="title">
                                Hello,Expdient staff &lt; username?? &gt;.
                            </h1>
                            <h2 class="subtitle">
                                 <table>
                                    <tr>
                                           <td>
                                               {{ fragment|safe }}
                                           </td>
                                    </tr>
                                </table>
                            </h2>
                        </div>
                    </div>
                </section>```
#

that is one section

#

this is the other

#
                        <div class="tile is-parent" style="height:400px;">
                          <article class="tile is-child notification is-warning ">
                            <div class="content" >

                              <a href="{{url_for('roll_call')}}">
                                <p class="title"> Roll Call </p>
                              </a>
                              <p class="subtitle"> These are the last 5 roll calls </p>
                              
                              <main>
                                <p class="title center">Roll Call Log</p>

                                  <div class="center" >
                                    <h7 style ="width:95%; height:150px; overflow-y: scroll;">
                                         <table>
                                            <tr>
                                                   <td>
                                                       {{ fragment|safe }}
                                                   </td>
                                            </tr>
                                        </table>
                                      
                                     </h7>
                                      </article>
                                  </div>
                              </main>

                              
                          </div>```
#

umm

#

so just the order

#

testing now

#

so

#

that didnt help, but basically it's placing query 1 in both divs

#

maybe i need to close the cursor

#

the content of this cursor.execute(sql_query1) data1 = cursor.fetchall()

#
<section class="hero is-info welcome is-small" style="height:200px; ">
                    <div class="hero-body">
                        <div class="container">
                            <h1 class="title">
                                Hello,Expdient staff &lt; username?? &gt;.
                            </h1>
                            <h2 class="subtitle">
                                 <table>
                                    <tr>
                                           <td>
                                               {{ fragment|safe }}
                                           </td>
                                    </tr>
                                </table>
                            </h2>
                        </div>
                    </div>
                </section>```

gets placed here

#

and

#
                        <div class="tile is-parent" style="height:400px;">
                          <article class="tile is-child notification is-warning ">
                            <div class="content" >

                              <a href="{{url_for('roll_call')}}">
                                <p class="title"> Roll Call </p>
                              </a>
                              <p class="subtitle"> These are the last 5 roll calls </p>
                              
                              <main>
                                <p class="title center">Roll Call Log</p>

                                  <div class="center" >
                                    <h7 style ="width:95%; height:150px; overflow-y: scroll;">
                                         <table>
                                            <tr>
                                                   <td>
                                                       {{ fragment|safe }}
                                                   </td>
                                            </tr>
                                        </table>
                                      
                                     </h7>
                                      </article>
                                  </div>
                              </main>

                              
                          </div>```

here

#

the goal is to have query 1 go to the first div and query 2 go to the 2nd

#

yea

#

but idk much about fragments, idk what to even google

#

so idk if i can just change the name

#

how would you refactor it

#

i need to redo the whole thing tbh

#

i need to learn about blueprints

#

and {{fragment[1] | safe}} where you want fragment2
@limber edge this worked

#

blueprints is nice, but really only practical for larger sites imo
@limber edge this is the direction im headed

#

for your database stuff
@limber edge yes i have to do a major refactor, right now im not using the orm

#

thank you for your help

cold haven
#

hello

#

ABstraCtiยคn{Bยคx =>(bindObservable = n2sFiles{network, security, storage}) Unbยคx =>(bindObservable = i2rData{reliability, integrity, redundancy})}

nova shadow
#

Is it stupid for me to be running two backends for my website? I am using Node.JS to run the API and Flask to fetch and process data from the API

quick cargo
#

yes thats a pretty dumb idea

granite mirage
#

@reef rover your question was inactive, what happen if you run rq worker high default low ?

reef rover
#

@granite mirage it just says listening on those queues

granite mirage
#

and you visit that path on browser, and no task got sent?

reef rover
#

The task gets queued but the worker does not start it

granite mirage
reef rover
#

Seems like a bug

silk gorge
#

Does anyone have any ideas on how I could make the image on the left inherit the height of its sibling on the right using CSS grid?

native tide
#

stackoverflow is your best friend for those type of Qs

kindred schooner
#

Just use px

#

like img {height:20px} and p {height: 20px} you can just use some Javascript (or Python) to change a variable.

devout coral
#

@silk gorge Show me the snippet of how you have your html set up?

#

Just the parent and everything inside.

cold haven
#

Set it in a parent div container and set children at relative height is what I would do.

kindred schooner
#

That would work.

#

Why is there a web-development channel in a python server?

cold haven
#

Django probably

kindred schooner
#

Oh.

cold haven
#

It's a python framework

kindred schooner
#

Ik,

#

I just think it would probably be more supported, if it's a Python framework.

devout coral
#

What would be more supported?

quick cargo
#

there are loads of Python web frameworks

#

FastAPI
Sanic
Starllette
AioHTTP
Japronto
Tornado
Flask
Django
apidora

#

thats just a small list :P

swift sky
#

how do you guys handle wtforms validators and inherittence

#

like

#
class PhoneSurvey(FlaskForm):

    email = StringField("Email", validators=[Optional()])

    terminal_number = IntegerField('Terminal number', validators=[Optional()])

    #pandemic?
    was_this_a_pandemic_related_call = SelectField('Was this a Pandemic related call',
                                                   choices=[('yes', 'Yes'),
                                                            ('no', 'No')],
                                                   validators=[Optional()])
    #pandemic topic?
    what_was_the_call = SelectField('What category was this call', choices=[('',''),('get_food', 'NYC Get Food'),
                                                           ('covid_test', 'COVID-19 Testing'),
                                                           ('remote_learning', 'Remote Learning'),
                                                           ('other', 'Other')], validators=[Optional()])

    #did you resolve this call [APPLIES TO: PANDEMIC AND NON PANDEMIC]
    was_the_inquiry_resolved = SelectField('Was the inquiry resolved', choices=[('yes', 'Yes'), ('no', 'No'),
                                                                          ('other', 'Other')], validators=[Optional()])

    #were you able to
    submit = SubmitField('Submit')

class PhoneResults(PhoneSurvey):
    start_date = DateTimeField(label='Start Time (mm-dd-yyyy)', format='%m-%d-%Y %H:%M:%S', validators=[DataRequired()])
    end_date = DateTimeField(label='End Time (mm-ddd-yyyy)', format='%m-%d-%Y %H:%M:%S', validators=[DataRequired()])```
#

basically i have my survey, and i have my results (which is a class i use to pull data into xls and send to user)

#

and as u see my results inherit from my survey

#

but if i put in some DataRequired() validators in my survey, i am not able to actually download the report, because well i guess PhoneResults is expecting required data that is not being input by the reports users/since in my view function this is not a field that I actually use (in the reports page)

#

i believe there might be some OOP principles to help with this

#

but i was curious if anyone had suggestions

native tide
#

So if you have the DataRequired validator, and even if you provide data in that field, it doesn't submit?

swift sky
#

no so for example

#

the phone results class, the variables in there, those are the only things i ask from my user to input

#

so if i put a data required under some variables in PhoneSurvey i can't download the PhoneResults report, because I've inherited DataRequired() validators

#

and my end user who is trying to use PhoneResults to pull the xls report, does not actually need to input values for the PhoneSurvey, but because there are DataRequired() validators which are inherited from PhoneSurvey the xls file wont load.

#

i hope that makes sense

sly echo
#

Hello

#

I need some help

#

I'm just a beginner in Python.
So beginner that I just know the syntax.
I really want to climb up fast.
I love the web dev.
How can I come from my level to yours?

#

I'm so bad right now that I don't even get the logics of my academic assignments.

#

Someone, help

#

I'm just stuck in tutorial purgatory and live helps

quick schooner
#

do u know html ?

native tide
#

Can I hire somebody

#

Ping me if yes payment is involved

quick cargo
#

@native tide no

#

!rule 6

lavish prismBOT
#

6. No spamming or unapproved advertising, including requests for paid work. Open-source projects can be shared with others in #python-general and code reviews can be asked for in a help channel.

#

6. No spamming or unapproved advertising, including requests for paid work. Open-source projects can be shared with others in #python-general and code reviews can be asked for in a help channel.

native tide
#

!rule 5

lavish prismBOT
#

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

plucky tapir
#

Django: I have a user logged in, they want to enter personal info about themselves into a table in the database, they should only create and submit a max of 1 time, is that a one-to one relationship? That is not with a foreign key correct? The other tables I could use a foreign key because they can enter posts multiple times?

quiet comet
#

use a boolean field, if he create one then true, if not false

vestal hound
#

Django: I have a user logged in, they want to enter personal info about themselves into a table in the database, they should only create and submit a max of 1 time, is that a one-to one relationship? That is not with a foreign key correct? The other tables I could use a foreign key because they can enter posts multiple times?
@plucky tapir onetoone field

finite flame
#

is python a good option for backend dev?

plucky tapir
#

@vestal hound thanks. Would a one-to-one prevent the user from making another post to that table or I have to check that some other way? Through views possibly

shut marten
#

?poll

indigo kettle
#

@plucky tapir onetoone field ensures that there is only one related object

#

another one will not be allowed to be created

nova nacelle
#

Does anyone have any ideas on how I could make the image on the left inherit the height of its sibling on the right using CSS grid?
@silk gorge is this solved?

cold socket
#

Anyone know how to get around circular import errors?

ImportError: cannot import name 'Hospital' from partially initialized module 'app' (most likely due to a circular import) (/root/Tactical/app.py)```
chrome onyx
#

If you import a module that imports the main file, it will cause a circular import error

cold socket
#

Hmm why can't I import 2 files to each other?

chrome onyx
#

Like if you have import hi in one file and in hi.py you have import main, then it will import hi, which will import main, which will import hi, and so on and this causes an error

#

That's why you usually have one main file with all the variables and separate files for classes

#

And those class files usually don't import anything from the main file

cold socket
#

Oh I see the problem

chrome onyx
#

This has happened to me a lot, so I would just say combine both files

#

Good Luck!

cold socket
#

So Hospital is a class (table in SQLite) in app.py

#

And im trying to access it in another file

#

So I imported it from app. But I also use functions from the other file in app.py

chrome onyx
#

Is app.py importing that "other file"?

#

Oh yeah

cold socket
#

So yeah I import them in each other

#

yep

#

So I should just take everything in the second file and put it into app.py

chrome onyx
#

That happens to me a lot when I try to create a new file for my db.Model class when using SQL... you just have to move the other file to app.py, I can't think of another way

cold socket
#

Yeah I agree, ill merge it into app.py

#

Hopefully this resolves my problems

chrome onyx
#

Good Luck with the rest of your project!

cold socket
#

Thank you kind sir!

still kite
#

Hey guys what is a better framework django or flaskl?

chrome onyx
#

Depends on what you want to do

#

If you want to code a simple website

#

Use Flask

still kite
#

Full Stack Web Development

chrome onyx
#

If you want an industrial-scale website with great organization and multiple features...

#

Use Django

still kite
#

I want to become a full stack web developer that's why

chrome onyx
#

I would recommend starting off with Flask then... if you haven't done web dev before

still kite
#

and is there any other framework to make a rest api

chrome onyx
#

I don't know much about Rest APIs, so someone else can help you with that

#

But if you haven't done web dev before, I would recommend you get started with Flask

#

It has some cool features and works really well even though it's very simple

still kite
#

I know that is why i like rest api's

warm igloo
#

FastAPI is great to try too. Weโ€™ve been using that instead of Flask lately.

vernal furnace
#
{% if object.auther == user %}
                <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{% url 'post-update' object.id %}">Update</a>
                <a class="btn btn-danger btn-sm mt-1 mb-1" href="{% url 'post-delete' object.id %}">Delete</a>
            {% endif %}
#

yoo why its not working

#

๐Ÿ˜ฆ

#

The server is working just fine, everything is working but the buttons for update and delete doesn't show

late gale
#
{% if object.auther == user %}
                <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{% url 'post-update' object.id %}">Update</a>
                <a class="btn btn-danger btn-sm mt-1 mb-1" href="{% url 'post-delete' object.id %}">Delete</a>
{% endif %}

try to get end if like this as its the normal if statement

vernal furnace
#

what do u mean

#

intendation looks fine in ide

late gale
#

oh ok let me look again

#

do u have any errors ?

vernal furnace
#

nope

late gale
#

so the problem should be in the {% url % }

#

let me see

vernal furnace
#

it looked like {& url &} at first but I fixed it

late gale
#

isnt it corey's tutorial ?

#

it looks very familiar to me

#

corey schafer

#

i was getting into his repo so i can see what u did wrong but u actually solved it so nice job

vernal furnace
#

yea

#

well its not working pithink

tardy heron
#

Why can't I send mail using gmail? I already sent mail using sendgrid, but my email is on a blacklist, so i made a gmail account to send, but it hangs. Same with my other account.

#

i mean sendgrid is on a blacklist

#

my mailbox doesn't get any mail from them ๐Ÿ˜‰

vernal furnace
#

OHHH

#

FINALLY

#

it was auther not author

#

;-;

late gale
#

=,=

#

haha

#

yea happens

vernal furnace
#

but why the ide didn't tell me about it

tardy heron
#

When I added gmail to thunderbird it asked me about it on my phone. Now it doesn't ask. Is there some thing about this I dont know about. Like having to authorize an app using my credentials

vernal furnace
#

Hi Again,
I added another field for my requirements to post here it is:

bedrooms = models.CharField(max_length=2, choices=(("2","2"),("3","3"),("4","4")), null=True, blank=True)
#

and that one is in my views.py

class PostCreateView(LoginRequiredMixin, CreateView):
    model = post
    fields = ['title', 'content', 'bedrooms']
#

it gives me this error

#
OperationalError at /post/new/
table blog_post has no column named bedrooms
Request Method:    POST
Request URL:    http://127.0.0.1:8000/post/new/
Django Version:    3.1.2
Exception Type:    OperationalError
Exception Value:    
table blog_post has no column named bedrooms
Exception Location:    D:\Python\lib\site-packages\django\db\backends\sqlite3\base.py, line 413, in execute
Python Executable:    D:\Python\python.exe
Python Version:    3.9.0
Python Path:    
['D:\\buybeit_project',
 'D:\\Python\\python39.zip',
 'D:\\Python\\DLLs',
 'D:\\Python\\lib',
 'D:\\Python',
 'C:\\Users\\Fw admin\\AppData\\Roaming\\Python\\Python39\\site-packages',
 'D:\\Python\\lib\\site-packages']
Server time:    Sat, 07 Nov 2020 09:40:10 +0000
#

table blog_post has no column named bedrooms ๐Ÿค”

#

Anyone knows what to do?

#

I fixed it, makemigrations.

agile wedge
#

Hello guys. Im making simple website in flask. When i enter name and classroom in POST method and click submit i get error: return render_template("elo.html", ucenik=ucenik)
NameError: name 'ucenik' is not defined.

Here is main piece of code. I reckon solution is simple i just cant find it.

meager pecan
#

hi guys i am beginner i need a friends or a team that have the time and the ability to help and share mme to expand #I-need-help ๐Ÿ™‚

tribal python
#

@agile wedge you have a scope error, ucenik is only defined in the home function

#

not the elo function

agile wedge
#

How do i make elo function "see" ucenik from home function?

tribal python
#

define it outside of the function.

#

use a database or some basic store for the objects

#

@meager pecan if you have a question, feel free to ask in the appropriate channel, or see #โ“๏ฝœhow-to-get-help if you need some targeted help with something

meager pecan
#

can i ask a question? how old are you @agile wedge & @tribal python

#

since you are very pro!

#

i am 16 years old and learning python ana java in school but i need to expand more

agile wedge
#

@tribal python Ok ill try to implement basic database. tyvm

meager pecan
#

i am beginner!

tribal python
#

23 here

#

I wouldn't call myself a pro, intermediate to advanced maybe :p

meager pecan
#

how old are you @tribal python for having this ability of learning python and when you started learning?

tribal python
#

I literally just said

#

I started learning when I was around 12, I'm 23 now.

meager pecan
#

wow nice

#

11 years

#

i started in 2 months

#

๐Ÿ˜†

#

but i read too much i love!!!!! team work!

nova nacelle
#
OperationalError at /post/new/
table blog_post has no column named bedrooms
Request Method:    POST
Request URL:    http://127.0.0.1:8000/post/new/
Django Version:    3.1.2
Exception Type:    OperationalError
Exception Value:    
table blog_post has no column named bedrooms
Exception Location:    D:\Python\lib\site-packages\django\db\backends\sqlite3\base.py, line 413, in execute
Python Executable:    D:\Python\python.exe
Python Version:    3.9.0
Python Path:    
['D:\\buybeit_project',
 'D:\\Python\\python39.zip',
 'D:\\Python\\DLLs',
 'D:\\Python\\lib',
 'D:\\Python',
 'C:\\Users\\Fw admin\\AppData\\Roaming\\Python\\Python39\\site-packages',
 'D:\\Python\\lib\\site-packages']
Server time:    Sat, 07 Nov 2020 09:40:10 +0000

@vernal furnace make migrations in your app

#

I fixed it, makemigrations.
@vernal furnace oh, you did that already.

empty saffron
#

How can I use JS to get data from django backend? or a way to pass data from template to a view in django so that the view can update it and send back

late gale
#

@empty saffron use sterilizers

#

that might help i was going for the same problem and that helped me

empty saffron
#

I don't want data from db

#

I want it from a function

#

I want to pass data from user to a function in the backend and get the result and display it

#

Basically, the user will enter 2 fields in a form and press "Run" then it should feed that data to a function in the backend and get the results and add a row in a table

mental prawn
#

Hey guys i have a question

late gale
#
class UpdateProfile(LoginRequiredMixin, UpdateView):
    model = Profile
    template_name = "users/update_profile.html"
    fields = ['user']

    def form_valid(self, form):
        form.instance.author = self.request.user
        return super().form_valid(form)

    def test_func(self):
        profile = self.get_object()
        if self.request.user == profile.user.id:
            return True
        else:
            return False

and here is the template

lavish prismBOT
#

Hey @late gale!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

โ€ข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

โ€ข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

late gale
mental prawn
#

is there a difference if i code on pycharm or python app it self?

late gale
#

@mental prawn nope

#

Pycharm will let you do a virtualenv for your project which is something cool for your package management

tardy heron
#

@mental prawn you don't mean the interactive interpreter?

mental prawn
#

what i mean is that for example if i want to make a website there is no difference if i use pycharm or some other editing apps

late gale
#

nope there is no difference

#

but in web developement i highly recommend vs code

mental prawn
#

visual studio

tardy heron
#

no theres a lot of choises. Some have more features than others

late gale
#

vscode = Visual Studio Code not Visual Studio

#

because it's very fast and doesnt consume much ram

#

unlike Pycharm

#

though pycharm has amazing features

#

that vscode doesnt has

tardy heron
#

vscode has plugins, but i found pycharm easier to use. Don't know how others feel

late gale
#

it depends on everyone's perspective

placid vale
#

heared pycharm first time o.o

late gale
#

If u are working on a big projects i would recommend pycharm

mental prawn
#

well when am coding on pycharm when i right some letters or words it pop ups some other words for example if i right pr it will show me different stuff to use

late gale
#

I only use vscode for websites

placid vale
#

lol firstly i used notepad

tardy heron
#

eww

mental prawn
#

notepad ++?

placid vale
#

nah simple ๐Ÿ˜›

mental prawn
#

idk how to use that cuz am used to pycharm

placid vale
#

notepad?

late gale
#

there are really some people still use notepad and idk why

placid vale
#

yeah