#web-development

2 messages · Page 86 of 1

slow rampart
#

contenteditable says its not a valid xpath

#

ive been working on 70 lines of code for 3 days now

#

this is hell

wind escarp
#

does automating a post actually count as scraping?
@slow rampart it's none of my business to ask whether it's one post or several but usually possibilities are limitless, you can do a lot cool shyt by scraping a website but I am sure if you try to scrap reddit, their rate-limit will kick you

native tide
#

Iirc, there is an api which you can use to retrieve information from subs, unless they deprecated it / removed it

slow rampart
#

praw?

native tide
#

Yeah

slow rampart
#

that only works for getting posts not making them afaik

wind escarp
#

the thing is, OP wants to send stuff out

slow rampart
#

im using it on a discord bot im making

native tide
#

I’m looking at the reddit api, and it seems you can post comments and create threads and such

#

why would you want do use that

slow rampart
#

i dont think im allowed to discuss things like that here since i believe its against reddit tos, but i will not be using it maliciously

#

its supposed to automate posts though, and it will have a delay so its not spamming

native tide
#

I wouldn't scrape reddit, there are many better websites for doing that

slow rampart
#

just to help automate a bit

native tide
#

Reddit’s /api/submit is the endpoint. Don’t know what that correlates to in praw

slow rampart
#

i will look into that

#

i think i found something with praw

hallow jacinth
#

anyone experienced with postgress and heroku think they can help me real quick

versed python
#

yeah shoot @hallow jacinth

hallow jacinth
#

I am not sure why when I run my server that the postgress db isn't getting updated with my db models

#

I tried getting rid of my migrataions folder, rocommended earlier, but that didn't seem to help the problem

versed python
#

are you sure you are using postgres and not sqlite3?

#

happened to me once

hallow jacinth
#

hmmm let me check on the site real quick again

versed python
#

ping me when you reply

hallow jacinth
#

since I am using flask do you mean the config.py? Also, it seems to be set up properly. It at least registers locally

#

@versed python

versed python
#

I don't know how to configure flask

#

but I am sure there must be some settings for it too

#

look up how to use postgres with flask @hallow jacinth

#

search on google

hallow jacinth
#

okay ill try that

native tide
versed python
#

Now you can try it by going at localhost in your browser:
localhost:5000

change it to http://localhost:5000/ in Your README. nice project, looks good. @native tide

wind escarp
#

he doesn't need to do that @versed python

versed python
#

well it is just a bit more verbose and thus looks more professional.

#

either way both will work so no harm in keeping it the way it is

native tide
#

thanks 🙂

topaz finch
#

I am trying to add a dropdown list from bootstrap, as is demonstrated here:
https://getbootstrap.com/docs/4.5/components/forms/#form-controls

I added it to another form, but when the form is submitted, the value for logChannel isnt provided. Help?

<form method="POST">
  <label for="prefix">Prefix:</label>
  <input type="text" id="prefix" name="prefix" value="{{prefix}}" size=6 maxlength=8 required><br><br>

  <div class="form-group">
    <label for="exampleFormControlSelect1">Example select</label>
    <select class="form-control" id="exampleFormControlSelect1">
      {{channelOptions}}
    </select>
  </div>

  <button type="submit" class="btn btn-primary">Save Changes</button>
</form>

@ me when answering, please.

versed python
#

@topaz finch show us the view which you are using

#

ghe one written in python

dense bear
#

hello again. I was working my project and encountered a "id does not exist" error. Any suggestions?

#

from what I remember I wrote the db.relationship lines correct, but maybe not

topaz finch
#

@versed python wdym by which view

versed python
#

@topaz finch you must have a views.py which will be using the html template you sent.

#

!paste

lavish prismBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

versed python
#

paste it here ^

acoustic oyster
#

howdy friends, I have a custom user

class User(AbstractUser):
    bot_admin = models.BooleanField(default=False)

and I would like to add the field "bot_admin" to the admin panel. I am using

class CustomUserAdmin(UserAdmin):
    add_fieldsets = UserAdmin.add_fieldsets + (
        (
            None,
            {
                "fields": ("bot_admin",),
            },
        ),
    )


admin.site.register(User, CustomUserAdmin)

but this does not affect the admin page at all it appears

#

oof, I need to stop posting here, I always solve these so fast after posting haha, I guess "add_fieldsets" is no longer a thing... or maybe never

topaz finch
#

@versed python after 2 hours of searching, I happened to find the answer when I gave up, of course. I just had to set the name attribute.

versed python
#

@topaz finch congrats!

native tide
#

@acoustic oyster sometimes its the typing out the problem that results in the answer. I wouldn't feel bad about it.

acoustic oyster
#

haha, ty. Who wouldve thought the solution was to read the docs 😅

azure owl
#

Hello. How do I prevent flask from sending html back as response instead of just status codes

lethal orbit
#
admin.site.register(User, CustomUserAdmin)```

@acoustic oyster cool use of decorators xD

acoustic oyster
#

LOL, I dont need this rn xD

#

Im busy copying your code

lethal orbit
#

flexes the iron fist into Friendo-bot

acoustic oyster
#

haha

cold socket
#

Anyone know of a good guide to seamlessly deploy my Flask app to production on a VPS?

acoustic oyster
#

always corey schafer! haha

cold socket
#

Oh dang that's a bulky video

acoustic oyster
#

he covers a lot of the basics, including setting up the server from scratch

#

if this is too much, linode and I think digital ocean have their own guides as well

cold socket
#

Yeah I'll be using DigitalOcean actually

#

Also if I want to run 2 flask apps on the same VPS

#

I should essentially do the same steps and just change the port number it runs on?

acoustic oyster
#

well, I personally use apache with virtual hosts. And I also use django, there should be Flask docs for official methods to serve the application

gleaming basin
#

hai guys

#

a little help

lethal orbit
#

Also if I want to run 2 flask apps on the same VPS
@cold socket best solution: docker, docker-compose, traefik.
Decent alternative: nginx as a reverse proxy for gunicorn / uwsgi or apache with mod_wsgi and virtual hosts.

zealous cloud
#

@honest dock is this something like WTF forms? Do you need to iterate through your form file with something like {% for field in form if field.widget.input_type != 'hidden' %} to make each field show up? Also what route is your form sending the POST request to?

honest dock
#

hahahha

#

it's fine i fixed it

#

let me delete it

primal kernel
#

Hay guys! is someone acquainted with **Django **and Fixtures?

versed python
#

yeah

#

i think

#

what do you need @primal kernel

primal kernel
#

Okey I'll try to explain:

#

Not sure if I should write this here 😫

versed python
#

!paste

lavish prismBOT
#

Pasting large amounts of code

If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

versed python
#

write here @primal kernel

primal kernel
#

So I execute the next command:

python .\manage.py loaddata .\rules\fixtures\rules.json

But I get the next error:

AttributeError: Problem installing fixture 'C:\Users\Ángel - Trabajo\Documents\AVC.\rules\fixtures\rules.json': 'NoneType' object has no attribute 'id'

#

Oh wow i'm sorry wait

versed python
#

well it looks like there was an issue exporting the data

#

if you look at the fixture itself, every object has pk: null

primal kernel
#

I read that if you write pk: null it gets an autoincremental number

versed python
#

no

#

it gets that when django does the database handling for you

#

since you're loading data manually, you need to absolutely correct and valid fixtures, otherwise it won't work

#

the simplest way to fix this is just add pk=1, pk=2 as so on

primal kernel
#

I tred with only 2 elements, and didnt worked, wait:

versed python
#

show me the error

primal kernel
#

Same: AttributeError: Problem installing fixture 'C:\Users\Ángel - Trabajo\Documents\AVC.\rules\fixtures\rules.json': 'NoneType' object has no attribute 'id'

versed python
#

hmmm

#

i get it

#

is your database empty?

primal kernel
#

The tables are created but no data inside

versed python
#

i mean is there already data for the models License and the other one?

#

The tables are created but no data inside
@primal kernel yep that's the problem

primal kernel
#

No, sorry, in license and profile there is only one row with ID: 1

versed python
#

you see, in your fixtures, under the fields object, you are referencing to license: 1. but that doesn't exist and your database doesn't know what to do

primal kernel
#

The empty table is Rule

versed python
#

No, sorry, in license and profile there is only one row with ID: 1
@primal kernel well that complicates things

#

maybe just delete the database and start over again?

primal kernel
#

Yeah I will try

versed python
#

or you could wait will someone else comes along and has a better solution

primal kernel
versed python
#

mostly deleting the db does the trick

primal kernel
#

Okey I will try

#

Thank you sooooo much for your help

#

❤️

versed python
#

do you have an element for profile too?

primal kernel
#

Yeah for both

versed python
#

well idk how to solve this then

#

I'd just delete the db and start over

primal kernel
#

It's ok @versed python i'll investigate, thank you so much

versed python
#

you're welcome

#

or you could ask in #databases @primal kernel they might know

primal kernel
#

Yeah good idea I will try

barren stratus
#

i was trying to deploy my flask app to heroku

#

but it throws a bunch of errors

#

is there anything wrong in my procfile

lethal orbit
#

but it throws a bunch of errors
@barren stratus It failed to bind() to the socket because it's already in use.

#

That means something is already listening on the port; either another copy of your app or something else.

#

nginx, gunicorn, etc.

native tide
#

Do you guys like Djoser in Django or it is rather crap ?

lethal orbit
#

Do you guys like Djoser in Django or it is rather crap ?
@native tide you know what's crap? your racist display picture.

#

I use numbers. You can always set the precision on the client-side.

#

If you just display them, it doesn't really matter. If you do calculations in JS, floating-point makes it easier.

#

(Assuming it is safe to ignore floating-point errors)

#

Normally those are small enough to be negligible if you just display prices.

sullen basalt
#

How can i make a model that can have multiple Charfields?

lethal orbit
#

Django?

class BlogPost(models.Model):
    title = models.CharField()
    text = models.CharField()
sullen basalt
#

Oh yes i mean in Django

#

And if I beforehand do not know how many Charfields i want

lethal orbit
#

SQL is schema-first, so you need to define your tables and fields before you insert data, i.e. add those fields.

#

If you want something dynamic, consider using a JSONField and storing the fields in there.

vestal hound
#

And if I beforehand do not know how many Charfields i want
@sullen basalt you can always make changes to your model later on

sullen basalt
#

I mean, the user should be able to click a button to get another field and I want all of the fields to be added to the database

#

But i do not understand how i should handle this with a Model

lethal orbit
#

JSONField

#
{
  "field1": "foo",
  "field2": "bar"
}```
sullen basalt
#

