#web-development

2 messages Β· Page 119 of 1

glacial orchid
#

See this

#

U will get my point

#

In his case it's just loading time
But in my case the template is not rendering expectedly

#

And also loading time as well

#

So?

plucky tapir
#

Would using CBV, admin, just the framework in general for Django be considered as tools? To develop a project

glacial orchid
#

What

hoary marlin
#

@glacial orchid the most I can do is to provide you the server invite of official django server and a server for django developers

ocean seal
#

Which hosting should I use for Django?

marsh canyon
#

I have used both pythonanywhere and digital oceans for my django website, pythonanywhere sets up gunicorn and a web server for you automatically, while in digital oceans and even others like Linode, give you a VM where you have to configure everyhting

#

pythonanywhere is free for basic hosting

marsh canyon
#

DO and linode are paid, btw

native tide
#

I heard GCP is good too

#

I tried using Heroku for my django + react app and it was a nightmare

left wadi
#

Hello, hope you''ll are doing well. Can anyone help me figuring out why my django application is throwing this error.

marsh canyon
#

show me your templates dir

#

@left wadi

left wadi
#

It is a very simple application, am learning the basics as of now. If anyone can figure out, please do let me know. Thanks in advance!

marsh canyon
#

when you use extends, you need to give the full path to the file from the templates dir

#

like {% extends "base/base.html" %}

#

include the folder which the base.html file is in

left wadi
marsh canyon
#

{% extends "pages/base.html" %}

#

@left wadi

left wadi
marsh canyon
#

whats the error now

#

btw the slash is / and not \

#

in the return render line

marsh canyon
#

is the folder named pages or page?

left wadi
#

pages

marsh canyon
#

then in the return render statement, it should be pages instead of page

marsh canyon
#

πŸ˜„

#

also

#

if you look at the error message

#

django tells you where it looked for the template

#

under template-loader postmortem

left wadi
#

Yes, I'll keep that in mind πŸ™‚

marsh canyon
#

so there, it said page/index.html but it should be pages

marsh canyon
#

so that means you prolly made a mistake while rendering the template

left wadi
#

Yeah

native tide
#

the error is in the error πŸ™‚

stone wren
#

whatever I do, celery still tries to connect default broker url

I useflask_celery

it does not recognize settings object

it's defaulted to amqp://guest:**@127.0.0.1:5672/

native monolith
#

Can I get some help with flask and aws? my web is unreachable, but I have added ports 80 :/

stone wren
#

did you allow the port from aws dashboard?

native monolith
stone wren
#

ok what about nginx

native monolith
#

you mean this?

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=80, debug=False)
stone wren
#

uhm, this can work too, but it's not for production

native monolith
stone wren
#

no, it should take parameters from settings

#

but it does not

native monolith
#
app = Celery("backend",
             broker=broker_url,
             namespace="zoomgif", include=["backend.tasks"])
low blade
#

does django force you to use the ORM to use the doc templating even if you're using a web api for a backend?

#

it really seems that way

chilly scarab
low blade
#

yeah, i've been looking at using fastapi to serve docs instead because of that lol

indigo kettle
#

you don't need to use the orm to use templates

#

@low blade you just provide context to a view and then the template reads the context

low blade
#

right, but it seems like the context must be a class that inherits from django.db.model

indigo kettle
#

context is just a dictionary

#

you can have a templateview like

class SomeView(TemplateView):
  template_name = 'my_template.html'
  
  def get_context_data(self, *args, **kwargs):
    context = super().get_context_date(*args, **kwargs)
    context['myvar'] = 'hello world'
    return context
#

then in my_template.html you can use myvar

#

that being said, if you are not going to use the ORM and the database integration that django provides, maybe using something else is preferable.

low blade
#

oh i was just missreading then

#

and yeah, i don't think that im liking the amount of magic that seems to happen in django. i pretty much just need something to spit out html docs and make requests to a backend api for certain things

indigo kettle
#

django has a lot of magic

low blade
#

yeah lol i think if django happens to do something that takes a ton of work to do in fastapi, i'll switch back, but fastapi has been pretty straightforward for me thus far

trim star
#

How do you test multiple types of file uploads in a django application?

#

I am trying to avoid having to create a test file for each and every supported file format

trim star
#

Is anyone here?

low blade
#

not anyone that knows how to do what you're asking, im guessing lol

trim star
#

Man..

#

So how do people write their unit tests for file validators in Django

low blade
#

most people don't just sit on discord too though and wait for questions. just need to be patient

trim star
#

I sit and wait for questions

#

(Did I say that out loud?)

trim star
#

If i had the file content of a valid file then that would be nice

vestal hound
#

if each file has a different format

#

then it would make sense...

trim star
#

@vestal hound So I guess the only way is to make physical files and carry them around my codebase?

vestal hound
#

you could store the binary representation as a test fixture

trim star
#

@vestal hound how is that different from a file on disk?

vestal hound
trim star
#

Ok thanks

torpid pecan
#

I am trying to create an html element based on the number of objects I have in a list(python). Does this have a name or am i thinking about this totally wrong? I am very new to web development.

surreal harness
#

is anyone here good with nested serializers with the DRF? I'm having an issue with getting the views to display the way i would like

plucky tapir
#

With django is there a way to delete and create from different tables at the same time? Class based views

sacred gull
torpid pecan
#

yes

sacred gull
#

you'd do that with the django template language loop thingy

torpid pecan
#

Thanks. I will look into it.

sacred gull
stuck swift
#

Hey I'm building an flask app where each user has their own calendar that others can book or schedule meetings on. Does anyone know of any packages or apis that would allow one calendar per user? And that would provide the apis for a user to manage their own calendar?

surreal harness
#

If I am writing an API and I have a nested relationship, but I want to be able to have views for both the parent and child, how can I achieve this? Parent has many children, so I want two views. /parent should show the parent's info with many children, and /children should just show the children for the parent that accessed the route (I have implemented this using tokens already)

stuck swift
#

You can have an api like this:
/parent/{parent_id}
/parent/{parent_id}/children
/child/{child_id}

#

/parent/{parent_id}/children/{child_id} could also be in there.

surreal harness
#

the way that my API is setup is such that I don't use the FK in the route, I just use the token to get the current user. So they can only access their own attributes by using a generic route. In the get methods I just fetch the Parent object using the token. Perhaps this is a bad setup?

#

so there's no
/parent/{parent_id}

its simply

  1. send request to /parent
  2. send with token or rejected
  3. token contains {parent_id}
  4. parent route queries for the parent with {parent_id}
  5. returns relevant data
stuck swift
#

@surreal harness is the Token an Auth Token of some sort?

surreal harness
#

yep

stuck swift
#

Wait so how many 'resources' do you have?

surreal harness
#

well let me just convey with the real objects

#

I have a User and a User has many SocialNetworkAccounts

#

so going to /me should be able to get all of the relevant user info, there might be some other stuff like email or whatever, but social network accounts will also show nested

#

going to /socialnetworkaccounts i want to just show the nested social network accounts

#

basically, a partial amount of that data

#

the reason being that I want them to be able to update that information in that view, if I sent a POST request to /socialnetworkaccounts with some new info, it should modify only that nested part and touch nothing else

#

i don't think the primary key being there or not should affect this part of what i want to achieve

#

since I can already get the specific user object consistently

stuck swift
#

Now is this stricly an API you are building or do your routes return data + HTML

#

?

surreal harness
#

just some JSON

stuck swift
#

I wouldn't really recommend this

surreal harness
#

and why is that?

stuck swift
#

you can definitely do it like this though

#

Are you familiar with the RESTful paradigm?

surreal harness
#

maybe not thoroughly

stuck swift
#

In theory one of the drawbacks with your approach is caching. every call to /socialnetworkaccounts is different depeneding on the logged in user so it cant be cached

#

not a big deal for you use case

surreal harness
#

yeah not worried about that right now but i understand