soo perhaps?

class Example(models.Model):
  name = models.CharField(max_length=255)
  fields = JSONField()
lethal orbit
#

Yup. You'll have to handle the input yourself though.

sullen basalt
#

So i can put the fields that the user adds all into JSONField

versed python
#

@sullen basalt you should actually define a second model which will store all the text fields that you want. this will enable you to have a variable number of CharFields associated with a model very easily.

#
class ExamplePerson(models.Model):
         name = models.TextField()

class ExamplePersonPhoneNumber(models.Model):
          example_person = models.ForeignKey(ExamplePerson, on_delete=models.CASCADE)
          phone_number = models.TextField()
#

as you can see, you can associate as many phone numbers to a person as you like

#

I think this is the way django docs suggest too. Or maybe i just read a Stackoverflow answer saying it is. Either way this is the best solution imo.

honest dock
#
#View
def edit_profile_screen_view(request): 
    
    if request.POST:
        form = UpdateProfileForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
    else:
        profile = Profile.objects.get(user= request.user)
        form = UpdateProfileForm()
    context['form'] = form
    return render(request, 'Profile/edit_profile.html', context)


#Form:
class UpdateProfileForm(forms.ModelForm):
    class Meta:
        model = Profile
        fields = ('link', 'description', 'picture')


#Model
class Profile(models.Model):
    class Meta:
        db_table = 'Profile'
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    link = models.TextField(db_column='link', default='', blank=True)
    picture = models.ImageField(db_column='picture', upload_to=upload_location, null=True, blank=True)
    description = models.TextField(db_column='description', default='', blank=True)

This gives me this error: NOT NULL constraint failed: Profile.user_id but I don't know how to fix it. Anyone know how?

versed python
#

@honest dock you're not really assigning a user to the profile object

#

to fix this, type these lines before form.save()

honest dock
#

@versed python yes, and it frustrates me that I don't know how. I tried form.user = request.user

versed python
#
instance = form.save (commit=False) 
instance.user = request.user
instance.save()

and then delete the form.save() statement

honest dock
#

oh okay

#

Can you explain it for me?

versed python
#

form.user = request.user is wrong since the form is not the Profile, it doesn't have a user attribute associated with it

#

Can you explain it for me?
@honest dock yeah

honest dock
#

I see

versed python
#

line 1) form.save(commit=False) gives you the Profile object you are gonna save. commit=False prevents django from actually saving the object to database and thus error is raised

#

line2) the instance (which is actually a Profile object) gets the currently logged in user associated with its user attribute

#

line 3) object saved to database :D

honest dock
#

I see

#

I'll give a try right now, thank you!

#

It's working

#

But!

#

It hasn't updated the profile, instead, it created a new one

versed python
#

it does?

#

weird

honest dock
#

Yes

versed python
#

oh i get it

solar ridge
#

From a generic view, what would the best way be to execute code when the view is requested?

#

I was thinking of putting it in the Setup()

jagged lark
#

Override it and call the super method

versed python
#

@solar ridge you could also override the get method

solar ridge
#

thanks, I solved it with a override of dispatch

frozen python
#

How do you get cards to show “side by side” in Django? Without the text going on the side too?

solar ridge
native tide
#

Is there a special decorator to use for running code after flask app closes?

weary dragon
#

How can i pass app argument to a class if that doesn't have the .init_app method?

versed python
#

@frozen python you mean bootstrap cards?

native tide
#

maybe you can add it in the constructor directly @weary dragon

weary dragon
#

how can i do that?

#

i also need to import it

native tide
#

For example db = SQLAlchemy(app)

#

sth like that.

weary dragon
#

and if i do that how i can import it?

native tide
#

Import what 😄

weary dragon
#

in your example the db variable

#

to use somewhere else

native tide
#

from <file> import db

#

if your python script is db.py you'd say from db.py import db

frozen python
#

@versed python yes, but it’s Django, it’s cycling through my info and placing it in. It’s showing side by side with my different info. I have a picture, paragraph and name.

versed python
#

@frozen python as far as ik you need to add a card body class to the actual text contained inside the card

weary dragon
#

@native tide i have now a import error, i don't think if i put a variable into a function i can import it

versed python
#

if your python script is db.py you'd say from db.py import db
@native tide just db not db.py

weary dragon
#

same thing

#

my function look like this ```py
def create_app(config_class=Config):

app = Flask(__name__)
app.config.from_object(config_class)

db.init_app(app)
login_manager.init_app(app)
mail.init_app(app)
migrate.init_app(app, db)
discord_oauth = DiscordOAuth2Session(app)

from flaskblog.users.routes import users
app.register_blueprint(users)

from flaskblog.posts.routes import posts
app.register_blueprint(posts)

from flaskblog.main.routes import main
app.register_blueprint(main)

from flaskblog.errors.handlers import errors
app.register_blueprint(errors)

return app```
#

and when i try to import discord_oauth i get a import error

frozen python
#

@versed python ok, I’m still messing around with card pictures too, there not lining right.

mental veldt
#

class Book(models.Model):
STATUS = (
(1, _('Available to borrow')),
(2, _('Borrowed by someone')),
(3, _('Archived - not available anymore')),
)

[...]

status = models.PositiveSmallIntegerField(
choices=STATUS,
default=1,
)
if you have a model like that, how can you add functionality for the user to create a new status to the choice list. one that doesnt exist already on the list. ie. a 4th status

versed python
#

@frozen python go to the bootstrap website, they have a good guide on cards along with images

#

@mental veldt should probably create a new model for that

lethal orbit
#

if you have a model like that, how can you add functionality for the user to create a new status to the choice list. one that doesnt exist already on the list. ie. a 4th status
@mental veldt you can't, really (AFAIK). Add an Other status and accept an optional other_reason text field.

mental veldt
#

@mental veldt should probably create a new model for that
@versed python how??

versed python
#

pm@mental veldt

mental veldt
#

@mental veldt you can't, really (AFAIK). Add an Other status and accept an optional other_reason text field.
@lethal orbit oh ok👍

versed python
#

@mental veldt no no it can be done

lethal orbit
#

I guess you could with another model and a relation.

#

And get the choices from the other table...

versed python
#

@lethal orbit yep, and should be pretty easy too

frozen python
#

@versed python I use Bootstrap all the time, just not with where the content is cycled through, so it’s just one card, that’s the template

versed python
#
class BookStatus(models.Model):
         status = models.CharField() 

class Book(models.Model):
       # other stuff
        book_status = models.ForeignKey(BookStatus, on_delete=models.SetNull)
#

@mental veldt

#

@frozen python still the html itself will be governed by bootstrap classes you use and you need to use a class to adjust the card image

mental veldt
#
class BookStatus(models.Model):
         status = models.CharField() 

class Book(models.Model):
       # other stuff
        book_status = models.ForeignKey(BookStatus, on_delete=models.SetNull)

@versed python ok let me try it out. Thank you

versed python
#

you're welcome

native tide
#

Django.
How do I show specific data to each group?
For example, I have this code:

{% for i in user.information.all %}
  <tr>
    <td><a class="btn btn-sm btn-info" href="{% url 'info-page' i.id %}">View</a></td>
    <td>{{i.topic}}</td>
    <td>{{i.full_name}}</td>
  </tr>
{% endfor %}

Now I want to do the same thing just for groups and not specific users, anyone has an idea?

frozen python
#

@versed python I just tried it, it’s still in a stacked

versed python
#

i am not that good at bootstrap so I don't think I can help further sorry @frozen python

icy frigate
#

anyone really good with curl?

lethal orbit
hallow jacinth
#

my git repo has 4800 objecys 0.0 how do i trim it down. I have a .gitignore, but maybe i added it too late nd some of those packages are still included

versed python
#

if you know what files you added by mistake, you can do git rm --cached file_path_or_folder

hasty dawn
#

Heey guys!

#

How u guys doing?

#

Did Someone here worked with uwsgi?

I'm facing some issues here.. :(

Trying to deploy a project with multiple threads and Flask application. But I can't get it to work...

I want the threads that i'm creating only in main process (right now it is beeing replied on every process), and I want flask (and just flask) in multiple processes... Is this possible at all?

frozen python
#

I’m creating a button to click to run a terminal command ....but I don’t think it’s registering right.

#

This is in VSCode

vague ibex
#

Hey there! I had something to ask! I'm asked to make a responsive design of a desktop-version website. Will it be okay if I display : none the desktop version and code the mobile-version separately and keep both the codes in a single file so that each of them load according to the screen size?

versed python
#

@frozen python is the file named tasks.json?

frozen python
#

@versed python it’s settings.json

versed python
#

@vague ibex it'll be okay but there are plenty of frameworks out there which you can use to have a single code base. one example is bootstrap

low blade
#

should i be using apache instead of iis on my windows laptop to dev a web api that will be hosted on an ubuntu server?

vague ibex
#

@vague ibex it'll be okay but there are plenty of frameworks out there which you can use to have a single code base. one example is bootstrap
@versed python alright ty! 😄

#

Just wanted to use plain html css js code tbh lol

#

Bootstrap is easy and short but it complicates things

frozen python
native tide
weary dragon
#

@native tide whym about groups?

native tide
#

Hey guys, do you know how after a form submission you can refresh the page?

#

Nevermind! Solved with redirect(url_for('function')) and adding returns on every if/else statement in the route 😄

sullen tusk
#

y'all im a programming

#

god

#

omfg

quick cargo
versed python
#

@frozen python is something wrong with your manage.py?

frozen python
#

@versed python no, when I hit the button it does that. When I type in everything manually, it works

versed python
#

@frozen python that's weird never really happened to me

frozen python
#

@versed python do I need to add something like ${}?

versed python
#

nope

#

i haven't tried with python manage.py runserver but my other commands work

maiden tulip
#

Hi, as you might know there are functions for a website to find out if the website is in focus. Does any1 know some test website that exists to test if it is in focus or not? I know it is something easy to program, but I am not at my dev environment rn.
A friend made me curious about what happens if you have multiple browser windows open (not tabs), for example with 2 monitors each having their browser windows.

frozen python
#

@versed python what other commands do you have? What does a layout of code look like?

hoary sable
#

is there a certain way to handle multiple forms in one page with FLASK??

warped timber
#

you can only submit one form at a time

#

by default

#

@hoary sable unless you do js stuff

#

plus by default submitting forms reloads the page

#

unless you use js to submit

hoary sable
#

oh ok so that's why i'm stuck for hours

#

is there a way to solve the problem ??

#

i have a page with a search input that display users and then i added radio buttons to vote for a user which means it's 2 forms in a page

vague mango
#

I'm having trouble reading external json files in Django

#

It is saying directory does not exist

#

Anyone have experience?

hoary sable
#

@warped timber any ideas ??

vague mango
#

So I'm having trouble setting the path to my file

native tide
#

can someone send a article or vid of where i can learn about DOM & events

vague mango
#

check out a video about Jquery @native tide

native tide
#

okay

#

@vague mango can u send the specific vid link and ping me when u sent it

vague mango
#

here hop in help chat and explain what you are trying to do @native tide

#

I'm in code/help @native tide

native tide
#

okay

#

i dont see that channel @vague mango

vague mango
#

scroll down

#

it's voice channel

native tide
#

oh

#

i cant talk tho

limber laurel
#

Is a good way of learning making small projects to practice specific skills?

vague mango
#

@limber laurel absolutely

native tide
#

im in

#

my mic dosent work

#

its broken

limber laurel
#

For example if I would want to make a more secure app maybe I should make a seperate sort of blog app maybe with nothin fancy on other things but higher security

native tide
#

i just need help with what dom & objects is

#

did u use solo leaRN?

#

dom

#

only DOM

#

no js

#

im learning js

hoary sable
#

check freecodecamp

native tide
#

ok

#

kk

#

yea

#

ight bro thx

#

i guess cya?

vague mango
#

maybe

#

LOL

native tide
#

lmao

fast basin
#

I want to detect the changes in my text editor Live for example if I added Heading with the Keyphrase Improve Grammar the messages on right will be marked as completed.
See these pictures for detail

native tide
#

where can i learn ES6?

dense bear
#

would anyone be able to help me with some Flask-SQLAlchemy related issues?

hallow jacinth
#

I FREAKING FIXED IT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

#

also, what issue are you having?

#

@dense bear

dense bear
#

well, I've got a fairly functional small app, and I'm trying to add a new table and form into the mix. The error I'm getting is that there are too many foreign keys associated with the new table though

#

I think I may not have a proper understanding of how to set the relationships up

hallow jacinth
#

hmm, maybe you are using foreign keys, when you are intending to use primary keys

#

I am not 100% sure why you would be getting that error though. might have to do with the way you set up your relational model

hoary sable
#

@hallow jacinth can i ask u i'm having issue with my flask website ??

hallow jacinth
#

sure I can try to help @hoary sable

dense bear
#

it says specifically that I may have intended to use a primary join, though I didn't think I needed one

hallow jacinth
#

if you take a help room up and show me what your models look like I may be able to help better

hoary sable
#

i have a page with a search input that display users by name and put them in a card and then i added radio buttons for each card to vote for a user which means it's 2 forms in a page but the voting system is not working is it something from flask itself ??? @hallow jacinth

#

but i'm not using wtforms

dense bear
#

oh uhhh, those seem occupied. I'm not sure how to go about making a new room. still new to this server

hallow jacinth
#

and steve let me look at something to try and see if I can find any hints

dense bear
#

I think I figured it out

hoary sable
#

@hallow jacinth take your time and thank you do u want me to send u my code . i didn't send it here because some ppl don't like to see code taking space in the chat

dense bear
#

shoot I think I reserved a room but I don't know where the room went. I thought it was named help-sodium

hallow jacinth
#

yeah, @hoary sable take a help room and let me see what your .html and route.py look like

hoary sable
#

ok let me add some comment to the code

#

@hallow jacinth i'm on help-oxygen

hallow jacinth
#

ok

warped timber
#

@hoary sable you can make them submit to 2 different endpoints

hallow jacinth
#

anyone have an idea why my db connection times out everytime a new row is added to a specific table? the connection times out, but when I refresh the route it sends duplicate messages ahaha

#

(postgress, heroku, flask issue)

hoary sable
#

@warped timber problem solved i forgot a line that render the page before the second if u can check more in help-oxygen guys noticed it there

frozen python
#

How do you create a Alias in VSC? I just got a tip to do that as a shortcut for runserver

acoustic oyster
#

idk, I use .bat or .sh for making my shortcuts

native tide
#

Should I stick to django template system or integrate react ?

acoustic oyster
#

I have moved away from django templates and now use react. I highly recommend it, it allows for much more flexibility, and creates much more interesting stuff imo

#

I would personally not use templates for any very serious project nowadays simply because react makes things so much more interesting and offers functionality that is essential on many projects

native tide
#

U also use redux or is context api?

#

I agree 2, react's better 4 serious web dev

#

An django as back end

acoustic oyster
#

I just use plain 'ol react with axios to make api calls for DRF backend, I am moving to graphql though as well

native tide
#

Gr8, I love functional components and hooks. u ever seen the YT channel DevEd ?

acoustic oyster
#

ohh, I dont think so. What do they do?

native tide
#

He's a web dev focused on using js

#

And has lots of react tutorials

acoustic oyster
#

oh, very nice. I have never seen any of his videos.

native tide
#

I learn it with his videos

#

Maybe I know Traversy Media ?

#

*you

acoustic oyster
#

I do not do a ton of front end xD I learned react mostly from docs and examples. I watched a quick video though.

#

but ty, I will have to remember these

native tide
#

I don't do front end that much but I'm currently learning it to get a job with my back end skills

#

I hate css

#

But have to study it

#

React docs are well documented

#

I like them

#

Not sure if this is the right chat to ask this. I am trying to use Kivy with Pycharm but I can't get a preview of my app no matter what I do. I have kivy and the dependencies installed but all I get is console output. No image or label. Am I missing a simple fix?

versed python
#

@frozen python was your issue fixed?

native tide
#

ok I will do that thank you

frozen python
#

@versed python not really, I created a bash_profile and a .bashrc file, but it’s not executing my commands

versed python
#

@frozen python alright tell me what exactly you want? because as far as I know, bashrc and bash profile files are not needed

frozen python
#

@versed python you can create shortcuts to create execute a terminal command

versed python
#

so in your current workspace create a folder called .vscode and a file inside tasks.json

#

then add the tasks you want to in that file

#

i sent you the website, just copy paste some default boilerplate code from there and you can extend it later @frozen python

#

also as far ik, you don't have to even touch the bashrc and bash_profile files

frozen python
#

@versed python I’ve tried that, but it didn’t work in the tasks. That’s what’s not executing right

versed python
#

maybe you could chain commands? like

#

source venv/bin/activate; python manage.py runserver@frozen python

vestal hound
#

&&?

frozen python
versed python
#

yeah

#

and as the other person suggested, you can also try replacing ; with &&. try out both

frozen python
#

@versed python should I only have one? Is it laid out right?

versed python
#

if you mean just one task, yeah that should do the trick

#

if you mean && then no, you need both

#

a single & will send the process to background and you'll be left without an activated virtual environment @frozen python

frozen python
#

@versed python I just typed in the snippet and it didn’t work

versed python
#

what error does it give?

frozen python
#

@native tide now there’s no errors but I’ll try it again

#

@native tide is says “ZSH: command not found”

versed python
#

you're pinging the wrong person lol

#

why don't you change your default shell to bash?

#

ctrl+shift+p -> change default shell

#

@frozen python

frozen python
#

I got it to work.... I just created “tasks” in VSC.

versed python
#

yay

onyx crane
#

**Django: ** (pls @me)
I'm successfully able to create database entrys out of ModelForms that are filled based on the fields provided in the form.
But how can i additionally pass the active user to the form.save() ?
(I want that every time a user creates a chracter this character gets assigned to him.) I have a correspending field set up:

class PlayerCharacter(models.Model):
    owner = models.ForeignKey(User, on_delete=models.CASCADE, related_name="playercharacter", null=True)
    ...

views.py

def charactercreation(request):
    form = CharacterCreationForm(request.POST or None)
 
    if form.is_valid():
        form.save()
        return redirect ("main:home")

forms.py

class CharacterCreationForm(ModelForm):

    class Meta:
        model = PlayerCharacter
        fields = {'pc_name', 'pc_age', 'pc_race', 'pc_class', 'pc_armor','pc_talent',
            'pc_attrCon', 'pc_attrStr', 'pc_attrDex', 'pc_attrMag', 'pc_attrSlh', 'pc_attrRfx', 'pc_attrLck', 'pc_attrPct' }
        


    def __init__(self, *args, **kwargs):
        super(CharacterCreationForm, self).__init__(*args, **kwargs)
        pass        
versed python
#