stuck swift
#

Also its kind of confusing. Because in order to get the backend record/model object you want to interact with you have to make a call to 'current_user()'

#

Probably going to run into difficulty writing tests for this too

surreal harness
#

right but this prevents some malicious access, no?

#

for example, if someone is hitting a user object that they shouldn't be hitting, sure it will get rejected

#

but this prevents that possibiltiy was my thought

stuck swift
#

I'd recommend going with the restful approach, where you essentially encode everything you want to do in the request. Your requests will be idempotent and very easy to test and debug and also make your life easier if you ever leave and comback to development after some amount of time

surreal harness
#

i see

stuck swift
#

I see your argument is around security? But you could simply have ACLs or permissions to handle this instead

surreal harness
#

ok sure, i mean, i'm a noob so idk

#

can you link something regards to how we should structure using the RESTful approach?

#

is it some paradigm for setting up proper api routes?

stuck swift
#

Ok gotchya

#

Without understanding the full context of your app, like how much time you want to spend on it, who's going to use it, if its for work/business/fun etc I can't speak to the optimal 'business' approach

surreal harness
#

lets just say i have 3 days

stuck swift
#

however technically speaking this is probably a sub optimal approach. Although It's totally ok and even recommended to go with sub optimal approaches to meet business use cases

#

Basically the "best" approach technically would be to have a RESTful paradigm.

surreal harness
#

hows it different than mine

stuck swift
#

You have 2 resources, Users, and SocialNetworkAccounts

surreal harness
#

yes

stuck swift
#

Your routes would be this
/User
/User/{user_id}

/User/user_id/SocialNetworkAccount
/User/user_id/SocialNetworkAccount/{social_network_account_id}

/me - alias for /User/{user_id} where user_id == current_user()

#

We then CRUD (Create, Read, Update, Destroy) each route with the HTTP verbs (POST, GET, PUT/PATCH, DELETE) respectivley

#

So if you want to add a social network account to user 5,
POST /User/5/SocialNetworkAccount with some JSON data in the body

#

If you want to remove a social network account 12 from user 5
DELETE /User/5/SocialNetworkAccount/12

#

If you want a list of all SocialNetworkAccounts on User 5
GET /User/5/SocialNetworkAccounts

#

You can also have the routes:
/SocialNetworkAccount
/SocialNetworkAccount/{social_network_account_id}

But I think for your use case this isn't needed.

#

Now you also want to limit what users can CRUD (create, read, update, and destroy) certain records. So you will need to add checks in your routes to verify that the user_id in the route is equal to the current_user(). If not, return a 401

#

Of course with each request you are also including the token. probably in the header.

#

Does this make sense?

surreal harness
#

im digesting this yeah

#

ok yeah, this makes sense to me

#

using the viewsets i can just create routes for the specific children and have the linked nested serializer, and then update those individually

#

in terms of limiting what the users can CRUD there's no generic way to do this right? i just need to have some is_valid method to check the fields that I care about i'm assuming

#

but yeah I understand thanks

#

@stuck swift can I ask you about the caching? Are you saying that it is easier to cache results if there are PK routes for the api?

stuck swift
#

Hey my b made dinner.

surreal harness
#

np

stuck swift
#

Sort of yeah. For your app it may not really matter much, but in general if more users had access to more resources then yes. For example

#

If your app had no Read only restrictions and every user could view every other users list of SocialNetworkAccounts, then the URL
/User/5/SocialNetworkAccount
would always return the exact same thing (unless this list was modified of course)

#

this means it could easily be cached. However a custom route like /socialnetworkaccounts would always change depending on the logged in user.

surreal harness
#

true, and if i wanted to prevent every user from being able to see every other user I could still do that by having some object level permissions I guess

#

the thing I'm running into now is, for example, if I want to update an individual user's socialnetworkacccount, I can arbitrarily edit an object that isn't mine by providing some random Id or whatever, which is really bad

stuck swift
surreal harness
#

ok cool, thanks

stuck swift
#

Object or route level.

#

Which web framework are you using?

surreal harness
#

Django

#

unfortunately i don't think I have enough time to change the route levels, so I'm going to have to go with the generic /socialnetworkaccounts route like I was saying before

#

I can add individual checks on the PATCH method but it seems very...ungeneric

#

i mean this is baby's first API dev anyway so

stuck swift
#

for your routes you want to add a check for each UPDATE or CREATE route that looks at the current user and the id in the URL. Basically.
if current_user().id != user_id
throw 401

#

past your UPDATE route and I'll have a look

surreal harness
#

yeah that makes sense if I had the id in the URL

#

ok

stuck swift
#

Also if you wanted to be l33t you'd create a python decorator to decorate the routes where the url id must match current user id, assuming this is a common thing.

#

Also another benefit of the RESTful routes are that they follow a "Pattern". software eng is all about "Patterns".

#

Patterns allow you to abstract things and ultimatley wirte less and less code.

surreal harness
#

def partial_update(self, request):
    if not request.data.get('id'):
        return Response({"message": "object id not specified"}, status=status.HTTP_404_BAD_REQUEST)
    user = get_user_from_token(request.auth) # helper method
    user_social = UserSocialNetworkAccounts.objects.get(id=request.data.get('id'))
    serializer = UserSocialNetworkAccountsSerializer(user_social, data=request.data, partial=True)
    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data, status=status.HTTP_201_CREATED)
    return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
#

that first check is specifically because like you said im not using the id in the route, so I need to check for it inside of the object being passed in to the request, but if I had the PK level routes like you said it wouldn't be necessary

surreal harness
stuck swift
#

where do you map the url to this function?

surreal harness
#

in my urls.py I have something like this

path('sns', UserSocialNetworksViewSet.as_view({'put':'partial_update'}), name='sns')
stuck swift
#

ok 1 sec, I've never actually used Django

surreal harness
#

I know that partial updates should be done in patch actually, maybe we will change that

#

oh yeah...Django has a lot of specifics so it might be a bit hard to understand. not sure

covert kernel
#

how can i only give a django group access to a page and not to the others.

like only the ppl in the grp blog writers have access to page "New Post"

stuck swift
#

@surreal harness
so is '/sns' the actual url that maps to te partial_updated function?

surreal harness
surreal harness
#

something like

def new_post_view(request):
    user = request.user
    if user.group_id != BLOGWRITERS_ID:
        return redirect("somewhere else")


stuck swift
#

Try changing it to
path('user/(?P<value>\d+)/socialnetworkaccounts', UserSocialNetworksViewSet.as_view({'put':'partial_update'}), name='sns')

surreal harness
#

I want to and will in the future, but I think I can't right now

stuck swift
#

Then add a paramter "value" to the partial update funtion. It might have to be a named param not sure

surreal harness
#

unfortunately the mobile developers define the API spec and for 1.0 we have to do it as they say

stuck swift
#

ahhh

#

fire their asses then

#

they fked up lol

surreal harness
#

but I get the idea. basically it is better in general to have PK in the routes than to not

#

hah

#

you know how time crunches are

stuck swift
#

Yeah. There are so many reasons why too. They become very apparent with larger apis.

#

If you have 150 models and dozens of relationships across these models you'd quickly realize doing it the RESTful way is a no brainer

surreal harness
#

yeah. i might go aggro and just demand that we have object ids in the routes

stuck swift
#

escpecially when you get into complex permission/ACL usage

surreal harness
#

it also makes the implementation quite annoying too