@onyx crane you'll have to override the savemethod instead of __init__ method

#
class CharacterCreationForm(ModelForm):
       def save(self, user):
              # do stuff with user
              return super().save()
        class Meta:
          # as above 
        ```
onyx crane
#

urgh i remember reading something that it can't or shouldnt be overriden or smth

#
  • what exactly do i do with the user ?
    i couldnt find any doc about how the .save method actually works
river ledge
#

Hey guys, does anyone have experience with github pages?

#

i've followed the documentation to the T and still can't get my custom domain to work

#

my github looks like:

#

while my domain site godaddy looks like:

frozen python
#

@versed python sorry I was pinging you!

versed python
#

@onyx crane what do you need to do?

onyx crane
#
def save(self, user):
        self.owner = user
        return super(CharacterCreationForm, self).save()

This didn't work.
Do i need to define the 'owner' field in fields to make it a part of the form ?

versed python
#

just tell me what you are trying to do, i feel like you are solving the problem incorrectly @onyx crane

onyx crane
#

oh.
well im trying to fill in the owner field of my model with the user who submitted the form, without using a form field where the user selects himself

versed python
#
if form.is_valid():
     character = form.save(commit=False)
     character.owner = request.user
     character.save()

this goes into your views.py @onyx crane

onyx crane
#

TypeError at /charactercreation
save() got an unexpected keyword argument 'commit'

versed python
#

did you remove the save method from the form? @onyx crane

zealous cloud
#

Hello can someone help me figure out how to query this data so its useable? I have this section in a flask route

if g.user:
        user_likes = g.user.likes
        print(user_likes)

the print statement is returning something that looks like

[<GovMembers O000172>, <GovMembers C001093>, <GovMembers C001091>]

I need the last bit, in this case the C001093 id part only so I can use it in my jinja template. How can i return just the ids?

For reference my 'Likes' model only contains an id, user_id, and item_id which would be the id number I'm looking for

onyx crane
#

wow! thanks Ignis!

#

i guess ill look up the commit False :) !

versed python
#

@onyx crane np

vestal hound
#

Hello can someone help me figure out how to query this data so its useable? I have this section in a flask route

if g.user:
        user_likes = g.user.likes
        print(user_likes)

the print statement is returning something that looks like

[<GovMembers O000172>, <GovMembers C001093>, <GovMembers C001091>]

I need the last bit, in this case the C001093 id part only so I can use it in my jinja template. How can i return just the ids?

For reference my 'Likes' model only contains an id, user_id, and item_id which would be the id number I'm looking for
@zealous cloud list comprehension

#

[like.id for like in g.user.likes]

#

more efficient: g.user.likes.values_list('id') (this should work)

frozen python
#

I was about to get a JetBrains subscription, but after learning how to use “Tasks” in VSC, I think I’m sticking with VSC

idle karma
#

Does anyone use AWS Lambda? I'm wondering if there is an environment variable available that I could inject into templates. So that if I have two versions of a website say, I could have the stack name or env name displayed at the bottom of the page so that I can tell at glance which one I'm looking at?

gentle ingot
#

Would it be considered bad practice to download bootstrap and strip what I need from it for my own css?

versed python
#

depends on what License they use, but it should be generally fine

gentle ingot
#

MIT copyright Twitter 2018. I know the copyright wasn’t needed but I found it funny lol.

#

So yeah legally I’m okay.

versed python
#

pretty much

lean saddle
#

can i ask a html css related question

willow plume
#

dont ask to ask

#

just ask

lean saddle
#

can someone please help me , i want to add a link inside a para like
<p style="css stuff"> blah blah blah <a href="link.com">text</a></p>
but this turns the entire para into a link and somehow the page code isnt what i wrote it says something <a class="icon"...> something instead of my <p> tag in the inspect element of the page
i am using vs code with live server

#

so no one can help me

willow plume
#

hm

#

i forgot most of the html i learned

#

imma relearn tomorrow

lean saddle
#

i didnt learn html

#

i didnt knew that u were suppose to

willow plume
#

?

lean saddle
#

😅

#

nothing

willow plume
#

sorry i couldnt help

lean saddle
#

thanks np

versed python
#

@lean saddle are you sure you're clicking inspect element on the right element?

lean saddle
#

yes

gentle ingot
#

Make a style tag with the css stuff or a css file and then use <a class=“css class”>

lean saddle
#

so i shouldnt use style =""

#

in the element

versed python
#

because what you have written is absolutely correct and should technically work fine

lean saddle
#

i stil dont get it wait let me show u

zealous cloud
#

@zealous cloud list comprehension
@vestal hound Thank you that did the trick!

gentle ingot
#

That works but can get messy if you are making a style for almost everything within the tags.

#

Look at w3school man at example.

versed python
#

the first rule of inline tags is 'never use them'

#

there is no rule 2

lean saddle
#
    Just a heads up, please make sure that you are aware that piracy is a crime and is also an immoral thing to do, so I suggest that you buy games rather than finding the cracks' cause believe it or not, the chance of a crack being a trojan or virus is quite high, so here is a friendly advice, go to your local shop and buy a DVD or CD. It's quite cheap. And please install some antivirus like <a href="https://www.malwarebytes.com/mwb-download/" style="color:rgb(24, 117, 160);text-decoration: underline;"> MalwayreBytes</a></p> ```
#

and here is what shows in the inspect element section