covert kernel
#
class CreatePostView(LoginRequiredMixin, View):
    template_name = 'blog/new_post.html'

    def get(self, request):
        form = BlogPostForm()
        user = request.user
        if user.group_id != BLOGWRITERS_ID:
            return render(request, self.no_permission_template_name)
        return render(request, self.template_name, {'form': form})

    def post(self, request):
        form = BlogPostForm(request.POST)

        if not form.is_valid():
            messages.error(request, 'Invalid form', extra_tags='dnager')
            return render('create_post')

        post = form.save(commit=False)
        post.user = request.user
        post.save()

        return redirect('blog_post', post_id=post.id)``` like this?
gaunt marlin
#

@covert kernel you can write a custom decorator for that group and add to the view, also check in the template the user group name to show it or not

stuck swift
#

If they look to increase who can access routes and want to add more models an relationships requiring they conform to REST it totally within scope and reasonable.

surreal harness
#

yeah I agree

#

what is ACL btw?

gaunt marlin
covert kernel
#

thanks!

#

lemme have a look

stuck swift
#

ACL means permissions on a resource. I think it stands for Access Control List. So basically an ACL defines who can access something.

surreal harness
#

oh right gotcha

stuck swift
#

So you could set permissions on who can READ SocialNetworkAccounts via an ACL on the SocialNetworkAccount Model.

covert kernel
#

@gaunt marlin something like this?

def is_member(user):
    return user.groups.filter(name='Member').exists()
stuck swift
#

I think it's a more generic way of saying "Permissions"

native tide
#

Anyone know the structure for a nested for loop inside a for loop with jinja?

#
        {% for result in results: %} 
*other code here* 
{% endfor %} {% endfor %}```
prints a lot
#

cant figure out why

gaunt marlin
#

@covert kernel use can use the existed user_passes_test decorator to implement it easier

from django.contrib.auth.decorators import login_required, user_passes_test

user_member_required = user_passes_test(lambda user: user.groups.filter(name ='Member').exists(), login_url='/') # redirect to other path

def member_user_required(view_func):
    decorated_view_func = login_required(user_member_required(view_func))
    return decorated_view_func

@member_user_required
def index(request):
    return render(request, 'index.html')

like so

covert kernel
#

lemme try

gaunt marlin
#

@native tide is results data in i?

covert kernel
#

@gaunt marlin how can i do that on a class?

gaunt marlin
#

why do you need to use a class? @covert kernel

#

oh the views class?

covert kernel
#
class CreatePostView(LoginRequiredMixin, View):
    template_name = 'blog/new_post.html'

    def get(self, request):
        form = BlogPostForm()
        user = request.user
        return render(request, self.template_name, {'form': form})

    def post(self, request):
        form = BlogPostForm(request.POST)

        if not form.is_valid():
            messages.error(request, 'Invalid form', extra_tags='dnager')
            return render('create_post')

        post = form.save(commit=False)
        post.user = request.user
        post.save()

        return redirect('blog_post', post_id=post.id)
#

yes

native tide
#

@gaunt marlin i is just the integer between 1-11. I get the output of both results but I get 11 copies of said output

native tide
#

in python a for loop after a for loop is supposed to run output per parent for loop, right? Is that not how it is in jinja?

#
    for n in loop:```
#
i
n```
stuck swift
#

@native tide What do you actually want? Your telling the inner for loop to run 11 times? Is this intended?

covert kernel
#
user_member_required = user_passes_test(lambda user: user.groups.filter(name ='Blog Writers').exists(), login_url='/') 
decorators = [login_required, user_member_required]

@method_decorator(decorators)
class CreatePostView(LoginRequiredMixin, View):
    template_name = 'blog/new_post.html'
    def get(self, request):
        ...
    def post(self, request):
        ...```
#

how can i pass th<e user in th<e decorators @gaunt marlin ?

native tide
#

@stuck swift I need to add a number next to each output of results

#

usually a loop in a loop works

gaunt marlin
#

@covert kernel it should get auto get request.user if you applied the decorator to a class, no need to pass anything

stuck swift
#

@native tide can I see your full code?
Also is it just a number from 1-11?

gaunt marlin
#

@covert kernel use custom one like so

@method_decorator(member_user_required, name='dispatch')
class CreatePostView(LoginRequiredMixin, View):
covert kernel
gaunt marlin
#

@covert kernel
you use it if you apply to the whole class instead of method in the class
Or, more succinctly, you can decorate the class instead and pass the name of the method to be decorated as the keyword argument name:
explained in the docs

covert kernel
#

oh ok! thanks alot, u rock!

stuck swift
#

@native tide can you take advantage of the builtin enumerate function and remove the outer for loop with the range?
{% for i, result in enumerate(results): %} *other code here* {% endfor %}

native tide
#

The problem was just that it was repeating the full second loop each time, so like instead of 1 a 2 b 3 c I got 1 abc 2 abc 3 abc, if you know what I mean

glacial orchid
#

Hello

#

Anyone is free?

#

I need some help with my blog app project

#

With django

glacial orchid
#

I am getting
SMTPAuthenticationError: (534, b'5.7.9 Application-specific password required.

#

I have two factor authentication set up
Before this
I just enabled less secure app be turned on and was able to send email manually but unable to do so after two factor authentication

#

My moto is to send email to the user of my app to reset the password

surreal harness
surreal harness
#

nvm, think i got it

vivid canopy
#

hey guys wanna ask how can i set in sqlite table minimum lengh?

pastel osprey
#

random question - do async, but CPU-bound Promises in JavaScript block the browser tab? (i don't have any slower devices to try) (for example, if you have say a sudoku solver or other algorithm in an async () => {})

peak bronze
#

i think it does block

native tide
#

does anyone know how drf serializer work?

def perform_create(self, serializer):
        for f in self.request.data.getlist('graphs'):
            serializer.save(graphs=f)```
when the server got the posted file, the files are saved correctly in the storage, but in the API it only saved 1 file like this
```"graphs": "http://127.0.0.1:8000/1991-06-20-mw74-minahassa-peninsula-sulawesi-2.miniseed",```
how can i make this "graphs" become list of files?
covert kernel
#
class BlogPost(models.Model):
    title = models.CharField(max_length=64)
    content = MarkdownxField(max_length=16384)

    created_at = models.DateTimeField(auto_now_add=True)
    last_edited = models.DateTimeField(auto_now=True)

    user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
``` ok so this is my blogpost of model
#

and

#
[
    {
        "title":"Flask vs Django - Which Is Better?",
        "content":"Ei dicta apeirian deterruisset eam, cu offendit invenire pri, cu possim vivendo vix? Nam nihil evertitur ad, ne vim nonumy legendos iracundia. Vix nulla dolorem intellegebat ea? Te per vide paulo dolor, eum ea erant placerat constituam? Dolores accumsan eum at.\r\n\r\nInteresset consequuntur id vix. Eam id decore latine, iusto imperdiet ei qui. In ludus consul reformidans eam. Nec in recusabo posidonium, cu tantas volumus mnesarchum pro. Nam ut docendi evertitur, possim menandri persecuti ne sed, cum saepe ornatus delenit ei?\r\n\r\nIn mel debet aliquam. In his etiam legere, doming nominavi consetetur has ad, decore reprimique ea usu. Eam magna graeci suavitate cu, facete delenit cum ne. Ponderum evertitur tincidunt ei mel, ius ei stet euismod docendi.",
        "user_id":"NewUser1"
    },
    {
        "title":"You Won't Believe These Clickbait Titles!",
        "content":"Cu justo honestatis mel, pro ei appareat mediocrem suavitate. No his omnis ridens. Ludus ornatus voluptatum mei ut, an mentitum noluisse forensibus cum. Eam affert pertinax consequuntur ei, nisl zril meliore te vis? Ad animal persius concludaturque vix, eu graece audiam mel.\r\n\r\nVitae libris mentitum pri in. Cu rebum veritus sea, ex usu consul dolorum, pro tale maluisset consulatu ut. Quo ad clita persius ancillae. Vel illud blandit at, vel eu hinc graeco, usu doctus praesent ea! Vim rebum deserunt ex.\r\n\r\nIus lorem omittam id, est suavitate definitionem ad! Id vim insolens tacimates, pri at decore causae. Ex duo bonorum repudiandae? Vix no vidit facete impedit. An oportere indoctum eam.",
        "user_id":"NewUser1"
    }
]``` this is posts.json file, how can i add th<ese posts to it thro the shell?
#
import json
from blog.models import BlogPost
with open('posts.json') as f:
  p = json.load(f)
 