#
    Just a heads up, please make sure that you are aware that piracy is a crime and is also an immoral thing to do, so I suggest that you buy games rather than finding the cracks' cause believe it or not, the chance of a crack being a trojan or virus is quite high, so here is a friendly advice, go to your local shop and buy a DVD or CD. It's quite cheap. And please install some antivirus like </a>  ```
versed python
#

are you using normal HTML or some frontend framework?

lean saddle
#

<!DOCTYPE html>

versed python
#

I think you should be scared, it looks like your computer has gained intelligence

#

<!DOCTYPE html>
@lean saddle that's normal HTML

#

this should not be happening

lean saddle
#

that is what i thought

versed python
#

the browser doesn't randomly make changes to your code

lean saddle
#

😄

#

so i am screwed

versed python
#

are you sure you're opening the correct file?

lean saddle
#

could this be live server

versed python
#

idts

lean saddle
#

in vs code

versed python
#

I highly doubt it

#

why don't you check and open the file in a normal broswer like google chrome?

lean saddle
#

then is it my browser

#

i will try

versed python
#

yeah do that

mystic wyvern
#

guys anyone her can help for somthing in django

lean saddle
#

can i ask again

vestal hound
#

guys anyone her can help for somthing in django
@mystic wyvern don't ask to ask

#

just ask.

versed python
#

if you don't reply within an hour, i am gonna assume your computer has indeed gained intelligence and killed you

#

and is out for human blood

lean saddle
#

ok

mystic wyvern
#

@mystic wyvern don't ask to ask
@vestal hound ok,(:

lean saddle
#

😅

mystic wyvern
#

the for loop in file(html) dosen't work with me why?

vestal hound
#

what?

versed python
#

what are you writing in code @mystic wyvern

vestal hound
#

you're going to need to give a lot more details

mystic wyvern
#

{% for Board in bored %}

{{Board.name }}
{% endfor %}

vestal hound
#

...what is bored

lean saddle
#

@versed python sir thanks so much, its my browser,firefox is glitching

versed python
#

yay you're not dead!

lean saddle
#

tell that to my console i typed apt-get update && apt-get upgrade and i have been regretting it for 4 hours

mystic wyvern
#

...what is bored
@vestal hound The thing that will bring me back from databases

nimble epoch
#

Hi

versed python
#

@mystic wyvern can you show us the associated views.py?

mystic wyvern
#

ok

nimble epoch
#

Can anyone tell me what is flask-caching extension actually used for?

mystic wyvern
#

from django.shortcuts import render
from django.http import HttpResponse
from .models import Board

def home(request):

bored = Board.objects.all()

return render(request,'html.html',{'board':bored})
versed python
#

can you remove name and just write {{ Board }}

mystic wyvern
#

ok

versed python
#

wait

#

i get it

#

you have misspelled board in your views

#

both the spellings should be same

#

you have board and bored instead

#

you need to write {% for Board in board %} now

mystic wyvern
#

ok

#

ok i write it

versed python
#

yeah please do

mystic wyvern
#

ok in thes line what should i write {{Board.name }}?

versed python
#

no change required

#

just fix all spelling mistakes

mystic wyvern
#

didn't work

#

omg thanks

#

its workkkkkkkkkkkkkkkkkkkkk

#

no change required
@versed python thx man

#

@versed python REALLY THANKS i I tried to fix it for 2 day

tropic lance
#

I have a sanic webserver running on port 8000, how can I make it use nginx (where my ssl cert is)?

#

Each time I try and edit the config to use port 8000 it says the sanic server is already using it

#

Please ping me

jagged lark
#

@tropic lance you should bind your sanic server on ankther port, or even better don’t expose it

versed python
#

@versed python REALLY THANKS i I tried to fix it for 2 day
@mystic wyvern yeah np

hot kraken
#

Do i need any external security for my web app built with "Django and Angular"?

#

If yes...How?

nimble epoch
#

Hi, Can anyone tell me what is flask-caching extension actually used for?

coral raven
#

Used to cache data

#

so webpages load faster

versed python
#

@hot kraken security from what?

fair light
#

i am taking a result from a form in html and printing it. , now the result is being replaced.. when i give the data again i need to give the result on a new line..any idea?
to make it in different line?

#

ping me if anyone can help

lethal orbit
#

Do i need any external security for my web app built with "Django and Angular"?
@hot kraken firewall, protect your DB, make sure to handle CSRF/XSS ....

#

Django does take care of a lot of it OOTB

hidden gulch
#

Hello , where can I ask questions about git?

jagged lark
hot kraken
#

@versed python
From unauthuroized hackers or bots

versed python
past cipher
#

Does anyone know where I could find a junior developer, who wants to create a front-end to add to their portfolio? For the past 3 weeks, I've been working on a e-commerce store like Sellfy. For creative people to sell their digital content/subscriptions. The only problem is I suck at front-end, and have no plans to be a front-end developer. I have 70% of the back-end done, but the front looks pretty shit

vague ibex
#

@past cipher if you're willing to pay the front-end dev, you can try fiverr

past cipher
#

right now it isn't paid. Hoping to find someone who wants to add something to their portfolio to show potential employers. If I do end up paying, I will hire a non junior

vague ibex
#

tbh ngl I couldve worked but your profile pic scares me

past cipher
#

lol

#

I get this all the time

#

when i signed up for Discord, I googled "avatar"

#

and chose the first one 🤣

sinful mantle
#

When I make a list of webelements using driver.find_elements_by_css_selector('div[role="row"]'), how is the elements of the list like?

merry geode
#

I setup a login process using DRF for my Vue.js front-end. But any tutorial I read related to authentication ends at sending the token. I'm just not able to find how to use that token to actually authenticate user requests.
Any help or guide would be appreciated

versed python
#

@merry geode You using axios?

merry geode
#

Right now I'm just trying it out on Postman

versed python
#

but you'll be using axios right?

merry geode
#

Yes. So far I've used Axios for other things

#

Basically what I want is once the user is authenticated, when they call other APIs, I should be able to know

  1. That the user is authenticated
  2. The identity of the user from the authentication token
versed python
#

@merry geode have you heard about nuxtjs?

#

its basically vuejs on steroids

#

if you use that, i wrote a tutorial on how to setup and use user authentication with Nuxtjs and drf

merry geode
#

If you can link me to it, that would be really great

#

However, right now my problem is on the Django side. I don't know how to consume the token in the requests after the user authentication is done

versed python
#

wdym?

#

once user authentication is done, you just need to make sure that you are sending the tokens from frontend and drf will take care of authentication itself

uncut spire
#

I'm looking for advice on what to write tests for in an application that essentially wraps a number of calls to other services in a single endpoint--obviously, testing my network connection is useless for the purpose of testing--is there anything beyond schema validation that people commonly do?

versed python
merry geode
#

once user authentication is done, you just need to make sure that you are sending the tokens from frontend and drf will take care of authentication itself
@versed python Exactly, this. How do I implement this in my other APIs

versed python
#

@merry geode read up 👆 on the tutorial, and if you need help after that, you know where to find me

#

also you'll not need to read part2

wild thunder
#

guys

#

i'm working in a project

#

we are having a problem with json encodings

#

that could be fixed adding 4 lines in the json package library

#

is that possible?

frozen python
#

Should Django be used for styling? Or just make things functional?
....is Django good to focus on or is it mainly Python and let React and Vue be the true styling for front end?

hallow jacinth
#

anyone have any idea why everytime I try to post on my heroku hosted site, it says server error?

#

the logs points to something that doesn't quite make sense

woven gorge
#

Anyone good with selenium?

merry geode
#

Why don't you just ask the question?

sly canyon
#

@woven gorge don't ask to ask

woven gorge
#

sry

sly canyon
#

You'll find out if you get a response or not.

versed python
#

@frozen spear template_name = 'core/AjaxTemplate.html'

woven gorge
#

Using selenium and actions to scroll to a specfic element on a webpage so i wouldnt get "Message: element click intercepted: Element <div id="loginButton" class="button">...</div> is not clickable at point (588, 650). Other element would receive the click: <div class="footer">...</div>" as an error.

#
driver.implicitly_wait(5)
login_button = driver.find_element_by_xpath('/html/body/div[2]/div/div/div/div/form/div[2]/div[1]/div')
action.move_to_element(login_button).perform()
login_button.click()
#

Still getting the same "not clickable at point (x,y) error.

#

Anyone know why actions is not moving to the particular element

versed python
#

@frozen python django can easily handle a good looking static website but most websites today are dynamic. That's why all these frameworks like Vue and React are getting famous.

#

You will be making more functional websites using a frontend framework, but will have a tradeoff of cost, learning curve and time and energy spent

frozen spear
#

@versed python did that

#

i tried every path

#

im doing that for a test

#

understading ajax

#

its not a big deal so ye

versed python
#

does it work?

frozen python
#

@versed python cost as in it’s more time to do front end with React/vue? But tho, can I focus on Django for the Database part? Then other then that, just python in general?

frozen spear
#

i redid it anyways

#

cuz it was on forms only

#

now added an actual model

versed python
#

@frozen python I meant the cost you need to hire devlopers to do your frontend. If it is a one man job, then it will take a lot of time yeah

#

you can focus on django and then move on to django rest framework and then to a frontend framework (Vuejs in my case). This is what I did but you can do it differently

frozen python
#

@versed python what’s a difference between Django and a rest Framework?

versed python
#

thats a very broad question

astral musk
#

Anyone have any idea why my flask app running on a rpi with nginx and gunicorn gives me a 403 error whenever I try to read a page that contains info from a database?

versed python
#

you will be better off looking at django rest framework website @frozen python

frozen python
#

@versed python ok, I mean that as in Django with python vs ingeneral of a rest Framework

wanton ridge
#

anyone have a website design which i can fo it myself?

vague ibex
#

anyone have a website design which i can fo it myself?
@wanton ridge what do you mean?

wanton ridge
#

@vague ibex i mean i wanna create a website with html and css but i dont know how to design it maybe u know it

vague ibex
#

@vague ibex i mean i wanna create a website with html and css but i dont know how to design it maybe u know it
@wanton ridge Yea, I do. So, what is the specific topic you need help with?

wanton ridge
#

i have this @vague ibex

#

maybe u can give me any improvements?

vague ibex
#

Looks really nice

#

you using flexbox/grid for the pc pics?

versed python
#

@frozen python python can't be used for frontend, atleast not as extensively as Javascript

#

so if you want to make a good looking reactive website, you'll have to learn Javascript and then a framework like Vuejs or React

wanton ridge
#

@vague ibex yes bro

frozen python
#

@versed python I have been using them. I’ve been focusing more lately on Python/ Django, because I don’t like how vaug it is with styling..... not that radius, or color.... or wait yes that color 😂

native tide
#

if u learn flexbox/grid then u got a job

#

trust me U got a 5 pound paying job

versed python
#

@versed python I have been using them. I’ve been focusing more lately on Python/ Django, because I don’t like how vaug it is with styling..... not that radius, or color.... or wait yes that color 😂
@frozen python yeah I find Vuejs difficult too but I am slowly learning

frozen python
#

@versed python vue has a bit of its “own” syntax. React uses more typical vanilla JS syntax. I prefer React vs Vue, but vue does have nice corner cutters

versed python
#

@frozen python from what I have read from their docs, vuejs is supposed to have an easier learning curve than React

frozen python
#

@versed python yes, but I do prefer React because it has more support and add ons to use. I like Vue, but I think React has a more stable base

versed python
#

and a larger user base too. the industry prefers React due to its maturity. I understand where you are coming from. @frozen python

frozen python
#

@versed python I like Vue tho, because once you get the hange of the “new” syntax, it’s nice. But there are things like Famer Motion and Styled Components I like with React, vue dosnt have

versed python
#

yeah ik nothing about them lol. Vue is growing in popularity quite quickly so that's a plus @frozen python

frozen python
#

@versed python I’m at the point of that, I want to get a position, even if it’s a free position, just to gain the “work flow” experience and tips.

versed python
#

I'm definitely not at that point, especially with frontend since I am just starting out. Have you checked out codementor.com? @frozen python

frozen python
#

@versed python no, I will! So to start out.... Traversy MEDIA, Dev-Ed, The Net Ninja, Corey Shaffer ... ARE GREAT!!! also Blondie Bytes

#

@versed python for YouTube channels to watch..... those are great

versed python
#

i am trying to design my own website for now, but yeah I have encountered some of these

#

i didn't know Corey was also involved with frontend @frozen python

vague ibex
#

@versed python no, I will! So to start out.... Traversy MEDIA, Dev-Ed, The Net Ninja, Corey Shaffer ... ARE GREAT!!! also Blondie Bytes
@frozen python Dev-ed is a legend

hoary bramble
#

Hi, everyone.
Does anyone used social APIs with Python?
For instance, Instagram, Telegram, Facebook, OK, VK or Youtube?
If so, how we can identify if a user watched, liked or commented that video.

versed python
#

@vague ibex I'll check them out then, thanks. and thanks @frozen python too

vague ibex
#

Which language are you trying to learn ignisda?

frozen python
#

@vague ibex hes very down time earth! Even if he makes a mistake, it’s nice to see how to fix it

cold socket
#

@hoary bramble You can either do it through the website's API if available or create a bot that watches a users activity

brave bolt
#

Hello there

frozen python
hoary bramble
#

@cold socket Yes, I learned their APIs. For instance, Youtube V3 API. But there is no way to identify if user is liked some video. But a website vkmix.com is able to identify.

brave bolt
#

So in oAuth2 when someone is authenticate dhow do I deal with their AUTH and REFRESH keys while the are "on" the app so they don't collide with others

frozen python
#

Also on “Skillshare.com” if you get stuck with JavaScript..., “KALOB TAUKIN” is great!

hoary bramble
#

@cold socket How I can get allowance from Youtube to identify if user is liked or not?

frozen python
#

I like how vue has it laid out with props, methods and that...: I’m messing up in React because I’ve been focusing on python

frozen python
#

I’m mainly wanting to focus on, what’s the best “geared towards one thing”.... type of part of web design. Again, I don’t like the vague styling. I like how Django works.... but it’s still Jinja styling. But, I like possibilities of the back office right away. But, other than Datascience or machine learning... what’s a “need” of python that you don’t have to have college?

quiet loom
#

Hello how long does it take to learn django and where to start? Which skill level needed?

near forge
#

@quiet loom Django docs & youtube. Intermediate python skills, probably a little knowledge about how website works & html +css if you want to do frontend aswell.

hoary bramble
#

Hi, everyone.
Does anyone used social APIs with Python?
For instance, Instagram, Telegram, Facebook, OK, VK or Youtube?
If so, how we can identify if a user watched, liked or commented that video.

#

How we can access user informations?

#

This is for an app to multiply likes of users like vkmix.com

near forge
#

@hoary bramble you would have to look at each individual API and see what they offer. I'm note sure if they offer user history, sounds like an invasion of privacy.

hoary bramble
#

you would have to look at each individual API and see what they offer. I'm note sure if they offer user history, sounds like an invasion of privacy.
@near forge No it is not invasion. Just the app helps a user to multiply subscribers.
But for that I should check if user is watched and liked the video we give or subscribed to the channel we gave its link. Then if I know the user subscribes to a channel which we give, we give user some coins. For that coins they can buy subscribers.

#

I read but there is no way to do that.
But how VKmix.com identifies if user is liked a video or not.

#

I read full API docs.

#

But no way.

versed python
#

@vague ibex Vuejs

hoary bramble
#

Yeah, I understand what you mean.

#

Thank you very much.

#

@glacial night What do you think?
Which one is easier to do first?
Identifying and getting user data from Instagram, telegram, facebook, vk, ok, tiktok or youtube?

swift sky
#

how would I embed a variable that is a dictionary, from one .py file, into an html file

#

I'm doing a flask app

#

just trying to do a table essentially

errant spear
#

@swift sky Are you using flask templates?

swift sky
#

yes

#

any ideas @errant spear

errant spear
#

So you would need to pass the dictionary to the template in order to display it on the HTML file which can be achieved with

return render_template('template.html', dict_to_be_passed = dictName_in_py)
#

then in the template.html you can do

<h3>DICTIONARY: {{ dict_to_be_passed }}<h3>
#

and to display separate fields

<h3>DICTIONARY FIELD: {{ dict_to_be_passed['field_name'] }}<h3>
#

@swift sky

#

Does that make sense?

swift sky
#

so i would need to make a separate template for the actual table file

errant spear
#

No you can work with the template you currently have

swift sky
#

ahh

errant spear
#

Lets say you currently have

return render_template('index.html')
#

and index.html looks like

#
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    This is my HomePage
</body>
</html>
#

Then you can change it to

return render_template('index.html', dict = dict_in_py)
#

and index.html to

#
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    This is my HomePage
    {{ dict }}
</body>
</html>
#

Does that makes sense?

#

Basically you are passing an argument to a function

#

and accessing that argument in the template

swift sky
#

yes thank you

#

your guidance helped me see that i actually need to edit some code before i even work on importing

#

the scope of the dict im trying to import isn't set correctly, and I need to edit something else as well

errant spear
#

Glad to help 🙂

#

If you need anything else feel free to ask

native tide
#

Who needs help with flask

broken fjord
#

lel me but it's against the rules 😢

#

btw who can talk to me in private chat i need to talk about requests cause when i asked here they said it's against the rules

frozen spear
#

for some reason its also poppin that in the cmd

stoic prairie
#

I've been building a discord bot integrated with flask so some actions can be done on the web. I'm not too far in but having some issues and starting to wonder if I should be using django instead of flask.

Also when I say on the web I mean specifically in internal browser at this point. It might be cool to add it to "the web" at some point but there is no need for what I want to do with managing users and doing backups.

native tide
#

Depends on what the issue that youre having is if I would recommend switching @stoic prairie

#

I initially started Django and then quit and went to Flask, and then I realized that both are good for different things

stoic prairie
#

I've been trying to use threading with flask and a lot of the errors I came up with people on stackoverflow say it is flask issue with not supporting threading

native tide
#

Ah, okay. I definitely dont have any input on that. Ive never tried to use threading on Flask.

brave bolt
#

Hello hello

native tide
#

But uh... I know that a lot of times with Discord bots in python, there are situations where you cant do things traditionally apparently, like unit tests. And I believe the way people handle that is by separating their logic from the command structure. Im not sure if that would help you here...

#

But maybe you could use Flask without threading, which you are using in the bot, but not in Flask? Not sure about that one. Ive never written multiprocessing code at all tbh

hallow jacinth
#

Could someone helpme figure out why heroku still tries to connect to elasticsearch even though I have logic that says if there is no url don't use ?

#

Locally, my program ignores the elasticsearch integration when I don't give a URL, but heroku keeps trying to use it

noble star
#

Is there like an article that gives a comprehensive view of a website

#

I am talking like the path from HTTP entering the system, processing it, outputting it, sending the request back etc.

#

Because it learning flask and trying to deploy a website but I don’t REALLY understand what is happening

strong oriole
#

can u connect flask + discordwebhook lib?

quick cargo
#

yes

strong oriole
#

dope , time to learn flask instead sleeping to school lmao

quick cargo
strong oriole
#

on my github u can find what lib im using for webhooks , its much simpler for me

quick cargo
#

d.py is pretty much the only safe one other than doing it raw yourself

#

the others ive seen are well, spammy in places

strong oriole
#

wdym?

quick cargo
#

some of them take lists of webhooks then just flood discord with webhook posts

#

which will get your ip ratelimited and probably banned for a bit

#

its fine if youre only sending like 1 or 2

strong oriole
#

o.0 , yea i used discordWebhook or something liek that lemme check fo embed generator

quick cargo
#

but i wouldnt use those sorts of things for multiple webhooks because you'll get hit by ratelimits hard if youre not carful

strong oriole
#
from discord_webhook import DiscordWebhook, DiscordEmbed
#

thats what i used

native tide
#

Very quickly actually. I havent tried it in

strong oriole
#

and didnt have problems with it yet

native tide
#

Discord but other services I have seen it be a thing

quick cargo
#

I doubt you will until you send lots

#

Btw if you're uploading files the ratelimit is much lower than 50/s globally

#

cloudflare will get you before discord does when uploading files

strong oriole
#

i mean , my progam is universal , u need to give it your webhook and nobody else can use it because its stored localy and its overwrited everytime u upload new webhook link , if u want to check code its here https://github.com/micho44/EmbedGenerator

quick cargo
#

that should be fine

strong oriole
#

its not uploading webhooks anywhere other than local stored json

#

it just uses it to send the embed

#

for flask html is needed for input fields and buttons right? first time working with web dev

quick cargo
#

pretty much

#

honestly you could just do a form

#

and submit that sends a POST request with the form

#

would be the easiest

strong oriole
#

that doesnt tell me to much :/ like i use requests.post function? or what?

#

it my first time working in these regions , i only woked with local GUI apps

quick cargo
#

no i mean litterally the HTML forms system

strong oriole
#

yoooooo , that forms system might actually work , but how can i get data that has been typed in?

quick cargo
#

its sent as a POST request by the html to the server

#

read through the link and watch a video on flask's forms system

strong oriole
#

https://www.youtube.com/watch?v=9MHYHgh4jYc - will this work? just dont want to waste time im yet on #3 tutorial and if this isnt what i should be using then i just wont watch it yet

In this flask tutorial I show you how to use the HTTP request methods Post and Get. The POST method will allow us to retrieve data from forms on our web page. In later videos we'll get into more advanced topics relating to login sessions and using POST methods to retrieve secu...

▶ Play video
noble star
#

I’m supposedly supposed to make a secret key for Flask but where do I hide it, so that it does not show up in my code?

strong oriole
#

secrets.py

key = "what ever key"

main app

from secrets import key
``` ?
noble star
#

Say like you have other developers working on a project but you don’t want them to know what the Secret Key. they could just peek at the secrets.py folder and see what the key is

vestal hound
#

I’m supposedly supposed to make a secret key for Flask but where do I hide it, so that it does not show up in my code?
@noble star it's fine for it to be in your code

#

as long as your code is not public.

noble star
#

Oh ok

vestal hound
#

Say like you have other developers working on a project but you don’t want them to know what the Secret Key. they could just peek at the secrets.py folder and see what the key is
@noble star in this case

#

environment variable

#

or local file

#

that isn't, say, committed to VCS

strong oriole
#

@quick cargo i want to thank u for helping with that form suggestion , it works as i wanted! 😄

quick cargo
#

Np 👍

frozen python
#

I tried adding a second user to my Django app, but it won’t let me log into it. I created a new name and password, typed it in exactly, and it didn’t match

vestal hound
#

I tried adding a second user to my Django app, but it won’t let me log into it. I created a new name and password, typed it in exactly, and it didn’t match
@frozen python you didn't use .create_user

#

right?

#

you used User.objects.create or something

frozen python
#

@vestal hound I did “create super user” but I went in and clicked on “create user” and I created one, but it didn’t let me log in.

#

@vestal hound my super user works fine

vestal hound
#

okay, go back

#

you created your user

#

using the admin panel GUI?

#

not programmatically?

frozen python
#

@vestal hound correct. I just created it in Super User.... logged out and tried to log in as that new user.... didn’t work

vestal hound
#

hm.

#

did you change your user model?

#

any errors in the log?

frozen python
#

@vestal hound no

native tide
#

So, if anyone would look at my Django project structure... https://paste.pythondiscord.com/oberolipow.rb

I'm not sure how to go about having common modules. You'll notice that Ive put utils.py and constants.py at the root, which is well outside of project and the apps within it.

I'm having trouble reaching out from one app where I need code from another. For instances, from */users back out to another app. So the way ive done it is just to throw common modules at root and use the entire project as module for importing

in ts_backend/users/views.py:

from ts_backend.users.models import User
from utils import get_context

This was working for a awhile... but I did some refactoring and some time passed...

And now when I run

$ pwd
/home/shaen/PycharmProjects/term-story-back
$ python ts_backend/manage.py runserver

Im getting error :