for post in p:
  post = BlogPost(title=post['title'], content=post['content'], user=post['user_id'])
  post.save()```
#

this is what i tried but then

#
ValueError: Cannot assign "'NewUser1'": "BlogPost.user" must be a "User" instance.
#

so how can i set it as a user instance?

green skiff
#

I am not too familiar with that, but maybe you need user__id, with two underscores?

covert kernel
#

ok lemme try

covert kernel
green skiff
#

Yeah, no, sorry, I really don’t know

covert kernel
#

np, thanks

native tide
#

@covert kernel The user you're trying to input into the ForeignKeyField is not a user instance, it's a string.

glacial orchid
#

Someone help me plz

#

We are django brothers na😭

native tide
#

Hi, how can I use a property in Min(). I want to use the result of this property @property def fictional_quote_price(self) -> Decimal: return self.quote_price - self.total_score here @property def environmental_impact_project(self): return Applicant.objects.filter(project=self).aggregate(Min('fictional_quote_price')) but i get the following error: Cannot resolve keyword 'fictional_quote_price' into field.

glacial orchid
#
gaunt marlin
#

if it sent and return no error, maybe check your spam folder. Some service like gmail filter emails @glacial orchid

worn pier
#
  1. I created the Django_project folder in my desktop
  2. Created a virtual environment named 'venv' inside the Django_project folder
    So far i have a Django_project folder and inside that i have 2 sub folders,(.vscode, and venv)
  3. i used Django_project>django-admin start project web_app commad and now i have 3 sub folders in the main folder .vscode, venv and web_app
    is this the right way?
gaunt marlin
#

@worn pier start project will create the django workplace folder, you don't need to create the Django_project folder from the start

glacial orchid
#

@gaunt marlin no bro
I read the doc
What's happening is because it says my email is not registered in the system but I have registered it in settings.py file still not working
Please visit the forum and helpπŸ™

worn pier
#

i read in an article that it is good practice to name your virtual env as venv, to make source control easier, or something like that, so inorder to organise multiple environment with same name it is better to put it in a folder right?, im new to this

gaunt marlin
gaunt marlin
#

because you didn't post your custom view code and not telling him if the email you posted in settings.py is related to a system user or not

vocal berry
#

@snow estuary

glacial orchid
static shuttle
#

flask or django
What are the pros and cons?

gaunt marlin
#

@glacial orchid your users in user table need to have the email that in settings.py

snow estuary
#

Hello guys i cant get all user input when he sign up from the use table anyone could help! (im using django) Thank you.

#

User*

glacial orchid
gaunt marlin
#

no that not what i mean...
do the users data in your users table has email = the one in the settings.py?

#

user.email = the one in settings

glacial orchid
#

I don't get you
What I did is EMAIL_HOST_USER = my email
And my email is in users email table
Is there something I am missing

native tide
#

Hi, I want to get the value of average_mki_value average_mki_value = Applicant.objects.filter(project=self).aggregate(Avg('mki_value')) print(average_mki_value) when I print I get this {'mki_value__avg': 208875.0} How can I get just the value (208875.0)?

glacial orchid
vernal furnace
#

Guys how to use google maps with django

native tide
glacial orchid
#

πŸ˜‚

native tide
#

So whats your problem

#

@glacial orchid

vernal furnace
#

uh

#

lmao

glacial orchid
#

Visit the forum πŸ™

native tide
vernal furnace
#

I have the same problem @glacial orchid

#

you have to pay for a port I guess

glacial orchid
vernal furnace
#

um

glacial orchid
#

If u have read the forum u may understand my problem

#

I have posted my email in settings.py and I have a user in app with that email but still email is not sent

#

But no error is thrown

#

Perhaps
Email is not registered in system
But I dont understand what this mean
Cause I have done EMAIL_HOST_USER = myemail

vernal furnace
#

not like this

#

then EMAIL_HOST_USER = os.environ.get('myemail')

#

@glacial orchid

glacial orchid
#

Done that too that's just to hide the credentials not necessary for this to work

vernal furnace
#

Can you tell me what is the error you are receiving?

glacial orchid
#

Have you read the forum and the doc I sent?
If no
Then do that first

vernal furnace
#

The documentation is a documentation

glacial orchid
#

Nope I sent specific

vernal furnace
#

Yeah but I'm reading things blindly without knowing why

covert kernel
#

In this Python Django Tutorial, we will be learning how we can use email to send a password reset link to a user so that the user can reset their password. Users will be able to fill out a form with their email and have a unique token sent to them, and if their token is verified then they will be able to create a new password. Let's get started....

β–Ά Play video
#

have a look at this

glacial orchid
#

I am following himπŸ˜‚

#

Corey

covert kernel
#

it worked for me.

glacial orchid
#

Not for mw

#

I copied him but

#

See@covert kernel

covert kernel
#

you might need to allow less secure apps to access your account.

vernal furnace
#
If the email address provided does not exist in the system, this view won’t send an email, but the user won’t receive any error message either. This prevents information leaking to potential attackers. If you want to provide an error message in this case, you can subclass PasswordResetForm and use the form_class attribute.
glacial orchid
#

When Corey ran server with url Password reset and password reset done
He got an error
I did not
That's where problems began

vernal furnace
#

did u make environment variables roc?

#

in your system

glacial orchid
glacial orchid
covert kernel
#

do it without environment variables

glacial orchid
glacial orchid
#

Just tell me how to register an email in system and what this mean anyway

vernal furnace
#

@covert kernel Can you tell me how its working for you? My problem is with the ports, idk how to get free ports >.<

#
530, b'5.7.0 Authentication Required.
#

roc

glacial orchid
#

What

vernal furnace
#

since it does not send you any error, are u sure the account you are sending the message to exists?

glacial orchid
#

Yes
It's my personal email address

vernal furnace
#

Oh, because I deleted m from .com and it said "successfully sent the message"

#

Anw, can you fix my problem 😦

glacial orchid
#

Do this

#

I blv gmal is free

vernal furnace
#

nope its not

#

not anymore

#

the 587 port was free

green jewel
#

any library for integrating neo4j to flask

glacial orchid
#

Then nthng is free
I went to sendgrid.com
That's also not free
Even it is , the formalities are too complex

glacial orchid
vernal furnace
#

rip

glacial orchid
#

follow me on instagram
You seem to be passionate about python
roc_tanweer

vernal furnace
#

I will when I get my phone

native tide
#

someone knows how to fetch discord data like guild ids in flask?

glacial orchid
#

Ok for now I'll add u here

glacial orchid
#

@vernal furnace u know about registering email in system

#

What exactly does this mean

#

I don't understand

#

This is why I am not getting any error and it's shown that email is sent like said in doc

vernal furnace
#

idk what that really means

glacial orchid
#

Np

sand gate
#

anyone knows how to use @font-family on css?

#

cause mine's not working

glacial orchid
near bison
#

on django, is it normal to have an app named homepage

native tide
#

@sand gate Yeah, what's the issue?

glacial orchid
native tide
#

Because I can't help with everything

glacial orchid
#

If u do
U can help
If no
No issue

vestal hound
glacial orchid
#

There wasn't any negativity

vestal hound
#

no, I mean that you should just post your question

#

gatekeeping rarely helps anyone

#

and "know Django" is a pretty subjective question

proven saffron
#

yeah django is huge

vestal hound
#

you could be asking about something very specific

#

template interpolation has nothing to do with async access to the ORM, but both are Django

glacial orchid
#

Yeah

#

Both are different at beginning

proven saffron
#

so what is your question

glacial orchid
#

Mine?

proven saffron
#

yeah

#

or have you asked already?

glacial orchid
#
vestal hound
#

@glacial orchid so not many people are going to read a whole forum thread

#

generally specific, well-defined questions get much quicker answers

#

just my two cents

glacial orchid
proven saffron
#

it's not a thread

dense slate
#

What service are you sending email through?

proven saffron
#

and sorry man I don't know how emails work with django I only know the basics and api stuff

glacial orchid
#

Blog app

dense slate
#

What service.

glacial orchid
#

To reset password

dense slate
glacial orchid
dense slate
#

You can't use gmail anymore.

glacial orchid
#

How cmet

#

Come

dense slate
#

I don't know why, I just know they decided not to allow it to be used that way anymore.

#

I think it happened like 6 months ago.

#

Maybe more. I went to mailgun when that happened.

#

Mailgun is free to some small limit. Enough for errors at least.

#

I think 1000 emails maybe?

glacial orchid
#

Mailgun?

#

Wait lemmi see

#

Nope
It's asking for credit card

#

Can't give that

dense slate
#

Right, because if you go over your free limit, then they charge you.

#

That's how most of them work now.

glacial orchid
#

It will charge when u cross 5000 emails a month

#

Well it's not that important

#

I am just learning now

#

I'll see this later

#

Wait

#

O have yet another probt

#

Problem

#

Wanna hear

#

?

dense slate
#

You can just post it.

#

We'll help if we can.

glacial orchid
#

Aight

#

The problem is.....
I can't work in django without internet
I happened few days ago
Until then django was working fine

#

Any solution?

#

The problem is
Loading time takes forever
And template does not render as expected
But with internet
Everything works fine with no problem

dense slate
#

Maybe a dependency problem. Are you importing anything in your html or python from the internet?

#

Guessing bootstrap?

#

You can usually download those files and host them locally instead to bypass that problem.

glacial orchid
glacial orchid
#

I told u it worked fine
I did nothing and this happened out of nowhere

#

Believe it or not

#

I just started my pc and saw this

dense slate
#

So when you're offline, it loads differently or it does not load at all?

glacial orchid
#

It takes forever to load
And renders like shit

dense slate
#

What about the rendering changes? Is it just your css?

#

Meaning, does your content render, just without styling?

glacial orchid
#

I dunno
It's just weird render

#

Wanna be frnd?
I'll share more data on this with u

dense slate
#

If you give more details, it will be easier to debug the problem. Try to explain how the render is different.

glacial orchid
#

I am not on my pc atm
That's why I asked u wanna be?

dense slate
#

Or screen shot the difference.

#

Come back and post when you can then.

glacial orchid
#

Aight

dense slate
#

Just @ me.

glacial orchid
#

Np

#

Will try πŸ˜€

thin dome
#

man

#

how to use if funtion in django like if <option></option> == 1y:

glacial orchid
#

{% if....%} but don't use Colin(:) in that code block

thin dome
#

ok but its not working

glacial orchid
#

Explain wt u wanna do

thin dome
#

if the user choose 1y member ship then it will show 720$ and 6m:360$ and 3m:180$ and 1m:60$

#

how to do this?

native tide
#

JS

glacial orchid
#

Suppose u coded user_input = input()
So you can do
{% if user_input == 1y %}
720$
{% endif %}

native tide
#

You can't hot-reload your website on an option-selection with Django templating, you can only refresh the page with the price if the user submits a POST request with a form.

vague root
#

Hello bro

glacial orchid
#

U mean making a form for this pricing?

sacred gull
#

is brython actually used or is that more of a gimmicky-kind of thing?

native tide
#

@glacial orchid He had an <options> tag, so I assume he wants to change a different price on each selection. That's a JS task

glacial orchid
#

Okay
Dunno JS
Sorry to interfere 😌

glacial orchid
native tide
#

Also this wouldn't work because it's Django... there is no access to the terminal for the user:
Suppose u coded user_input = input()

glacial orchid
#

I thought that would work
I need a lot to learn from you guys

native tide
#

@thin dome You could use this:

<select onchange="JS function here()"> </>

And that JS function can refresh the page with the updated price...

glacial orchid
#

I had posted a problem in my django
Wanna hear?

silver tinsel
#

can i ask for some help with css here too? πŸ˜„

#

or maybe does anybody know a server for stuff like that?

native tide
#

Yes... but don't ask to ask, just ask the question

glacial orchid
#

LolπŸ˜‚

native tide
#

it wasn't a joke

glacial orchid
#

Oops

silver tinsel
#

i created a footer
like how can the size of the footer or the height adapt to the amount of lines that are in the footer? you know what i mean?

#

currently the text just gets cuttet away and i cant scroll down

#

should i post my css code?

glacial orchid
#

Yeah

silver tinsel
#

!pastebin

glacial orchid
#

It will help

silver tinsel
native tide
silver tinsel
#

oh well i can guess what it means πŸ˜„

thin dome
#

no it was css

silver tinsel
#

i jsut followed a tutorial and then started changig stuff for my purpose

thin dome
#

no javascript used in it

silver tinsel
glacial orchid
thin dome
#

yes

glacial orchid
thin dome
#

yes its css

silver tinsel
#

okay so if i set overflow on scroll i can scroll now in the footer

#

is there a way so i can scroll on the page?

thin dome
#

but the file is in .html

native tide
silver tinsel
#

if i remove it it changes nothing :/

#

i will look it up

native tide
#

That's because you have a set height...

#

Anything over the height (130px) will be cutoff if overflow is hidden

native tide
thin dome
#

css file

glacial orchid
thin dome
#

not js

native tide
#

What is

glacial orchid
#

Css is just for styling

native tide
#

the onchange attribute takes a JS function.

silver tinsel
native tide
#

Or just remove it...

thin dome
#

what?

silver tinsel
#

lol

#

yea true that works

#

just started yesterday with css

#

πŸ™ˆ

native tide
# thin dome what?

Read the code again, onchange takes a JS function. JS can be intertwined with HTML

thin dome
#

ok i understund i think

native tide
#

You need to understand the event handler, onchange also

#

And know what it does,

thin dome
#

ok thanks sir

native tide
#

When you select a new option within the select, the onchange function will run and do whatever you want it to, such as updating the price... but that functionality is your job

thin dome
#

ok sir and too

thin dome
#

thx too

native tide
glacial orchid
#

Don't be mad

native tide
#

No one is mad herre

glacial orchid
#

Just saying bro

#

Btw

#

U didn't answer me

#

I can't use my django in offline mode now

hot kraken
#

Is django installed in your env?

glacial orchid
#

Internet is needed to load fast and Template render

hot kraken
#

You likely added some embed code.

#

Which uses other libraries like bootstrap

glacial orchid
#

I did nothing
I just started my pc and saw this

#

Did nothing to code

hot kraken
#

Can you send the errors?

glacial orchid
#

Will post here later

hot kraken
#

K

glacial orchid
#

Not on my pc rn

native tide
#

are you using virtualenv

glacial orchid
#

Nope

native tide
#

well there's your solution most likely

glacial orchid
#

My django was working fine
That happened suddenly

#

Without me doing anything

hot kraken
#

@glacial orchid have you used any image or request with links?

#

Create a new template and try loading it. Just a clean hello world template

glacial orchid
#

Oh!!
I did nothing
I was working in windows shell
And my pc got turned off due to electricity prblm
And when I opened my pc and there wasn't internet at that time
I saw that happening
And from then
It's happening whenever there isn't net

hot kraken
#

And check if it takes long also

#

That should not cause any problem. But try to reboot your pc

#

@glacial orchid

glacial orchid
#

Oh

hot kraken
#

Whats the reault of a clean template?

glacial orchid
#

Didn't try that

hot kraken
#

Try it. If it works then django is all right. Problems with your template.

#

And if not then create a new django project and paste the code

#

In it

glacial orchid
#

Then why is everything alright when internet is available

hot kraken
#

Bc of links.

#

Django is trying to hit links for a time.

#

And thus its becoming slow

native tide
#

why discord oauth2 works locally but cannot be handled on heroku?

#

clicking Authorize sends back to the authorization page

#

by authorization page I mean the discord's prompt

hot kraken
#

I dont know about heroku that much but it works perfectly on aws

#

It should work on that also

native tide
#

I tried aws just a few min ago but it seems very complex and I failed to deploy

hot kraken
#

Go through the docs.

native tide
#

there is nothing appearing on my logs on heroku I see the requests but it's causing an infinite auth loop

hot kraken
#

It covers everything.

native tide
#

docs are outdated

#

from 2016

dense slate
#

That's just a vague question, @native tide . Oauth is inherently complex (not really but getting it setup can be).

#

And every situation you use it in needs to be tested for that one setup.

#

Unless you have concrete examples, you just need to keep debugging.

native tide
#

it's working locally and I have set up all error handlers

hot kraken
#

I followed docs and some code on stackoverflow

#

Ot wirks

#

Works

dense slate
#

Your user successfully registers locally?

#

Ok, so you need to make sure you're using a live key for production. That's one difference.

#

Do you know anything about where it's getting stuck?

hot kraken
#

Check the discord auth allowed lists if you have enabled

native tide
#

no

hot kraken
#

I faced same on twitter

dense slate
#

Ok well then that makes it hard for us to know. πŸ™‚

#

Put some stuff in your django to write to your logs/terminal and see what doesn't show up.

hot kraken
#

Log in with twitter was working locally but not on aws

native tide
#

there are no errors on logs

dense slate
#

Print lines in your code.

#

See where something doesn't print.

hot kraken
#

Is any access or request deny message?

silver tinsel
#

hey,
if i have a html file witht he footer and a navbar and stuff and i want it to be shown on every other page. how could i do that without copy pasting the code on every other page?

hot kraken
#

Use a {% extends "base.html" %}@silver tinsel

native tide
#

OAUTHLIB_INSECURE_TRANSPORT this was set to true might this be the cause?

silver tinsel
#

but then it gets loadad as an extra window

dense slate
#

@silver tinsel You should read up on how extending templates works in Django. The Django docs are pretty clear about how templates work.

hot kraken
#

I dont think you should turn it off

dense slate
#

@native tide That allows you to work locally.

#

It doesn't have to be off.

silver tinsel
#

currently i am just doin a simpl html css website without any backend

native tide
#

I now authorise and it sends me back to here

dense slate
#

But the frontend on Django work a specific way with its templates.

#

@silver tinsel

#

Oh, you're not using Django?

hot kraken
#

@native tide check oauth permissions

native tide
#

permissions are these

silver tinsel
#

yea i've done a tutorial with django and everything worked there. but now i am trying to do a simpl website wihtout any backend just html and css

dense slate
#

So is this simple site using Django or not at all?

silver tinsel
#

no its not

dense slate
#

if you want to use the same thing on multiple pages, use include.

#

lookup html includes

hot kraken
#

@native tide i think i have to give a closer look at ot

silver tinsel
#

okay thanks

dense slate
#

Welks.

hot kraken
#

To your problem

#

Sorry

#

I tagged wrong

glacial orchid
hot kraken
#

Like css or js links

#

Or any pic

glacial orchid
#

There is no link bro

#

I am not using bootstrap

hot kraken
#

Can I see your template?

#

Just the head part

glacial orchid
#

I told u already
I had used django offline many times before

#

Everyone uses it offline in developing mode

hot kraken
#

Yah. I know.

#

And so i dont think its djangos problem

glacial orchid
silver tinsel
dense slate
#

is the site on a server or local?

silver tinsel
#

local πŸ˜„

dense slate
#

If you have index.html, and you include navbar.html, it should work.

#

I'm not sure where you are seeing that error.

native tide
#

issue kinda resolved. i was redirecting back to login on error

vivid bough
#

I can't import one py file into another py file even they are in the same project folder , can anybody help?

native tide
#

from module import x
or
import module

dense slate
#

@vivid bough What else do you know? What error is it giving?

glacial orchid
#

Check ur spelling

dense slate
#

What's your import code look like?

glacial orchid
native tide
#

if doesn't work create a folder like "modules" in same directory and then from .modules.module import x

dense slate
#

@glacial orchid I already answered you and you said you aren't at your PC.

glacial orchid
#

U using class base view or function base

silver tinsel
#

i found a solution on stackoverflow πŸ˜„

#

maybe not the best way but it works

native tide
#

@plush heart try to see if request.META['HTTP_REFERER'] gets the url of the page sending the request

#

Or, print request.headers and see if the origin is there.

#

and if so you can access it

dense slate
#

I'm confused why you would want to do this based on the directory path?

native tide
#

I now fixed the infinite authorization loops. But now I'm receiving an error that's not resolved

#

Yeah me too Demi

dense slate
#

@plush heart What's the end goal you want to do? Prevent something, authorize something, or what?

native tide
#

so you have one URL that handles deletions? It sounds like you'd be better off having an API endpoint which you can consume whenever you want to delete a note

dense slate
#

You don't direct users to your urls.py paths instead?

#

When would you need to do that?

#

You want to show one link or another, based on where they are on the site?

#

Well then wouldn't each separate page have different links, depending where they are?

#

So if I'm at /notes/ versus /other_notes/, each of those have their own page, right?

native tide
#

If you're deleting a note, why can't you redirect to the same URL - wherever you are on the site? That's what I don't understand

dense slate
#

So why would you not have different links on each page?

#

Or is it a shared page with some kind of javascript affecting the rendering?

#

Maybe just get a new group. πŸ˜„

glacial orchid
#

May I ask a q demo?

#

Demi*

#

Autocorrect..

#

How long have u been doing django

#

I mean I can't understand any of these thing

#

Feeling depressed so asking

dense slate
#

2-3 years. Not a lot.

#

Enough to feel comfortable.

glacial orchid
#

Oh😭

dense slate
#

It takes a lot of work to become good at any language/framework, so don't get down on yourself.

glacial orchid
#

πŸ™ I respect u

#

Sir

#

It's been 3 months in python
And less than a month in django

dense slate
#

I've been there. I know it's hard at the beginning.

#

It's hard even now. I still get stuck on bugs for hours or days.

glacial orchid
#

Mind If I ask ur age?

#

Mine is 20 almost

dense slate
#

Probably not a discussion for web_dev. πŸ˜„

glacial orchid
#

Np

silver tinsel
#

if you r new to python i dont think django is the best to start with

glacial orchid
#

I got stuck for the whole day on sending email for resetting password but nthng working

glacial orchid
#

That's why I didn't choose flask

#

Nthng is hard if u have passion

#

@dense slate
When I am giving my email to reset password
It redirect to password-reset-done view but email is not sent
And matter of fact is that it all happens without creating Password-confirm-view
Any idea?
It shows email is sent but nthng happens

#

This is the last concept I wish to learn for my blog app

stable kite
#

@glacial orchid are you using django?

glacial orchid
stable kite
#

@glacial orchid have you set an email to sent mail from?

glacial orchid
stable kite
stable kite
#

@glacial orchid are you using any 3 rd party package?

dense slate
#

@silver tinsel Why not start with Django? It has most things included, lots of libraries, plenty of tutorials and docs...

#

It's a great framework.

dense slate
#

Ah, if you're new to Python... Yea I can see the reason behind that.

silver tinsel
#

yea thats what i meant

dense slate
#

I worked with Python about a year before jumping into any Framework.

silver tinsel
#

django is great for sure

#

but defently not so easy to undersatnd for a total beginner

glacial orchid
dense slate
#

Well, you also want to set yourself up for success.

#

And not get constantly discouraged.

stable kite
dense slate
#

@stable kite He's trying to use gmail.

stable kite
#

ya i know

dense slate
#

Gmail doesn't work like that anymore.

stable kite
#

what?

glacial orchid
stable kite
winged gull
#

WEB DEVELOPEMENT WITH FLASK IS WORTHY AND STILL RELEVENT FOR 3 4 YEARS CAN ANYONE PLZ ANSWER i am noob .

dense slate
#

I had to move to mailgun with its API because using gmail with SMTP no longer was supported.

#

If there's a way to use gmail, I sure don't know it anymore.

winged gull
#

anyone plz answer

dense slate
#

@winged gull Flask is relevant. If that's the question.

stable kite
native tide
#

Who knows the future? πŸ˜„ not me

glacial orchid
dense slate
#

Maybe there are some other free services, I'm not sure.

native tide
#

@glacial orchid are u using this?

winged gull
#

demi yes i want to build cv with web development projects ??

dense slate
#

@winged gull Go for it!

winged gull
#

yes bro

glacial orchid
silver tinsel
#

how can i make my footer stick to the bottom? so if i add a large main part i only see it when i scroll down

native tide
#

Who said anything about mailgun

glacial orchid
native tide
#

Did you read the link

glacial orchid
glacial orchid
dense slate
#

@silver tinsel I think that's more a CSS question than a python question.. but have you looked at tutorials to do that? Are you using bootstrap?

native tide
#

did you setup your smtp settings

dense slate
#

@glacial orchid What happened to me, when I was using gmail successfully, is that I stopped getting them. They sent sucessfully, but they would not arrive in my inbox.

native tide
#

gmail still works fine with django

glacial orchid
native tide
#

did you enable the settings in gmail

#

to allow third-party access

dense slate
#

Maybe 8 months ago or so.

glacial orchid
native tide
#

yep

glacial orchid
native tide
glacial orchid
# native tide yep

Even after enabling two factor authentication
And setting up app password nthng works

native tide
glacial orchid
#

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('User_Email')
EMAIL_HOST_PASSWORD = os.environ.get('User_Password')

native tide
#

and whats your view (for sending emails) looking like

glacial orchid
#

It's passwordresetview.as_view()

#

Default template
I have my own also

#

Own template

native tide
#

So you've done something like this?

@csrf_protect
def password_reset(request, is_admin_site=False,
                   template_name='registration/password_reset_form.html',
                   email_template_name='registration/password_reset_email.html',
                   subject_template_name='registration/password_reset_subject.txt',
                   password_reset_form=PasswordResetForm,
                   token_generator=default_token_generator,
                   post_reset_redirect=None,
                   from_email=None,
                   current_app=None,
                   extra_context=None,
                   html_email_template_name=None):
glacial orchid
#

I used class base view
Not this type of view
So no

#

But I saw am article doing similar thing

#

an*

#

I don't blv view has any issue
I think I have somehow not registered my email in the system
And dunno what to do about that according to documentation

#

Alright
It's 11:31 pm here
See h guys later
Good night

dry plume
#

Hello, where can i find a better host for django?

latent cosmos
#

hi

#

where can I find object oriented python section?

dense slate
#

@dry plume Better how?

#

Better than what?

dry plume
#

like unlimited db and some 10 GB storage

dense slate
#

I use DigitalOcean for my servers. You can get pretty good rates there.

dry plume
#

ok

#

Thanks

stone wren
#

can I get list of all the parameters without knowing the name of them? (flask-restx)

I'm trying to build some kind of proxy app, which will receive the request and then pass all the parameters, headers again to some server

halcyon lion
#

Eyo boys, can someone give me an example of some tasks you had to do for a job interview?

#

I heard thats common practice to get a task with like an hour to complete

woeful atlas
#

you know how to use a template (html) with quart with data transmission?

halcyon lion
#

learn to google dude πŸ˜„

#

i see you ask a lot of questions without bothering to google first

swift sky
#

hmmm

#

im trying to do password reset verification

#

im a bit lost tbh kind of just copy pasta code and trying to read some docs

#

im getting this weird error

#

the error is in regards to this portion of my code

#
    def send_reset_email(user):
        token = user.get_reset_token()
        msg = Message('Password Reset Request',
                      sender='noreply@example.com',
                      recipients=[user.email])
        msg.body = f'''To reset your password, visit the following link:
                {url_for('reset_token', token=token, _external=True)}
                If you did not make this request then ignore this email and no changes will be made.
                '''
        mail.send(msg)```