...
  File "/home/shaen/PycharmProjects/term-story-back/ts_backend/users/urls.py", line 3, in <module>
    from . import views
  File "/home/shaen/PycharmProjects/term-story-back/ts_backend/users/views.py", line 3, in <module>
    from ts_backend.users.models import User
ModuleNotFoundError: No module named 'ts_backend'
#

I just added an __init__.py that wasnt there before and it didnt help. It was working last week

#

If I just enter a console and type import ts_backend it does it. But from the ./ts_backend/users/views.py or any other file at that depth, it doesnt believe that it is.

#

from .models import User instead of from ts_backend.users.models import User worked, but now... its utils that isnt a module.

#

TLDR, how do you have a common app in django for utils?

versed python
#

@native tide i usually create a new app called utils and put things like common permissions, paginators and mixins in that app

native tide
#

yeah, I moved those files to very root because at the time I hadnt figured out yet why I was having trouble importing a single utils.py file from outside the apps and I was trying and failing to do relative imports.

Now I have read a lot more about different project structures and Im just trying to tweak it to be a lot better than what it is.

#

What i was trying to do right now is have a single apps.py file in the project rather than in the apps. But it occured to me half way through getting it there that this makes my apps not modular.

#

So Im setting it back 😛

#

it should be app.py though, which I would change if not for convetion, since it will only ever have one class.

onyx crane
#

Django
Is there anyother way to change an objects value, that uses strings as an identifier ?
Instead of object.field1 = 0 something like object['field1'] = 0 ?

vestal hound
#

Django
Is there anyother way to change an objects value, that uses strings as an identifier ?
Instead of object.field1 = 0 something like object['field1'] = 0 ?
@onyx crane hm

#

why?

dapper tusk
#

I mean, setattr should work

native tide
#

Hello everyone, is anyone an expert in flask sqlalchemy?

#

I have a problem in delete schemes in Association Objects

stable kite
#

anyone know what is the use of methods of model field of django from_db_value() and to_python().

alpine fiber
#

hello, so i was starting off learning flask. I created my first flask file with just a '\' directory and created a sample html file to render, but i am getting a jinja2.exceptions.TemplateNotFound error. They are both placed in the same folder and i am not very sure on how to fix it. I read something about putting it in a templates folder but couldnt quite follow. Any assistance would be greatly appreciated

mental veldt
#

sqlite3.IntegrityError: NOT NULL constraint failed: accounts_user.views

somebody help me understand what this error implies in django

alpine fiber
#

okay so i got rid of my render template thingy in my python file, but im still getting the same error, which is extremely strange

#

considering im not even calling a HTML file anymore, its giving me a "jinja2.exceptions.TemplateNotFound: test.html" still, despite me not calling test.html

#

oh i think i got it

#

lemme just check

versed python
#

@mental veldt your User model has an attribute called views which is not getting any value assigned to it

alpine fiber
#

nope i did not lmao

mental veldt
#

@mental veldt your User model has an attribute called views which is not getting any value assigned to it
@versed python I was trying to create a custom user with AbstractUser. Could this be because i havent added any views yet?? do I need to add views before making migrations??

#

@versed python oh sorry I get it. I was thinking about the views module, forgot I have a views field in my models. lol

alpine fiber
#

alright i finally figured it out, like a tool i had another flask app running simultaneously

versed python
#

@mental veldt not really this is not a models problem

#

yeah you got it

@versed python oh sorry I get it. I was thinking about the views module, forgot I have a views field in my models. lol
@mental veldt

mental veldt
#

@versed python Yeah thanks

versed python
#

you're welcome

mental veldt
#

@versed python How are you so good with Django?? Its like you know everything

umbral echo
#

anyone know what is the use of methods of model field of django from_db_value() and to_python().
@stable kite

You can use them to convert values.
From DB to python object : from_db_value() and to_python() will be from user input value to python object, this method is also called in the clean() method used to validate forms.

You can find more info in Django doc :
from_db_value() : https://docs.djangoproject.com/en/3.1/ref/models/fields/#django.db.models.Field.from_db_value
to_python() : https://docs.djangoproject.com/en/3.1/ref/models/fields/#django.db.models.Field.to_python
Converting values to Python objects : https://docs.djangoproject.com/en/3.1/howto/custom-model-fields/#converting-values-to-python-objects
Form and field validation : https://docs.djangoproject.com/en/3.1/ref/forms/validation/

versed python
#

i spent a lot of time wracking my brain over it, and have encountered most of the problems that get asked here myself. back then i wasn't on Discord so I had to do hours of research before I found out a solution, so maybe that's the reason?
thanks for the compliment though @mental veldt

mental veldt
#

@versed python you are welcome. I always find solutions for django problems on discord thanks to people like you

versed python
#

the pleasure is all mine :D

nimble epoch
#

@native tide whats wrong with your models?

mental veldt
#

@versed python Which one would you recommend using when creating a custom user?? Either AbstractUser or AbstractBaseUser? I have read articles that warn a lot against the use of AbstractBaseUser

acoustic oyster
#

I usually use AbstractUser, AbstractBaseUser is only really for a super high level of control and customization, from what i understand. Ive never actually needed to use AbstractBaseUser though

versed python
#

they're right, this is what I do too

mental veldt
#

@acoustic oyster @versed python I was trying AbstractBase user and I have found myself in a big mess.

#

maybe I should take that route

versed python
#

as @acoustic oyster said, you should only go with AbstractBaseUser when you know what you are doing

#

AbstractUser is more than enough for most projects

acoustic oyster
#

Haha, I did the same. You could maybe inherit from abstract user? Lol.

I ended up hard coding a lot of things that I needed because we accidentally used baseuser

mental veldt
#

I also have this project where I want to have like a number of views counter which increments everytime someone views a profile. what would be the best approach?

versed python
#

implement this on the view level maybe? are you using rest_framework?

mental veldt
#

@native tide am using rest_framewor

#

I added a views field on the models as an IntergerField then i was thinking I would have a function in the views module. but what I want is to detect that someone has actually viewed the profile.... I have no idea how to do that

versed python
#

can you send the view logic itself.? if you use class based views, maybe you can override the get method and increment the view attribute? @mental veldt

mental veldt
#

I dont have the logic. I deleted what I was trying. but I think it had
def views_counter(self, request):
views = 0
if (someone visits the profile):
views =+1
retrun views

versed python
#

nope, use rest_framework.views.RetrieveUpdateView for this and override the get method. Your code will be much smaller this way.

mental veldt
#

RetrieveUpdateView works for both get and put methods right?

versed python
#

yeah and also PATCH i think

mental veldt
#

Isnt PATCH the same as PUT?

vestal hound
#

Isnt PATCH the same as PUT?
@mental veldt PUT is for full updates

#

PATCH is for partial updates

#

basically.

stable kite
#

@umbral echo thanks

lethal orbit
#

What is the de facto standard for RESTful Flask?

#

In case I decide to apply for a job that uses that instead of Django and ariadne like I would prefer

#

Flask-RESTful any good?

mental veldt
#

PATCH is for partial updates
@vestal hound ok

broken briar
#

Hey Guys

I currently using Django with the Rest-Framework + Django Filter. Im happy so far but i ran into a problem:
How can i filter my model with an "or" condition instead of "and"?

Exp:
url.com?param1=abc&param2=bca

in the current situation i only get the results back when both conditions are true
but i want an "or" condition. So if any of the fields match -> return

lethal orbit
broken briar
#

I know about the Q Object, but can i somehow get this into this structure i currently have


class myFilter(FilerSet):
  field1 = filters.Filter(field_name='field1, lookup_expr='icontains)
  field2 = filters.Filter(field_name='field2, lookup_expr='icontains)
  
  class Meta:
    model = myModel
    fields = ['field1', 'field2']

class Viewset(Modelviewset):
  queryset = myModel.objects.all()
  serializer_class = ...
  filter_backends(django_filters.rest_framework.DjangoFilterBackend)
  filterset_class = myFilter

``` @lethal orbit
native tide
#

If you have time to look at my Django models, they're pretty simple. I keep getting django.db.utils.ProgrammingError: relation "users_playeraccount" does not exist.

I've reset the db, dropped the tables and the entire database multiple times, created it again, so i think it has to do with that models file unless Im failing to remove everything I need to remove to start over in postgres.

Originally this problem was a "are you sure you want to change this name" and then fails. Now its just that error.

https://github.com/shanerowden/term-story-back/blob/master/project/apps/users/models.py

honest dock
#

any idea why?

#

oh nevermind, just tried this and it worked:

path('<int:pk>/', views.driver_details_view, name='driver_details'),
cold anchor
#

if the routes are all the same, the pattern matching ones should go last

deep owl
#

can someone help me to build a website?

versed python
#

@deep owl no one is gonna do that. we help when you get an error

deep owl
#

no i mean codings

#

where to start?

versed python
#

that's just too broad a help to ask

deep owl
#

where to start i mena

#

mean

versed python
#

what do you know about web dev?

#

@deep owl

deep owl
#

i have no idea thats why im asking

versed python
deep owl
#

i want to build a site

versed python
#

here's an excellent series

deep owl
#

by my own

#

okay thank you

versed python
#

actually you have to choose between flask and Django

deep owl
#

what's good for a beginner?

versed python
#

there are a few other frameworks but idk about them

#

Flask is generally easier, but I personally started with django and find it easy enough

#

you should look up a guide on internet about flask vs django and then choose one @deep owl

deep owl
#

Django

#

should i watch the video?

versed python
#

yeah

#

get started with it. you'll probably understand absolutely nothing the first time you watch the series

#

don't worry you'll start getting it soon

#

just make sure you follow along

deep owl
#

okay thank you, can i add you on discord?

versed python
#

yeah sure

deep owl
#

okay

thick cove
#
Sep 11 13:39:19 gamestars apachectl[45630]: AH00526: Syntax error on line 49 of /etc/apache2/sites-enabled/gamestars.conf:                                                                                         Sep 11 13:39:19 gamestars apachectl[45630]: Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included in the server configuration                                                  Sep 11 13:39:19 gamestars apachectl[45611]: Action 'start' failed.         

Following a tutorial where I was told to download libapache2-mod-wsgi-py3 but then I get the above error ^
From what I've found on stackoverflow I need to install libapache2-mod-wsgi instead but this says it'll uninstall libapache2-mod-wsgi-py3

mystic wyvern
#

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/board/{%25url 'home' %25
Using the URLconf defined in post.urls, Django tried these URL patterns, in this order:

admin/
[name='home']
about/
board/int:boerd_id [name='board_topic']
The current path, board/{%url 'home' %, didn't match any of these.

You're seeing this error because you have DEBUG = True in your Django settings file. Change that to Fal why this??????????

versed python
#

@mystic wyvern you need to go to http://127.0.0.1:8000/board/12/ or some other integer like that

#

guys should I handle notifications in the frontend in the backend or frontend?

#

meaning do I create the notification data in the frontend and thyen send it to the backend to save in a model, or create the notification in the backend and send it to the frontend?

lethal orbit
#

What is the notification for?

versed python
#

for example "your Post was created and published successfully" @lethal orbit

#

ideally I should do the logic handling in the backend right

lethal orbit
#

Depends...

#

If you are pushing from the client to the server, you can save it in indexeddb as pending....

versed python
#

whats indexddb? I am using Vuejs

lethal orbit
#

Then send the request to the back-end. When the promise resolves, you sent a client-side notification.

versed python
lethal orbit
#

Indexeddb is optional.

broken briar
#

Can implement a Q Object into this code?

class myFilter(FilerSet):
  field1 = filters.Filter(field_name='field1, lookup_expr='icontains)
  field2 = filters.Filter(field_name='field2, lookup_expr='icontains)
  
  class Meta:
    model = myModel
    fields = ['field1', 'field2']

class Viewset(Modelviewset):
  queryset = myModel.objects.all()
  serializer_class = ...
  filter_backends(django_filters.rest_framework.DjangoFilterBackend)
  filterset_class = myFilter
versed python
#

Then send the request to the back-end. When the promise resolves, you sent a client-side notification.
@lethal orbit yeah this is what I was thinking too

lethal orbit
#

What modern sites do...

#

They store data in indexeddb (which is just a client side DB). If it fails, you give the user an option to retry.

versed python
#

is it some kind of localStorage?

lethal orbit
#

But yeah, if you send requests from the client to server, don't store notifications on the back-end. Send the request in a promise, and when it succeeds, then() notify the user on the client.

#

Yes and no. A more proper DB.

#

You could use LocalStorage too (or not store it at all).

versed python
#

But yeah, if you send requests from the client to server, don't store notifications on the back-end. Send the request in a promise, and when it succeeds, then() notify the user on the client.
@lethal orbit but what if I have a Notification model for storing them? I actually want to store them

lethal orbit
#

You really only need to store notification on the server for server events...

#

User A pushes a message to User B on the back-end... the server notifies User B that they have a new message

#

For upload succeeded, I wouldn't bother, tbh

versed python
#

so you are saying I shouldn't store "Your post was saved and published successfully" in my django backend database?

#

@lethal orbit

lethal orbit
#

Probably not.

#

Sounds like pointless information to me

versed python
#

Well then should I delete the Notification model altogether?

lethal orbit
#

If it's just for client events, I would say probably, yeah :p

versed python
#

so what would you use a Notification model for then?

lethal orbit
#

As I said, if the server sends notifications from another source, it makes sense to have one.

#

"A new movie you might like has been added"

#

User foo sent you a $5 virtual gift.

#

Those require some action from the server.

#

User sending stuff to the server is a client-server interaction, not server-client.

versed python
#

alright, so from what I see, I should probably keep the model but not use it for useless stuff like 'Your post was saved and published successfully'

#

and just display it on the client side and not bother sending it to the backend right?

lethal orbit
#

Yup

#

If you don't have server events to notify the user about, you can delete the model. No need to delete it now, though. Take some time and see whether there is a use case for it.

versed python
#

yeah as of now I will keep it as it is. Thanks @lethal orbit you helped a lot

weary dragon
#

Can i use asyncio in a flask app to wait for a db query? or that's not a case?

quick cargo
#

sorta

#

its pretty pointless

#

just use a standard driver

twilit dagger
#

How do I use JS files with Django?

#

I have them in static but it's not working

native tide
#

assuming the folder structure is fine and the app is in installed apps, there is a {% load static %} tag you have to add in the template for it to successfully work

twilit dagger
#

It's not giving me any error, I'm doing <script src="{% static 'home\home.js' %}"></script>

#

And this is the JS ```// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};

// Get the navbar
var navbar = document.getElementById("navbar");

// Get the offset position of the navbar
var sticky = navbar.offsetTop;

// Add the sticky class to the navbar when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky")
} else {
navbar.classList.remove("sticky");
}
}```

native tide
#

so its just not loading in?

#

if you check page source, what do you see there?

twilit dagger
#

Yeah it is there in the page source

#

It is loading in but it's not running

native tide
#

gotcha. if its not loading then someone else will have to help, I'm still pretty new with js myself. sry I can't help

#

the fact it loaded though indicates everything w/ django is fine

lethal orbit
#

It's not giving me any error, I'm doing <script src="{% static 'home\home.js' %}"></script>
@twilit dagger why are you using a \ ?

#

This might not be the problem, but they should always be forward slashes (/)...

twilit dagger
#

@lethal orbit Sorry that was a mistake, I was also doing {% static 'home\main.css' %} like that

humble bobcat
#

Been using django for 3 and a half years now and had the joy of a brand new error today. Django/postgres complain about too many connections to DB.

bleak bobcat
#

hi guys is this chat an okay place to ask a question about selenium?

strong oriole
#

i think so

#

whats the problem

bleak bobcat
#

im trying to help a friend of mine with an issue
hes trying to make a bot that gives kudos in strava
the button hes trying to target is

<button class="btn btn-icon btn-icon-only btn-kudo btn-xs js-add-kudo" data-entry="["Activity",4038233087]" str-on="click" str-trackable-id="ChYIBTISCP+XyoUPGAIoATBdOABAAEgBEgQKAggD" str-type="kudos" title="Give Kudos">
<span class="app-icon icon-dark icon-kudo icon-sm">
kudos
</span>
</button>

initially he had a line that looked like
buttons = driver.find_elements(By.XPATH,"""//button[@title="Give Kudos" and starts-with(@data-entry,'["Activity')]""")
ive changed that to
buttons = driver.find_element_by_xpath("//button[@title='Give Kudos']")

however it still doesnt seem to target it properly

#

its my first time looking at selenium as im usally a powershell groovy developer

strong oriole
#

what is the error

#

or no error?

bleak bobcat
#

Exception has occurred: NoSuchElementException
Message: Unable to locate element: //button[@title='Give Kudos']
File "C:\Users\bendo\Desktop\strava_palaver.py", line 33, in <module>
buttons = driver.find_element_by_xpath("//button[@title='Give Kudos']")

strong oriole
#

hmm is it full inspect element > copy xpath pasted?

bleak bobcat
#

ahh when I inspect the element and copy the xpath its
/html/body/div[3]/div/div[2]/div[2]/div[1]/div[2]/div[3]/ul/li[1]/div[4]/div/div[2]/button[1]

#

I assume thats wrong as it doesnt look right to me

strong oriole
#

buttons = driver.find_element_by_xpath("/html/body/div[3]/div/div[2]/div[2]/div[1]/div[2]/div[3]/ul/li[1]/div[4]/div/div[2]/button[1]")

#

try that

bleak bobcat
#

I get Unable to locate element: /html/body/div[3]/div/div[2]/div[2]/div[1]/div[2]/div[3]/ul/li[1]/div[4]/div/div[2]/button[1]

#

on the website (strave) there is multiple kudos buttons that he was trying to loop through and hit

thorny badge
versed python
#

if it's from Mozilla it's bound to be good @thorny badge

thorny badge
#

Guess ill follow through then, thanks :))

swift sky
#

thanks for your help @errant spear though i am not getting an internal server error

errant spear
#

You are not getting an internal server error?

swift sky
#

I am now*

errant spear
#

Ok can you give me some more information on the error

#

What is the exact error you are getting? What are you trying to do when you get this error? What do you expect to happen instead?

swift sky
#
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.```
#

so basically i have 1 script that makes a request for a stiemap in xml format, it then parses that xml into a dictionary of urls that have been updated in the last 3 days

#

it then stores that dicitonary into a variable

#

which i am then importing into my flask routes

errant spear
#

Ok so it seems like there is some sort of error in the code that is displaying this page

swift sky
#

well

#

the error i posted is the message output I got when visiting the flask route

#

i am wondering if the dictionary variable actually contains a dictionary

errant spear
#

So when you run a flask app in the command line you have to run the app.py file

#

Are you familiar with that?

swift sky
#

yes

#

you know what though

#

my parse script

#

has a if __name__ == "__main__": main()

errant spear
#

ok well whichever one you are running in the command line where it is being run there should be more information on the error and why the page isnt displaying

swift sky
#

one second

errant spear
#

Here is an example of what you might see on the command line when you run it

swift sky
errant spear
#

Ok cool

swift sky
#
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Knowledge Articles</title>
  </head>
  <body>
    {% extends "staff_parent_template.xhtml" %}
    {% block content %}
    <h1> Welcome to the Knowledge Articles page </h1>
    <p> these are the new articles for today </p>
    <h3>DICTIONARY: {{ dict_to_be_passed }} </h3>
    <h3>DICTIONARY FIELD: {{ dict_to_be_passed['field_name'] }}</h3>

    {% endblock %}
  </body>
</html>```