lofty portal
#

I'm getting a strange issue in Django:

Exception Value:     object of type 'int' has no len()
dense slate
#

@swift sky Is that Django?

lofty portal
#

Yup, when creating an object using a Django admin form.

#

It seems like the inlines model that I'm adding to another ModelAdmin form isn't working properly. It's inserting it into the form with an id of 0.

vestal hound
#

Eyo boys, can someone give me an example of some tasks you had to do for a job interview?
@halcyon lion did you Google this?

#

Yup, when creating an object using a Django admin form.
@lofty portal show model and form

dense slate
#

πŸ‘€

#

You need to share your code.

#

I don't even know what that is.

lavish prismBOT
#

Hey @lofty portal!

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

#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

#

Hey @lofty portal!

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

lofty portal
ivory prairie
#

hi

#

Can it be detected by other applications that I screen sharing from Discord, for example a system I entered via Google

#

?

lofty portal
#

?

ivory prairie
#

Can it be detected by other applications that I screen sharing from Discord, for example a system I entered via Google your thΔ±nk

#

Okay I screen sharing from discord

#

my screen google any web can this be detected

vocal berry
#

@lofty portal .

lofty portal
#

This is where I asked my question... Am I not in the web-development chatroom?

ivory prairie
#

I thought it was a question about web security and permissions

lofty portal
#

Nope. It's a Django Admin-site form submit error.

pallid apex
#

help I am getting error 500 on node side and 400 from my python

#
def data_getter():
    with open('../session-data/session_data.json') as session_data:
        data = json.load(session_data)
        data[request.form['sessionID']] = {'callSid': request.form['callSid']}
        json.dump(data, session_data, indent=4)```
#

^ where I am receiving the post

#
      'callSid': callSid,
      'sessionID': this.sessionId
    })
    axios.post('https://00000000000.ngrok.io/give_data', send_data, {headers:{"Content-Type": "application/json"}}
    ).then(res => {
      console.log(`statusCode: ${res.status}`)
    }).catch(error => {
      console.log(error)
    })``` where i am sending the post
#
KeyError: 'callSid'``` error from python
#

Error: Request failed with status code 500 at createError (/app/node_modules/axios/lib/core/createError.js:16:15) at settle (/app/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/app/node_modules/axios/lib/adapters/http.js:244:11) at IncomingMessage.emit (events.js:326:22) at endReadableNT (_stream_readable.js:1223:12) at processTicksAndRejections (internal/process/task_queues.js:84:21) { error from node hosted on gcp

final steppe
#

hello, would someone be how to enter information into a website. Example: I want to connect to my mailbox using a python program. How do I get the program to enter my username and password? thanks you very much!

karmic egret
#

Is there any place that I can store value in html except using query string?

#

the data will be store when generate html, not from the user

final steppe
gaunt marlin
final steppe
#

imagine that I want to brute force on my mailbox, I have to use the selenium library to be able to try the password that I tell him to try?

final steppe
vestal hound
#

Selenium is used for 2 things, mainly

#
  1. automated browser testing
#
  1. scraping websites that use JS
karmic egret
#

Is there anyway I can hide the query string

#

When I click this

final steppe
karmic egret
vestal hound
#

but how do you get that HTML in the first place?

final steppe
#

I do not understand everything. Sorry! Just so I was looking for a bookstore or something that would allow me to have a typing in a web page. I will learn more about selenium thank you very much 😊

vestal hound
#

normally

#

you use your browser

#

with the keyboard and mouse.

#

Selenium is a library that lets you control your browser with code

#

so you can, for example, tell it to click on a button

#

one use of this is to navigate a website programmatically

final steppe
#

oh it's really cool and powerful

#

but suddenly we can navigate using buttons or links but if there is a text box how do I fill it if I need it?

vestal hound
#

give focus to the box and fill it

thin dome
#

how to make tables for accounts in postgresql?

dense slate
#

Perhaps this channel could use a pin for how to ask questions. It would be helpful to make sure that people asking questions have at least investigated potential solutions and can show the relevant code so we can help in a meaningful way. Can we create some kind of guide or bot command for that?

#

<@&267628507062992896>

vestal hound
keen kettle
#

Hello everyone, I have an api I am calling that returns a very large json object. I have it writing to a file that I am attempting to ingest via FileBeat.

Output of the json result however in order to be read by file beat, it will all have to be on 1 line. How can I json.dump the object to export on just row 1?

#

Using requests to call api

#

Py3

#

Oh. . .

Json.dump(response.text.replace('\n',''), output_file)
#

Encase anyone was curious, tested

# wc -l file.log
Returned 0
shadow hornet
glacial orchid
#

@dense slate um
in tutorial Corey Schafer did the same to format the date but mine is not working
any idea?
I just want to remove the time

open owl
#

hey guys, am stack somewhere. How can i use django session captured in views.py file to the model, like populate the model field the request.session

glacial orchid
#

Does capture implies that?

versed python
glacial orchid
#

I have made spacesπŸ˜‚

glacial orchid
open owl
green snow
#

im trying to do ajax with django

#

i dont know why but m getting this error: $.ajax is not a function

elder jackal
#

i believe it's trying to find $ class object but fails

green snow
#

thanks ill try it

dreamy wadi
#

hello everyone

wide plume
#

Greetings everyone i had some questions
how to make some Jumplink in Django?

so i had a HTML page "Index.html"

in that Index HTML have a Navbar
Home,Info,etc

for instance some user click on Info on Navbar and it will show
<h3>Info!</h3>

i've tried using this
<a class="nav-link active" href="{% url 'SomeApps:info'%}#info">Info!</a>

and this is my Info
<a name="info"><h3>Info!</h3> </a>

i've tried this and search it on StackOverflow
https://stackoverflow.com/questions/25940811/how-to-add-anchor-to-django-url-in-template/25942548

and didn't work.

My Django version 3.1.3

Thank you.

hoary marlin
#

Hey Guys,
I've been trying connecting My flask app with Mysql db.
The connection was succesful but when I am accepting an input from user it shows error:
TypeError: an integer is required (got type str)

here's my flask code:-

from flask import Flask, request, render_template, url_for, redirect
from flask_mysqldb import MySQL
import yaml

app = Flask(__name__)
db=yaml.load(open('db.yaml'))

app.config['MYSQL_HOST']=db['mysql_host']
app.config['MYSQL_USER']=db['mysql_user']
app.config['MYSQL_PASSWORD']=db['mysql_password']
app.config['MYSQL_DB']=db['mysql_db']
app.config['MYSQL_PORT']=db['port']


mysql=MySQL(app)



@app.route('/',methods=["POST","GET"])
def login():
    if request.method =="POST":
        coachDetails=request.form
        name=coachDetails['username1']
        passw=coachDetails['password1']
        cur=mysql.connection.cursor()
        cur.execute("INSERT INTO CoachData(cname) values (%s)",(name))
        mysql.connection.commit()
        cur.close()
        return 'success'
    else:
        return render_template('reg.html')

@app.route('/show')
def user():
    return render_template('show.html')




if __name__=='__main__':
    app.run(debug=True)

here's my Yaml code:-

mysql_host: '127.0.0.1'
mysql_user: 'root'
mysql_password: 'yash'
mysql_db: 'loginEx'
port: '3306'

here's my MySql table structure:-
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| cname | varchar(20) | YES | | NULL | |
| cpass | int | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+

it's actually urgent so I would be really thankful.

timid belfry
#

can anyone tell is it compulsory to use serializer on every class in models in django rest framework? do ping me if someone knows

timid belfry
timid belfry
hoary marlin
timid belfry
hoary marlin
elder jackal
#

ah wait

elder jackal
#

cur.execute("INSERT INTO CoachData(cname) values (%s)",(name))

| cpass | int | YES | | NULL | |

#

trying to insert str values into int-typed pass probably

#

nope

#

full traceback shows your port should be int

#

in your yaml change port from
port: '3306'
to
port: 3306

hoary marlin
elder jackal
#

xD

#

cant you see the traceback

hoary marlin
elder jackal
#

yeah is it running?

#

telnet 127.0.0.1 3306

hoary marlin
elder jackal
#

check the port is open for connections

#
To display all open ports, open DOS command, type netstat and press Enter.

To list all listening ports, use netstat -an |find /i "listening" command.
#

thats how you do it in cmd

hoary marlin
elder jackal
#

try 3306

#

you have it 3306 in yaml config right

#

not 3360

hoary marlin
elder jackal
#

ok what you shuld do now is to launch the mysql right

#
To start the mysqld server from the command line, you should start a console window (or β€œDOS window”) and enter this command:

shell> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld"
The path to mysqld may vary depending on the install location of MySQL on your system.
lofty portal
cunning birch
#

@lofty portal Yes I try with the console and it gives me the Category object but in the views.py it shows me the 404 error

lofty portal
#

Yeah, sorry, I was too quick to respond. That's a generic message just telling you that you shouldn't show the debug in production...

#

What IDE are you using?

#

In VScode you can debug your Django app and see the variables when you submit the form. It may show you what the underlying issue is.

cunning birch
#

@lofty portal no I am using sublim text and the main error is: "No Category matches the given query."

lofty portal
#

What's the query? Perhaps that's not matching what you expect it to?

cunning birch
#

@lofty portal I am developing an e-commerce site but when I add a product to the cart I get this error and above I have the images of my code!

lofty portal
#

No need to get snippy. I'm trying to help, and I can see your code.

mental lodge
lofty portal
#

@cunning birch I would highly recommend getting VScode, it's free and you can probably debug the issue using that.

#

@mental lodge Are you in the correct path when you run that script?

mental lodge
#

yes

lofty portal
#

When you type ls it shows up?

#

Was it uploading before, or is this the first upload?

mental lodge
mental lodge
lofty portal
#

Sorry, I'm just asking generic questions hoping it will spark something for you to figure it out.
I don't use heroku, so I'm not quite sure. I usually just run my own ubuntu server with nginx and gunicorn.

mental lodge
#

have been trying for the past 5 days, got stuck

lofty portal
#

Are you running through a tutorial or something?

mental lodge
#

yeah

lofty portal
#

Maybe try backtracking and going through the steps again to see if you missed something. I do that sometimes and find that there was some little thing I missed.

mental lodge
#

followed corretly ,but i cant find a lead to move further

lofty portal
#

Seems like the heroku server is missing the manage.py from that message.

mental lodge
#

cant find a solution with that tutorial

lofty portal
#

Have you gone on the remote server to see if the project was uploaded there properly?

mental lodge
#

you mean host?

lofty portal
#

Yup

mental lodge
#

yeah its running perfictly

#

*perfect

lofty portal
#

Ok, so the site is running already for you?

#

You're just trying to migrate an update to the database for a change you made to a model or something?

mental lodge
lofty portal
#

You can also look at the logs by typing heroku logs --tail, maybe find something useful there.

mental lodge
mental lodge
#

thanks dude

lofty portal
#

Sorry I couldn't help more.

mental lodge
#

not a problem , thanks anyway

lofty portal
mental lodge
#

thanks a lot dude, will check this too

lofty portal
mental lodge
#

will check it

glacial orchid
dense slate
#

@cunning birch I think that's saying that the query you are trying to find (probably the item id), doesn't exist in that table.

#

So if you're looking for a particular UUID, that id doesn't exist in that model.

#

@glacial orchid Virtual servers cost money, yes.

#

But you can get basic ones as cheap as $5/month.