#web-development

2 messages · Page 178 of 1

rocky ferry
#

?

arctic wraith
#

you give a specific name to your function views

#

and you can just call the view on your html code using {% url %}

#

oh i forgot , href="{% url 'your_name' %}"

rocky ferry
arctic wraith
#

your urls ?

#

did you add the name

rocky ferry
#

yes

arctic wraith
#

no not here

rocky ferry
#

then

arctic wraith
#

delete what you've done here in views

#

don't change your views , put just the attribute name in your urls

rocky ferry
#

yeah it is working

arctic wraith
#

okey

rocky ferry
#

but why still

#

i get this error bro

arctic wraith
#

try to work with name in both of your apps

rocky ferry
#

do i need to put name in project url.py

#

also

arctic wraith
#

yeah

#

work with {% url %} it's better

rocky ferry
#

can u please explain me how in backend it is working

arctic wraith
#

it is a way to add a link to another one of your pages in the template. url tells the template to look in the URLs.py file, and it changes dynamically

rocky ferry
#

wow

#

i have added but still it shows me this error bro 😦

arctic wraith
#

it tells the template to look for something with name=(name of the url)

rocky ferry
arctic wraith
#

no not here , it's not necessary

#

in your 2 apps

rocky ferry
#

but when i open my server it is throwing me error

#

how can i overcome it

arctic wraith
#

you added the name at app register ?

rocky ferry
#

yes

arctic wraith
#

add your names at the second app

rocky ferry
#

i did still same error

rocky ferry
arctic wraith
#

show your html

rocky ferry
#

when i click on register it working

#

but the problem is when i open local host it is throwing me error

arctic wraith
#

did you change all your a href ?

rocky ferry
rocky ferry
#

currenctly working for one register thing

arctic wraith
#

change it for all

rocky ferry
#

actually i'm using template

arctic wraith
#

it's better to work like this

rocky ferry
#

so i got to use {% static %}

arctic wraith
#

yeah {% load static %}

#

work with python code in your html

rocky ferry
#

yeah i'm using that to render the static files

#

it works fine

#

but when i added register it got messed up

#

!pastebin

arctic wraith
#

look at this one , you will understand

rocky ferry
#

yeah i saw it

#

so basically , since i'm using rendering 2ndapp stuff from 1st app

#

i need to use this syntax

arctic wraith
#

yeah

rocky ferry
#

i removed other navbars

#

but still same error

rocky ferry
#

like <li><a href="#"><i class="fa fa-pinterest" aria-hidden="true"></i></a></li>

arctic wraith
rocky ferry
#

then why it is showing me error on local host

#

😦

arctic wraith
#

it shows error at your fist page ?

#

for the others no ?

rocky ferry
#

first page bro

arctic wraith
#

what is the first page , i mean url and view

turbid mirage
#

I have a model with a many-to-many relationship. The relationship is between 'User' and 'Movie'. The Movie model contains the many-to-many and has a related name: "users_liked". When I create a movie it should always default to "Liked" by the User. In the template, I will have an if condition to check if it is liked or not liked and return a thumbs up or down. Right now this is what is returned: 'movie_review_app.User.None`. It is the name of the app plus the name of User model and then None. I really do not understand this. When I add a movie it is always False. I can send a couple screen shots of HTML, Model and Views.

rocky ferry
#

localhost

rocky ferry
arctic wraith
#

it didn't find the template

#

probably your url

#

not the correct one

#

check your url please

versed python
#

I assume youre using Django?

turbid mirage
#

Yes

rocky ferry
#
from django.urls import path,include

urlpatterns = [
    path('admin/', admin.site.urls),
    path("",include('travello.urls')),
    path("",include('register.urls',)),
    #path("hello/",include('calc.urls')),
    
]
#

this is my url

versed python
turbid mirage
#

This is how I am creating the movie when added within the views.py

arctic wraith
versed python
turbid mirage
#

I do not think so. Not sure what signals is.

rocky ferry
#
    path('admin/', admin.site.urls),
    path("",include('travello.urls')),
    path("/register",include('register.urls',)),
    #path("hello/",include('calc.urls')),
    
]
#

i changed url

#

but still same

versed python
rocky ferry
versed python
arctic wraith
versed python
arctic wraith
#

your index is in travello right ?

rocky ferry
#
from django.urls import path,include

urlpatterns = [
    path('admin/', admin.site.urls),
    path("",include('travello.urls')),
    path("/register",include('register.urls',)),
    #path("hello/",include('calc.urls')),
    
]
turbid mirage
#

I can give you GitHub. Would that be better?

rocky ferry
versed python
rocky ferry
#

May be I should use static

#

In href

stark tartan
languid heron
#
The WebSocket transport is not available, you must install a websocket server that is compatible with your async mode to enable it```
 I get this error when trying to start a flask server socketio and make a connection from my reactjs frontend
#

Any clue why?

elder forge
#

say i want to take an upload from the user then do some action on the file and return it to the users
which storage service is the best for it. I don't want to save the file for longer may 15 mins max
which storage service can give me this any idea anyone.

versed python
rocky ferry
#

@versed python

#

can u please help me

versed python
#

whats the problem?

rocky ferry
#

path problem bro 😦

versed python
#

why are you trying to access /home? it clearly does not exist

rocky ferry
#
from django.urls import path,include

urlpatterns = [
    path('admin/', admin.site.urls),
    path("travello",include('travello.urls')),
    path("register/",include('register.urls',)),
    
    
]```
versed python
#

you forgot at the end / in travello

rocky ferry
#

yeah ur right , i have one question bro it is not possible to put empty path

#

for by default

#

like a landing page or home page

#

?

versed python
#

yes it is

#

path("", view_func, name="landing_page")

rocky ferry
#

i can put it in any template folder of any app

#

will it work

versed python
rocky ferry
#

u mean only in project url

#

i can write a view and call it there

turbid mirage
#

@near ocean If you are in you project urls you can have empty path

rocky ferry
#

ok

#

thank u so much guys

#

@versed python

elder forge
versed python
#

and no, you can not configure which files would be deleted

#

another method to solve would be hosting your app on a custom server and running a cron job every x hours to delete the files that are not needed

#

this would be the better method if you expect the app to actually get serious

elder forge
versed python
#

cron jobs are very easy, look up a tutorial

elder forge
versed python
#

ive personally used AWS and digital ocean so it should work there

#

but any platform that supports linux systems should be able to do this

native tide
#

Can get some tips to get some real client who will ay

#

I mean pay

elder forge
native tide
#

Cause I have a good experience but can't find a client

elder warren
#

Hi! How do I start making a website? Any useful sites I should rely on? 🙂

thorn igloo
gritty cloud
#

Learn it, and learn it right

opaque rivet
#

Bootstrap/tailwindcss are life savers tho babyrage

gritty cloud
rocky ferry
#

setting.py ```DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'telusko',
'USER':'postgres',
'PASSWORD':'root',
'HOST':'localhost'
}
}

#

register form ```<Html>
<head>
<title>
Registration Page
</title>
</head>
<body bgcolor="Lightskyblue">
<br>

<form action="/users/register" method="post" >
{% csrf_token %}

<label> Firstname </label>      
<input type="text" name="firstname" size="15"/> <br> <br>

<label> Lasttname </label>      
<input type="text" name="laststname" size="15"/> <br> <br>

<label> username </label>      
<input type="text" name="username" size="15"/> <br> <br>

<label> Password: </label>  
<input type="password" name="password2" size="15"/> <br> <br>

<label> Conform Password: </label>
<input type="password" name="password2" size="15"/> <br> <br>

<label> Email: </label>
<input type="email" name="email" size="15"/> <br> <br>
     
 
<input type="submit" value=" Register " size="15"/> <br>

</form>```

#

views.py code ```from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.models import User,auth
from django.contrib import messages

Create your views here.

def register(request):
if request.method=='POST':
print("success")
first_name= request.POST['firstname']
last_name= request.POST['lastname']
username=request.POST['username']
password1= request.POST['password1']
password2= request.POST['password2']
email=request.POST['email']
if password1==password2:
if User.objects.filter(username=username).exists():
messages.add_message(request, messages.INFO, "USER NAME TAKEN ")
else:
user=User.objects.create_user(username=username,password=password1,email=email,
first_name=first_name,last_name=last_name)
user.save()
messages.SUCCESS(request, messages.INFO, "SUCCESS HOMIE ")
else:
return render(request,'register.html')

tacit jewel
#

Hi, can anyone tell me what’s this feature called in css or bootstrap..

If I have to auto scroll a text (like the stock prices on a business news channel) if the text is getting wrapped.

rocky ferry
#

i don't understand why user is not adding to my database

stark tartan
#

i want to show the recent chats in left section of chats i use Django channels for chating but while chating in one group the new messages from other groups are not coming in left section as a recent chats of chat please can you tell me what to do

native tide
native tide
tacit jewel
native tide
tacit jewel
#

Thanks anyway

opaque rivet
#

@tacit jewel overflow-x: scroll

tall plaza
#

hi i am trying to deploy django api on heroku
i am facing some error
libGL.so.1: cannot open shared object file: No such file or directory

#

anyone have any idea

#

about it

tacit jewel
versed python
opaque rivet
tacit jewel
gritty cloud
tacit jewel
hot sandal
#

has anyone heard of fast api?

#

how do y’all feel with fast api vs flask

rare oar
#

I’m using fast api right now in a small project I just started so far it seems fantastic.

#

Also along that note: any way to mix best of both worlds? I’m using server side rendering and templates for ease. But itd be great if I could inject a component that will fetch an api and display data and not hold up the response. Is that doable? Was thinking it could be easy as injecting react in a small block, but that seems like a lot of overhead.

rare oar
#

this channel moves too fast for me

tranquil anchor
#

does anyone know how to use these variables in bulma?

merry lotus
#

Hey everyone, so I'm learning django and blogging about it simultaneously, so I want to upload it on GitHub. I won't be using this project for production, only as a portfolio item. So considering I'd like someone to be able to run it on their system, is it okay to commit everything, or do I need to hide certain things?

(I'd just like to confirm that nothing inside the django code contains any information about my computer that might help a potential hacker later down the line - - low probability but I'm still just concerned)

Thanks!

topaz widget
merry lotus
#

Yes, I was wondering what to do about that...
Since I'm not gonna deploy this site online, is it okay if I just removed the line of code containing the secret key?

topaz widget
#

I put the secret key into a JSON file and load the JSON to obtain the secret key for the project.

#

None of my Django code contains the secret key, only references to it.

#

You may want to put this site online eventually, so I would just get in the habit of moving the secret key to another file and importing it.

merry lotus
#

Yep I'm gonna do that too, I'm actually working on two django projects: the first is a django version of my blog (which is currently built on WordPress) and the second is a portfolio item, so I'm thinking when I deploy my blog I'm gonna move the secret key to a safe place, among other things

#

Is there anything else that I need to take care of?
I ran the checks, got quite a few things but I'm not sure they're needed at this point...

topaz widget
#

Everything else is up to you, though. Hackers can take a look at your backend code if you put it all up on github, and if it's poorly written, they can still find exploits.

merry lotus
#

My main concern is not the site getting compromised, I hope I'm making that clear

topaz widget
#

What is your main concern then?

merry lotus
#

It's a learning based project, so I'll be uploading the backend code too, and it'll all be accessible to everyone

#

My concern is the code containing something about my device that could help a hacker

topaz widget
#

Nothing in your github repo should have any information about your device.

merry lotus
#

When I deploy my blog itself, that's when I want to make sure no one can see the backend code

topaz widget
#

Unless you put information about your device in the directory that the git repo is cataloging.

#

Django is meant to run on a web server, so if you just put your repo at the top level of your Django project, it shouldn't have any information about your device.

#

I wouldn't worry too much about that, though.

merry lotus
#

Makes sense, I'm just overly cautious about this kinda stuff haha

topaz widget
#

You send information about your device to websites every time you make an HTTP request.

merry lotus
#

Yeah there's that too

topaz widget
#

Have you ever looked at an access log before?

merry lotus
#

I'm quite new to the world of Web development

#

Not really

topaz widget
#

Okay, well, if you take a look at an access log, it has something called a user-agent string, parameter, what have you. It has information about the browser and the device.

#

These log entries also have IP address, HTTP status code, time of request, and a little more.

merry lotus
#

Yeah it's just easy to forget, I mean nothing is really hidden to someone who cares to dig deep enough

topaz widget
#

So I wouldn't worry too much about putting out information about your device because you're doing it all the time when you get on the internet.

#

What I would worry about is putting private information like secret keys out there for anyone to see.

topaz widget
#

User agent strings can also be spoofed.

#

which is one reason they're not a great way to identify someone alone.

gritty cloud
#

then import everything you need to build the full css file

#

these variables define the navbar

tranquil anchor
#

rn im importing bulma like this

topaz widget
#

I once wrote a script for doing web scraping that spoofed the user agent string so they couldn't see I was using Python to access their website.

gritty cloud
#

to customize you need the npm package

#

or if your using Django

tranquil anchor
#

sob

merry lotus
tranquil anchor
#

i am

gritty cloud
#

you can use dcjango simple buloma

#

!pypi django-simple-bulma

lavish prismBOT
tranquil anchor
#

oo

gritty cloud
#

and it customizes for you

tranquil anchor
#

oh ill check it out

tranquil anchor
topaz widget
#

@merry lotus
Here is a log entry from my website:
114.119.142.112 - - [05/Aug/2021:19:47:42 +0000] "GET /robots.txt HTTP/1.1" 404 7047 "-" "Mozilla/5.0 (compatible;PetalBot;+https://webmaster.petalsearch.com/site/petalbot)"

#

The first number is the IP address.
The next thing in brackets is the time of the request.
Next is the type of request (GET) , the url they were attempting to access (/robots.txt), and then the protocol that was used (HTTP/1.1)

#

Next is the return code (404 - I don't have a robots.txt file--I should probably add one but I don't care at the moment)

#

After that, where it says Mozilla/5.0... is the user-agent string.

#

So it appears that this was a search engine crawling my website (or someone posing as one).

merry lotus
#

Whoa nice, that's really cool!

topaz widget
#

Yeah, that's typically the kind of thing you can see as the admin of a website.

merry lotus
#

Question: my site hasn't been indexed by Google yet, but cloudfare tells me I had like 500 visitors this month, so could you maybe suggest what's going on?

#

only a couple friends know about it at the moment, so idk how I'm getting that kinda traffic... Unless something is up with that

topaz widget
#

It's spammers and hackers. I think they're getting your domain name from the registry but I'm not sure about that.

#

Some of the traffic might be search engines, too.

#

Cloudfare probably has a way for you to see the access logs, and there are services that tell you the origins of IP addresses.

#

one such site I've used is db-ip.com

#

If you run an IP address through that database, it has metadata about that IP address.

#

But just be aware that IP addresses aren't always the best way to identify because requests can be routed through proxies (like a VPN).

#

If you can see the access logs, you might be able to infer the intent of the requests.

merry lotus
#

Okay...lots of stuff to learn
Could you give me some very basic tips about securing my site? I'm only learning security rn, and I'm doing the best I can, like yesterday I disabled directory listing...but still got lots to do

topaz widget
#

I get requests that are almost certainly hackers trying to break my website.

merry lotus
#

Also I'm trying not to use many plugins

topaz widget
#

When I get a POST request to a url that doesn't exist at my domain (and is a typical admin login url for a wordpress site), it is almost certainly a hacker attempting to get into my backend.

#

I'm not too familiar with Cloudfare. Do they just do hosting, or do they also have CMS solutions like Wordpress?

#

Do you have a portal you log into to make changes to your website's content through cloudfare?

dapper tusk
#

cloudflare barely even does hosting

merry lotus
#

Oh I'm only using cloudfare for caching and security, I've hosted my site on bluehost with WordPress

topaz widget
#

Is it like wordpress then?

dapper tusk
#

their main service is a cache and a firewall

merry lotus
dapper tusk
#

they also have static hosting and "not amazon lambda", but few use that

topaz widget
#

I mean, I'm not super familiar with wordpress, but I'd say change the admin login page url to something unique if you can (don't use the default) and pick a strong password.

#

I see a lot of requests targeting default wordpress urls in my access logs.

#

I don't use wordpress, though, so it's kind of funny.

merry lotus
#

They're just throwing stuff at the wall and hoping something sticks, then?

topaz widget
#

Other than that, the fewer plugins the better, as those can also be attack surfaces.

merry lotus
#

I'm learning django so I can move away from wordpress and take full control of my site

topaz widget
dapper tusk
#

~40% of websites use wordpress, so it is a pretty good attack vector all things considered.
But yes, make sure you don't have default passwords anywhere, ideally have https, keep things up to date

topaz widget
#

Yeah, https is a must.

dapper tusk
#

cloudflare will generally ban suspicious IPs and block their accesses, but it is not perfect and you should not rely on it

topaz widget
#

The web security rabbit hole goes pretty deep. Unless there is big money or sensitive political information involved in your website, you probably don't have to worry about the more complex forms of attack.

#

@merry lotus Here is a reference for some of the most common security issues facing websites and web applications:
https://owasp.org/www-project-top-ten/

merry lotus
#

Thanks! I'm gonna bookmark this right away and keep strengthening my protections!
I don't think someone would have a lot of incentive hacking my website, but still, this looks fun

topaz widget
#

The people who cast a wide net and take the lazy approach to hacking are the ones you should protect yourself from because petty internet crime is really easy for people to get away with. Fortunately, it is also the easiest form of hacking to counter.

merry lotus
#

Yep,I reckon they'd mostly do it for hijacking hosting room on servers?

topaz widget
#

That's more likely that getting free hosting.

#

They're just looking for a quick buck.

merry lotus
#

Totally plausible, thankfully I don't have anything like that on my website currently, but I have plans

#

Man, this thing looks so overwhelming but so fun

topaz widget
#

That seems too complex to manage.

#

for someone like that.

merry lotus
#

😅 I don't know about that

topaz widget
#

I'm pretty sure they're just looking for sensitive information.

merry lotus
#

Uh so I regularly test my website on places like pagespeed insights, could the unique visitors possibly be those sites?

topaz widget
#

related to finances

#

I mean, if they're accessing your website, then they would show up in your logs.

merry lotus
#

Looking at visitor demographics, I only have visitors from the US, UK and India. A few in Ireland, China, France. That's it.

topaz widget
#

I find it hard to believe IP addresses are only originating from those places.

#

I get requests from all over the world.

merry lotus
#

An awful lot of visitors from the UK, I don't even live there lol. Idk if that's a VPN or something because that'd be more evenly distributed?

topaz widget
#

including even Iran

#

VPN seems like a likely culprit.

#

I don't know what UK's privacy laws are, but VPN requests often originate from EU countries because the EU has pretty strict privacy laws which makes it harder to pin down the source of requests.

mint folio
tranquil anchor
#

@gritty cloud can u help me out with the extension ?

#
BULMA_SETTINGS = {
  "extensions": [
    "bulma-collapsible",
    "bulma-calendar",
  ],
  "variables": {
    "primary": "#000000",
    "size-1": "6rem",
  },
  "alt_variables": {
    "primary": "#000000    ",
    "scheme-main": "#000",
  },
  "output_style": "compressed",
  "fontawesome_token": "e761a01be3",
}
#

I defined primary to black in settings

#

in html i added these lines

#
    {% load django_simple_bulma %}
  {% bulma %}
  {% font_awesome %}
#

also

<nav class="navbar is-primary " role="navigation" aria-label="main navigation">

#

but color still didnt change

ionic raft
#

Well, that was an adventure. Just managed to build a Django connection to Stripe, successfully test a subscription, return to the site, AND update the user's Subscription model info. A huge day of progress really.

foggy bloom
#

Hi guys, I'm trying to build my django rest api, and i'm stuck with a question about how can I create a viewset that aggregate data from a model. You have any website or tutorial that can help me?

quartz yacht
#

Anyone have advice on creating a multi user registration form in django?

ember adder
ember adder
clear bone
#

Hey everyone I've been working on this spotify api app with Django. Today, after a long struggle with deploying onto heroku (static files), for some bizarre reason my app just doesnt work. Attached is a screenshot of the error message. "spotify" is the name of the app. what I find to be completely baffling is the fact that running the django app on localhost works perfectly. any thoughts on how to troubleshoot this weird error?

coral jackal
topaz finch
#

I have been working on parsing user agents, and I have done fairly well. The one thing that appears to be messing me up a bit is some of the user agents with silk-accelerated=true in them. What exactly does this mean?
Please ping when answering.

topaz finch
#

ok thanks, I will read through this

rocky ferry
rocky ferry
#

finally i got the solution

dusk portal
#
@api_view(['DELETE'])
def taskdelete(request,question_id):
    try:
        task=Task.objects.get(id=question_id).delete()
    except Task.DoesNotExist:
        raise Http404(status.HTTP_404_NOT_FOUND)
    return Response(task.data)```
rocky ferry
#

if we are creating template for each app it's better use {% url ' ' %} or else we can use url/url

dusk portal
#

i have a object ft id 8

dusk portal
#

error : ```py

"detail": "Method \"GET\" not allowed."```
#

postman look

crisp crane
#

def genPrimes(l=[]):
return l.clear() or (l.append(p) or p for p,_ in enumerate(iter(int,1),2) if all(p%i for i in l))
Can anyone help?

#

trying to understand this piece of code

worldly garden
#

Hello, who could help with docker ? I have this issue

inland oak
worldly garden
#

postgresql

inland oak
#

did you check its config, if you made allowed connections others than from localhost(127.0.0.1)?

#

you do realize that your dockerized application has basically ip 172.18.0.1(or something like that), which is not localhost

worldly garden
#

yes, I made this in django settings: ALLOWED_HOSTS = ['*']

inland oak
#

no

#

postgresql config

#

as in

#

/etc/postgresql/config.cfg

#

(or some similar address)

worldly garden
#

where I can find postgres config ?

inland oak
#

i have it at the path /etc/postgresql/12/main/postgresql.conf

inland oak
worldly garden
#

nope

#

win 10

inland oak
#

do you have postgres installed in windows?

worldly garden
#

yes, ah I need to go to the folder with postres ?

inland oak
#

yes

worldly garden
#

ok, one sec

inland oak
#

you need to switch two settings there

#

postgresql.conf
listen_addresses = '*'

#

pg_hba.conf
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all ::/0 md5
host all all 0.0.0.0/0 md5

#

those two changes in two files are enough to allow unrestricted access from any ip

#

btw, it is quite unsafe for production, so use it for development only

#

or make sure to have a long password at least

worldly garden
#

I have postgresql.conf.sample

#

that it ?

inland oak
#

of the postgresql.conf file

#

I don't know how it all works in windows, it should be somehow similar I guess

worldly garden
#

ah I found these files

wispy quail
#

Q: What happens when using celery itself as the broker instead of rabbitMQ?

inland oak
#

but I am not 100% sure

worldly garden
#

and no, I have the same problem 😦

inland oak
#
  1. local replication all peer
    host replication all 127.0.0.1/32 md5
    host replication all ::1/128 md5
    host all all ::/0 md5
    host all all 0.0.0.0/0 md5
    Allowing access not for all users
#

but for specified only one user?

#
  1. making sure allowed user has long password
wispy quail
worldly garden
inland oak
#

I mean it sets listening...

worldly garden
#

I'v already have this in settings

inland oak
#

basically we can set only

  1. listen to localhost only, if you have database and app at the same server
#
  1. or listening from all ips addresses your server has
#

so... really permissions you should set only at the level of

#

only here
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
host all all ::/0 md5
host all all 0.0.0.0/0 md5

#

here you can specify which user and from which ip addresses can access your db

worldly garden
#

ok, I got the idea, I'll try to manage this problem

#

thanks

native tide
#

,si

ionic raft
# ember adder I am currently developing a Stripe integration feature in Django. I used Stripe ...

That's fantastic. I have 3 different subscription tier products so once I got the first one done the next was simple enough. Need to a bit more template work for the third since it's a discounted yearly version over the month sub. I'm circling back to webhooks for failed subs tomorrow. But the idea of offloading the credit card processing and storage to Stripe works for me! And yes, seeing all those views/templates automatically updated based on the membership tier level...really cool! Congrats back at ya!

ionic raft
#

I was also REALLY impressed with Stripe support. They use Discord for support. I'm going to be using Discord for LanesFlow support. Much easier than building out a forum or Q&A when Discord has the foundation to offload. It was a link on their webpage, I clicked, was in, and navigated to threaded help in less than a minute. Was chatting to a dev and got the final help to make the connection with Stripe

#

Discord's one-click and you're in...that's my jam right there. Plus, set up a few channels, and can even created dedicated channels for top-tier clients. ideal

mint folio
#

Yeah stripe support, documentation and overall integration is probably one of the best I’ve seen. Especially compare to other gateways like PayPal, which can be a fucking pain.

ionic raft
mint folio
#

Although PayPal has improved recently I believe

ionic raft
#

It covered Python...However, their Discord support made up for it.

#

The target market for LanesFlow is business. So PayPal really isn't required for phase 1

#

Stripe was a must-have tho

wispy vault
#

jinja2.exceptions.TemplateSyntaxError

lunar geyser
#

hey does somebody know how to use the database models made in django in other scripts that dont really follow the django implementation

versed python
lunar geyser
#

ok i will take a look at it

inland oak
#

plus... in theory you can just enable django in standlone I guess mode, for its Django ORM being available even in other scripts

#

at least I managed to do that for celery scripts

#

and for sphinx docs

#

it requires just few lines of code I think

lunar geyser
#

ok i guess i will try on the standalone mode so i dont have to rewrite my models

inland oak
#
import django
import os

# Set the default Django settings module for the 'celery' program.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings")
# django.setup() # optionally to launch django initialization completely fully with all apps inits
#

if I am correct, all you need to set this DJANGO_SETTINGS_MODULE variable

#

plus perhaps django.setup() could be needed in addition

#

and that's basically it 😉

lunar geyser
#

ok thanks a lot

#

i will try that out!

#

👍

inland oak
#

u a welcome.

#

in Sphinx I made in this way, not sure if ../.. path is really needed being added

import os
import sys
import django
sys.path.insert(0, os.path.abspath('../..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'core.settings'
django.setup()
lunar geyser
#

i read something that you can register something like this as a django command like python manage.py {commandname}

#

also as daemon

#

if i would take something like this as a approach, could i communicate with the django apps in the website from the daemon

inland oak
#

instead of using the console version python manage.py something

#

we can use...

#
from django.core import management

management.call_command("migrate")
management.call_command(
                "flush",
                "--noinput",
            )
#

as example to migrate and nulify the data in db

lunar geyser
#

ok but like if i am running a daemon (smth like a discord bot) and i want to tell the bot to react to a change made on the website (like leave a server, etc) how would i do that

inland oak
#

urgh.

inland oak
#

that makes additional complexity

#

if you use discord bot...

#

it requires it all being async friendly

#

django ORM is not async friendly

#

you need to wrap it into something like...

lunar geyser
#

jeah ig now you got my problem

inland oak
#

here is example how i solved it for my discord bot

lunar geyser
#

like i am looking for the right thing before i write smt and realize that that is a bad thing

inland oak
#

as easiest solution I upgraded my python to 3.9

#

because it has the easiest in built feature to handle it

#
import asyncio
await asyncio.to_thread(
                self.get_new_forum_records)
#

self.get_new_forum_records is the name of my sync function

lunar geyser
#

ok that means

inland oak
#

this asyncio.to_thread makes sync code running in alternative thread

#

in order to have the main thread remaining asynced

#

in the get_new_forum_records function I make actions like request Django ORM (or in my case used Selenium)

#

this is important because...

#

...if you don't do that, discord bot just lags and can't login

#

because it happens in async background

#

which would be stuck and busy if you have constant usage of sync code

#

and bot intreface would be not responsive too

#

if you use sync code all the time

#

but this async.to_thread is a work around of it

#

at the cost of additional parallel CPU usage

#

not optimal for real production probably, but optimal for home made stuff for sure

lunar geyser
#

hmm ok

#

like i got what you explained but

#

that was more like how to start the bot right?

inland oak
#

I used this function in background loop constantly during bot usage

#

when it was without async.to_thread, the bot was not starting itself because async main thread was busy all the time

#

and its console interface was not responsive

inland oak
#

when you add any sync code to it

#

or the bot would basically not start itself at all

lunar geyser
#

ok that is a thing that i would not have noticed on my own. so thanks

dusk portal
#

Ohh

lunar geyser
#

but lets pretend we have a discord bot and a website seperatly
how would i let those two comunicate. So you could push a button on the website and the bot does smt instantly

dusk portal
#

Can someone tell me the whole roadmap
After someone has done django
And rest Framework how can he go to advanced at rest Framework how can he learn Django Channels why he needs to learn Django channels
And resources too

#

Cez i am ready to give my 101% next 1-2 years

inland oak
# lunar geyser but lets pretend we have a discord bot and a website seperatly how would i let t...

I'll just bubble anything that comes to my mind about it.
Basically you are looking for message queue pattern

In ideal situation we have master who inits the commands, which are sent to queue like NoSQL database redis
and available worker processes any first taken task

in this situation master would be your website
broker would remain someone like redis
and worker would be your discord bot application

#

What prevents your from doing that?

#

finding how the hell worker application could be launched properly with discord bot enabled in passive mode

#

as a dumb not really optimal work around...

#

we can just... make the messaging queue on our own, reinvent the wheel

#

our website would be sending commands to redis in direct way

#

and your bot would have background loop that checks the redis

#

if finds the tasks, takes one, completes and removes when finished

#

takes the next task and e.t.c.

#

ideally it could be made without reinventing the wheel with celery

#

which is made exactly for this

#

but how to connect celery with discord bot... that's a problem

lunar geyser
#

yes i thougth about something like a queue in a database but that was smt that didn' t seemed "professional" for me and was really janky

inland oak
#

it keeps all the data in its RAM memory

#

and works basically like a key-value dictionary

#

it is specifically suited to do tasks like that

lunar geyser
#

ok is there any downside of doing that

inland oak
#

well, as far as I heard

#

the standard library which I like to connect from django to redis... is sync too%

#

and async libraries for redis a bit unstable

#

so... again using asyncio.to_thread, or using unstable async libraries to connect

lunar geyser
#

ok ... hmm

#

ok i will do some research and have lunch but thanks for the good starting point 👍

inland oak
#

u a welcome

glacial yoke
#

is it possible to create a spinning wheel on a website, using django, where people would enter a so called game with different values, therefore having a different chance of winning, then the wheel would spin, and through random using all the chances of all people, it would output the winning person?

inland oak
glacial yoke
inland oak
#

I think spinning wheel could be drawn with Canvas(HTML+Javascript) if I am not mistaken (not really familiar with frontend)

#

you can storage your users with Django ORM in postgres for example

glacial yoke
glacial yoke
frigid tide
#

hi i want develop a web that got checking system,auto email system and login system,what should use

dapper tusk
#

that seems like something django would be good at

frigid tide
#

what is django?

dapper tusk
#

a python web framework

frigid tide
#

oh,ok

#

can you send django link through DM

dapper tusk
thick hull
#

hello

#

i made a html redirect link

#

and i want the link to open in youtube app, not in browser if its a mobile and if theres the yt app, how do i do it?

versed python
#

I don't think there's a way to do it.

#

But i suggest you look it up

#

Since I am not sure

thick hull
#

cant find anythikg

versed python
#

Yeah

#

There's no way to do it then

thick hull
#

hmm okay

tranquil anchor
#

i did

gritty cloud
#

Use the mavbar variables?

#

Navbar

tranquil anchor
#

oh

tranquil anchor
#

lke this?

gritty cloud
#

add those to your settings

turbid mirage
#

I have a many-to-many relationship between User and Movie. Movie contains the many with a field name user_liked and a related name users_liked. Based on the active_user, I want to return liked if they added the movie else not liked. In the template, I have an if else that I think should work but it is returning False or not liked for every movie. When I load the page within the context I pass all the movies (movies) and the active_user (active_user). Does my if statement look correct? Is there a better way to do this?

opal quest
#

I wanna use sass in django. Anyone know ytb vid or website can help me out thank you

gritty cloud
#

then use {% static %} to get the css

long jackal
#

how do I make the height of this box to the bottom of the page? For some reason if I put width: 100% it will make the box as wide as it can go (which is what I want) but push it's height to way beyond the screen below. All I want is for the width to stay the same and for the height to be as long as the screen minus the title above (not shown in the image but is there if I scroll up).

Code

    <div class="page-content">
        <h1 class="title2">[Game Title]</h1>
        <canvas class="center gameWindow"></canvas>
        <script src=./index.js></script>
    </div>
.gameWindow {
    border: 2px solid black;
    width: 100%;
}

.center {
    text-align: center;
}

.title2 {
    color: white;
    text-align: center;
    margin: 50px 0px;
    font-size: 50px;
}
timid blade
#

Hey i'm actually learning Django did someone could explain me what is utility of views.py

inland oak
#

All the data is used it seems

#

Nothing is loaded which is unused I assume

rancid cedar
#

Hello I am learning web development I any one is interested to learn together then contact me!

kind flicker
#

why am i getting an error here? anyone know cos its working fine in a venv but when i deploy it its fucked up compleately

#

that is the error it is giving me yet i would have 0 clue on how to fix that

inland oak
#

not sure which you have framework

inland oak
#

probably same problems

kind flicker
#

see im not using any css files so that could be why?

inland oak
#

are you deploying from windows to linux?

kind flicker
#

nope

inland oak
#

from linux to linux?

kind flicker
#

not that i know of anyway

inland oak
#

from where to where you deploy

kind flicker
#

im deploying on pythonanywhere

#

from my pc

inland oak
#

what is your OS

kind flicker
#

windows

inland oak
#

lets assume that with 99% chance pythonanywhere has linux servers

kind flicker
#

sure

#

what would the fix include doing

kind flicker
#

yes

inland oak
#

if your image in reality has bg2.jpg, it will work in windows

#

it will not work in linux

kind flicker
#

why?

inland oak
#

because linux has case sensetive file system naming

#

bg2.jpg and bg2.JPG are completely two different files for linux system

kind flicker
#

so i should try both ways?

inland oak
#

it will make your debug a hell way easier

kind flicker
#

hmm

inland oak
#

if you deploy to linux, you should better work from linux

#

it will just make the job easier

kind flicker
#

yeah maybe

inland oak
#

at least it is one of the 12 principles of devops

#

have your development environment as close as possible to production environment

#

the rule number something

kind flicker
#

ill look into it

#

im just trying something atm

#

I fixed it 🙂

#

i just changed it to lowercase and that worked the job

wispy ice
#

Hi, question here

#

Im using python cgi to upload a file

#

Read its bytes and split them

#

Fileitem.filename is correct, but fileitem.file.read() is not correct

#

Any idea?

#

Ping me please if you can answer

wheat jetty
#

@patent glade I just want to say thanks for everything, although I will fail I learn so much from you and I appreciate it but I wasn’t trying to use you. All this was so new for me and I was so stressed out, your a great guy and I wish you all the best with your teaching career 😄

dusk portal
#

uuf

random jolt
#

Is there any other languages that uses the slice notation like python?

dapper tusk
#

apl

#

and julia, and R

oak dome
#

looking for a job now

arctic wedge
#

Anyone have experience with Django template language and styling in css? I want them to look at something I'm having trouble with?

opaque rivet
#

@arctic wedge yes ask the question

arctic wedge
#

@opaque rivet Nevermind I am an idiot and did not close a div. I figured it out. Thanks though for offering to help lol

lunar stream
#

My Flask website loses scrapped data inserted with python after I reloaded. Does anyone knows how to solve this?

raw compass
lunar stream
#

main.py

from lxml import html
import requests

app = Flask(__name__)

#Getting data from url
url="https://ultimatepopculture.fandom.com/wiki/List_of_Nintendo_64_games#B"
resp = requests.get(url)
tree = html.fromstring(resp.content)
gamenames = tree.xpath("/html/body/div[4]/div[3]/div[2]/main/div[3]/div/div/table[2]/tbody/tr/th/i/a/text() | /html/body/div[4]/div[3]/div[2]/main/div[3]/div/div/table[2]/tbody/tr/th/i[0]/text() | /html/body/div[4]/div[3]/div[2]/main/div[3]/div/div/table[2]/tbody/tr/th/i/span/text() | /html/body/div[4]/div[3]/div[2]/main/div[3]/div/div/table[2]/tbody/tr/th/i[1]/text()")
gameGenres = tree.xpath("/html/body/div[4]/div[3]/div[2]/main/div[3]/div/div/table[2]/tbody/tr/td[5]/text()")

zip_object = zip(gamenames, gameGenres)


@app.route("/")
@app.route("/<user>")


def index(user=None):
    return render_template("game.html",user=user, zip_object=zip_object)

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

you're not using anything but local memory

lunar stream
#

So that's the reason?

vestal hound
#

when a process is killed

#

it returns its memory to the OS

#

or, more accurately, the OS reclaims it

lunar stream
#

got it. Next step will be setting the connection with the database I guess.

vestal hound
#

you need to persist your data

#

for a very simple project

#

you can just use a local file

#

next level up would be a local database (sqlite)

#

and for a production setting you probz want a standalone database

#

I favour Postgres

lunar stream
#

Thank you! I'll make a document and get the data for the website from there.

vestal hound
#

yw!

vestal hound
#

you only use CamelCase for classes

lunar stream
#

gotcha.

arctic wedge
#

Is it possible to use boostrap, Django and a custom CSS file in one project? Im having issues linking the custom css

arctic wedge
#

lmao I hate it that the moment I ask a question 1 min later I solve it T_T

lunar stream
#

@vestal hound damn, tried with the local txt and it keeps erasing the page

vestal hound
#

maybe I misunderstood you

lunar stream
#

Sorry, This was my issue before My Flask website loses scrapped data inserted with python after I reloaded. Does anyone knows how to solve this?

#

So, I tried your advice you can just use a local file

vestal hound
#

no

#

as in

#

like

#

from waht I see

#

you scrape once

#

every time you run the server

#

do you not want to do that?

#

what do you expect to happen?

lunar stream
#

I stopped scrapping each time it loads

#

got the data into a txt file

#
from lxml import html
import requests

app = Flask(__name__)

def getDataFromTextLineByLine(textname):
    dataFromText = []
    n = open(textname, "r", encoding='utf-8')
    Lines = n.readlines()
    for line in Lines:
        dataFromText.append(line)
    n.close()
    return dataFromText


gamenames = getDataFromTextLineByLine("gamenames.txt")
gameGenres = getDataFromTextLineByLine("gameGenres.txt")

zip_object = zip(gamenames, gameGenres)

@app.route("/")
@app.route("/<user>")


def index(user=None):
    return render_template("game.html",user=user, zip_object=zip_object)

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

So, the information will be static.

vestal hound
#

scrapping means "throwing away"

#

anyways

#

okay so

lunar stream
#

Anyway, now it's not scrapping

vestal hound
#

it's static

lunar stream
#

yes

vestal hound
#

what's the problem now?

lunar stream
#

But, each time I reload the website it loses all the content I passed through the function def index(user=None): return render_template("game.html",user=user, zip_object=zip_object)

vestal hound
#

ah

#

okay

lunar stream
#

to the html file

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles/index.css') }}">
</head>
<body>
 

{% if user %}
<h1>{{ user }}</h1>
    
{% else %}

<div id='container'>
    <h1>Name/Genre</h1>

    <h1>{% for element1, element2 in zip_object %}</h1>
    <main>
        <p><a href="{{ element1 }}">{{ element1 }} </a><span style="padding-right: 40px;"></span> {{ element2 }}</p>
    </main>
{% endfor %}
</div>
        
{% endif %}
</body>
</html>
vestal hound
#

I get what you mean now

#

nothing to do with your template

#

zip produces an iterator

#

your iterator has been exhausted

#

example

#

!e

a = [1, 2, 3]
b = ['a', 'b', 'c']

z = zip(a, b)

for x in z:
    print(x)

print('first done')

for x in z:
    print(x)

print('second done')
lavish prismBOT
#

@vestal hound :white_check_mark: Your eval job has completed with return code 0.

001 | (1, 'a')
002 | (2, 'b')
003 | (3, 'c')
004 | first done
005 | second done
vestal hound
#

@lunar stream get it?

#

zip objects are one use only

lunar stream
#

Ow

vestal hound
#

you need to convert it into, say, a list

lunar stream
#

I'll try that now

vestal hound
#

also, please remember that it's "scraping" with one "p"

#

🥴

lunar stream
#

Lol

#

@vestal hound Wow. You nailed it.

#

I'm one step further now. Thank you!

vestal hound
#

please remember the snake case thing 🥴

lunar stream
#

ofCourse

vestal hound
#

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGH 😢

manic frost
ionic raft
#

So yes...zooming away from 100% view in the browser will mess with how lines appear... 😄

prisma heart
#

Should my Django site's main page be an app?

#

I mean it's just a template so does it require an app?

sullen pebble
#

can i make a website using python??

wooden ruin
sullen pebble
#

what are the basics?

wooden ruin
#

there's a frontend(client) and a backend(server). for frontend you should know at least html/css/js and for backend you can use python to create a web server

#

!resources

lavish prismBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

sullen pebble
#

hmmm

versed python
burnt zealot
#

so this might seem fucking stupid but i'm trying to read a txt file with python and send that string to a javascript file

versed python
#

Just create a core app and use that

burnt zealot
#

So I have my html page running this: <script src="Python/ReadFile.py"></script> to run the python program which is this: Read = open("Assets/MapCol.txt", "r") which opens the txt file in a new tab in chrome for some reason

raw compass
versed python
burnt zealot
#

could you guide me to where I can learn how to do this?

raw compass
burnt zealot
#

I can learn php

versed python
#

You'll find python easier though

burnt zealot
#

probably

raw compass
burnt zealot
#

How do you execute a python file via html?

raw compass
burnt zealot
#

web framework?

raw compass
burnt zealot
#

I don't get why i'm coding up a wbesite in flask, when what i want to do is get a string from a .txt file and pass that to a javascript file

#

i can't read a .txt with java

raw compass
burnt zealot
#

Yeah, so how would I pass this text to java? Json?

raw compass
#

your browser can prompt the user for a file upload. Is that sufficient?

burnt zealot
#

nah this is an embeded file.

raw compass
#

on your computer or the webserver?

#

the webserver can serve a txt file.

burnt zealot
#

on my computer, in a folder

#

I'm trying to get the contents of the txt file as an array

#

can I put the contents of the txt file in JSON of something and that can send it to java?

raw compass
#

i don't know. What are you using as a webserver?

burnt zealot
#

not really a webserver currently, just running the html file off my computer

raw compass
burnt zealot
#

nah that gives me an error

raw compass
# burnt zealot nah that gives me an error

I believe the explanation of this error is in some of the comments of that link. It would have worked though chrome and then firefox disabled it for security some years ago.

Your never going to production with running a html file off your computer like this. Do yourself a favor and install a small webserver and host the txt file like you would in production via http:// or https:// so that this method would work.

slim beacon
#

Can someone help with the NGINX config for websockets, specifially WSS?

smoky oar
#

guys say that we have a facebook pixel on a website

#

and we send a get request to that website using fetch

#

will facebook deal with it as a user

past cipher
#
class Course(db.Model):
    __tablename__ = 'courses'
    id = db.Column(db.Integer, primary_key=True)
    course_id = db.Column(db.String(255), unique=True)
    start_date = db.Column(db.String(50), nullable=False, default ='08/25/2021')
    course_payment = db.relationship('Payment', backref='course_payment', uselist=False)

class Payment(db.Model):
    __tablename__ = 'payments'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'))
    course_id = db.Column(db.String(255), db.ForeignKey('courses.course_id'), nullable=False)

  def fetch_all_student_payments(self):
        user = User().current_user()
        query = self.query.filter_by(user_id=user.id).all() 
        for i in query:
            print(i.course_id)

Can anyone see why i.course_id returns a string and not an object?

#

I have worked with Sqlalchemy a bunch of times, and I'm not sure what my problem is

#

I should be able to do:

for i in query:
  print(i.course_id.course_name)
pearl trench
#

hello guys i need help

example user wanna create 500 new entry with orm then user need to wait but if user close the browser the process will cancel right? how i can handle this case ? any suggestion ?

versed python
pearl trench
teal tusk
#

i dont know if this is the right channel but i need help with webscraping

jovial cloud
past cipher
#

Thanks @jovial cloud - its been a while since I've use alachemy

ember adder
#

In Django, I already have views that inherit from LoginRequiredMixin, which override the dispatch method. I would like to develop a mixin that check if a member has an active subscription, so it would probably also redefine dispatch.

Should the two mixins live side by side in the inheritance parameters of a class or should my subscription mixin inherit from LoginRequiredMixin?

versed python
ember adder
timid blade
#

Hey, i'm creating a website a with Django and i need to know how did i get the content of an text area content,
I have done this :

versed python
broken oar
#

I'm doing a tutorial on Flask, yay

tight bison
#

Heyy guys, I have a question in mind

So I've been building a python - strapi.js (a kind of headless CMS) integration API for a backend of a website. And I used python requests library to make CRUD requests from the backend to the database system. And this got me wondering, if I could build an entire backend using pure python, what is the advantage of using a framework like Django in this case? Can't I just use python to handle all of the data transactions and stuff like that?

opal quest
#

I got the error that told the rest_framework_simplejwt could not be solved although i've install the restframework pip but didnt working at all, anyone can help me pls

idle marsh
#

looking for free host to host my static website (except github)

wheat solar
#

heroku

dapper tusk
#

cloudflare pages, netlify

#

heroku is overkill for a static site

wheat solar
#

shhhh

#

but yes lmao

idle marsh
#

what about free domain?

dapper tusk
#

if you are a student, you get a free .tech domain, a free .me domain, and a free domain from name.com for a year each

#

using the gh student pack

#

pages will give you a pretty nice subdomain on pages.dev

#

if you can somehow figure out .tk or .gz domains, those are also free

idle marsh
dapper tusk
#

http://www.dot.tk/, but idk how to get it to give an actual domain

covert kernel
versed python
#

I already have github student pro account but dont see any option to get a domain

dapper tusk
#

I never actually did this, since I got .xyz for a dollar for a year

#

so until that expires, I will save those offers

idle marsh
covert kernel
#

And then checkout

covert kernel
#

Done, now check your mail

native tide
#

am i able to build a complex website with many functions with just python, html and css?

dapper tusk
#

yes, though javascript will let you have a more pleasant UX

native tide
#

let's say for example i wanted to build an ecommerce site

eternal blade
native tide
#

alright, so i should learn javascript first to a semi-pro/pro extent as well as html and css

exotic pike
#

if you want a dynamic UI/UX you should use javascript

#

my current stack is django & react.js

eternal blade
native tide
#

alright, thank you for the help

eternal blade
#

But you need to know OOP

native tide
#

i already know it in python and they say that once you learn 1 programming language the others become easier to learn

exotic pike
#

yeah,

dapper tusk
#

you don't need a JS framework

#

it just makes for a better website than pure backend templates

exotic pike
eternal blade
dapper tusk
#

you don't even need dynamic UI

eternal blade
native tide
eternal blade
#

👍

wanton garden
#

Hey, so how can I send a status code 200 after a specific request

#

It's difficult for my to explain sry.

idle marsh
#

What does java script do in website?

idle marsh
tranquil anchor
#

Can anyone tell what are all the ways to host a website??

thorn igloo
ashen crescent
#
import flask

app = flask.Flask(__name__)

@app.route('/')
def default():
    return "online"

if __name__ == '__main__':
    app.run(host="0.0.0.0")
``` for some reason this works on localhost but not on my local ip 192.168.xx.xxx
mystic wyvern
#

Is django equal to or greater than node.js?

thorn igloo
#

i mean python is what you would compare it to

mystic wyvern
#

nodejs language ?

thorn igloo
#

what i mean is nodejs is more comparable to python rather than django

#

django is a web framework that runs on python,

wooden ruin
#

node is a runtime @mystic wyvern that allows u to use javascript outside of a browser

#

hence allowing you to use it in things like servers

#

nodejs has backend frameworks such as express or nest which are comparable to django

idle marsh
ashen crescent
#

I fixed it

idle marsh
#

Hello guys i'm facing this issue

nova sonnet
#

is there a way to pass a count of a queryset into the template without modifying the original queryset?

#

for example I want to pass a count of each object where either one of the attributes are either true or false

covert kernel
nova pewter
#

# Create your models here.


class User(models.Model):
    first_name = models.CharField(max_length=128)
    last_name = models.CharField(max_length=128)
    email = models.EmailField(max_length=254, unique=True)
from appTwo.models import User


class NewUserForm(ModelForm):
    class Meta:
        model = User
        fields = '__all__'
from appTwo.forms import NewUserForm
from django.contrib import messages

# Create your views here.


def index(request):
    return render(request, 'apptwo/index.html')


def users(request):
    form = NewUserForm()

    if request.method == "POST":
        form = NewUserForm(request.POST)

        if form.is_valid():
            form.save(commit=True)
            return index(request)
    else:
        print(form.errors)
        print("invalid")

    return render(request, "appTwo/users.html", {"form": form})
#

why is my form returning "invalid"?

#

thanks

final geode
#

Hello why am i getting this error?\

#

'InMemoryUploadedFile' object has no attribute 'get'

raw compass
ionic raft
# exotic pike my current stack is django & react.js

I'm learning my way through Django for the back-end of the web application I'm building. React is my planned next step for the diagramming part of the 7th app within this web application. I hear really good things about React.

ionic raft
# nova pewter ```from django.db import models # Create your models here. class User(models....

I've used form = UserSignupForm() for my sign up.

From my forms.py file for the app...```py
class UserSignupForm(UserCreationForm):
"""UserSignupForm for the user to create an account."""
email = forms.EmailField()

class Meta:
    model = User
    fields = ['username', 'email', 'password1', 'password2']```

If there is something I'm wondering about it is the use of all for fields. I get why, but why not be specific?

nova pewter
# dusk portal show me the html code
<html>
  <head>
    <meta charset="utf-8" />
    <title>Users</title>
  </head>
  <body>
    <h1>Here are your users:</h1>

    <form method="POST">
      {{form.as_p}} {%csrf_token%} <input type = "submit" type="button"
      value="hit it"
    </form>
  </body>
</html>
ionic raft
# nova pewter ``` <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>User...

Out of habit I'll throw the csrf ahead of the form itself. Doubt that's an issue though.
You are missing a closing >```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Users</title>
</head>
<body>
<h1>Here are your users:</h1>

<form method="POST">
  {% csrf_token %}
  {{form.as_p}}
  <input type = "submit" type="button" value="hit it">
</form>

</body>
</html>```

nova pewter
ionic raft
#

Give it a go with the fixed >

nova pewter
#

fixed

ionic raft
#

Side note, I'm not a fan of fields = '__ all __ ' for a couple of reasons. One of them is security. And the other is clarity

nova pewter
#

thanks for the help

ionic raft
#

Fabulous

ionic raft
#

Good luck.

nova pewter
ionic raft
ionic raft
dusk portal
#

did u fixed that?

nova pewter
#

yep

ionic raft
dusk portal
#

nice

#

what was the prob

nova pewter
#

just a missing ">"

dusk portal
#

ohh lol

nova pewter
dusk portal
#

i too saw

ionic raft
#

Plus a couple of tips around setting up fields and forms

#

Oh, and exclude = [] for fields to explicitly hide are also good for security

nova pewter
#

well i saw it right after posting it, but didn't thought that it will fix the issue

dusk portal
#

btw while working with a form i saw u wrote {{form.as_p}} then csrf tokens , remember after u write method=POST

ionic raft
dusk portal
#

not after form

#

;-;

nova pewter
#

cool

ionic raft
#

App 2/7 done for LanesFlow...processes...

dusk portal
#

nice\

#

are u good at rest framework @ionic raft

ionic raft
# dusk portal are u good at rest framework <@!837562596231872512>

Not done much with it. I've been building queries (CRUD functionality) in views as I've needed and met all my needs. But then I've got a complex DB I've also build up too. About 20+ tables/models. AKA I've managed to get all the CRUD I need through Django alone and not needed to strike out into REST yet

exotic pike
ionic raft
#

So, turns out there's a record of the past 3.5 months of learning Python/Django and building this web app. This brought a smile to my mental head.

dusk portal
ionic raft
#

I've built the entire DB in my web app. The only thing I'm connecting out for is to Stripe for subscription payments.

dusk portal
#

oh

#

what r u doing now rn @ionic raft

ionic raft
#

Just fixed a nasty bug where if I changed the name of a team or organization templates broke. I realized I needed to query by id and fk_id fields rather than names. Glad I caught that now ahead of alpha testing...that would have been nasty out in the field

#

Just about finished app 2/7 though. Onto app 3 tomorrow. Clean up, testing, tweaking...

dusk portal
#

umm if u ask me i have been learning flask from april as it was my 1st framework and was new so learned it till June ig then from 7th of june i just started working on django

#

then then from 3rd of August Django Rest Framework

ionic raft
#

It's the little things...like alternating styles for looped grids per this...

dusk portal
#

hh

ionic raft
#

I'm really liking this design language and layout for this app. Hoping testing validates the UX

dusk portal
ionic raft
#

I got started w Corey and Django. Did first 12 parts of his Django series. Going back to 13 for when I promote to production on Linode...and www.lanesflow.io will be ALIVE!

dusk portal
#

made todo app + todo app with authentication + contact page app + auth system in django then forms in django class based views then 1 ecommerce type of app , then 1 corey's blog app

#

my frontend is like wtf bro

#

it's too bad too too bad

ionic raft
#

Yah...I called the blog "Articles" and did a task list too...

dusk portal
#

have u discovered django channels

dusk portal
#

u learned about that search functionality backend cez it's imp

#

@ionic raft

ionic raft
dusk portal
#

because it's important i mean

#

btw how u learned payment gateway wow i wanted to learn it too

ionic raft
#

Well, still thinking on that...Search isn't as key for my apps...Because there's a hierarchical structure to finding things. However, I think I will circle back to search across the DB at some point.

#

My priority is a UI design that makes it so you don't really have to search

dusk portal
#

very good

ionic raft
#

Oh yes...Stripe...

dusk portal
#

i have some problems related to reset password and payment gateway and some integration

#

u teach me things that u know

#

i'll teach u things

#

that u dont know

#

it's ez cez searching advanced topic on internet and getting answer is like

#

1% chances

ionic raft
#

Reset password...likely easier than stripe...stripe was a bit nasty...not much out there...had to piece it together

dusk portal
#

yes

#

vc?

#

nice

ionic raft
#

Can even send the email over...

dusk portal
#

u coding from how many years

ionic raft
#

from their account...I started with Python Apr 16, 2021...Django in July...here's my git commits...

#

Here's the Stripe gateway with logo...

dusk portal
#

i dont push that much to git

ionic raft
#

I'm actually REALLY good with the user going clearly over to Stripe gateway. I want subscribers to know that Stripe, the experts at managing billing, manage billing and their credit card info. No saving credit cards for me. Outsource ALL that to Stripe

#

I push to git with every major update...will track until I get something working and tested. Then I push.

dusk portal
#

ohh

ionic raft
#

I took 1 week off after having learned for over 2 months...then back to it

dusk portal
#

i make whole proj

#

then push

ionic raft
#

Wow....I couldn't do that. I want a record of the major commits...so i can track back if I need.

dusk portal
#

i iz noob in git

#

lmao

ionic raft
#

I'm noob too...but after I lost a few days of work through some weird stuff I was determined to learn git. So I studied it

dusk portal
#

nice

ionic raft
#

So password reset...

dusk portal
#

ik how to do that

#

but error

ionic raft
#

What's the error

dusk portal
#

wait

#

lemme open that proj

#

yo @ionic raft

ionic raft
dusk portal
ionic raft
#

I followed Corey's password reset method. So not sure I'll be of much help.

dusk portal
#
app_name='users'

urlpatterns = [
    path('',v_views.register,name='register'),
    path('profile/',v_views.profile,name='profile'),
    path('login/',views.LoginView.as_view(template_name='users/login.html'),name='login'),
    path('password-reset/',views.PasswordResetView.as_view(template_name='users/password_reset.html'),name='password_reset'),
    path('password-reset/done/',views.PasswordResetDoneView.as_view(template_name='users/password_reset_done.html'),name='password_reset_done'),
    path('logout/',views.LogoutView.as_view(template_name='users/logout.html'),name='logout'),
    path('password-reset-confirm/<uidb64>/<token>/',views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'),name='password_reset_confirm'),
    path('password-reset-complete/',  views.PasswordResetCompleteView.as_view(template_name='users/password_reset_complete.html'), name='password_reset_complete'),
]```
dusk portal
ionic raft
#

I like the token approach. One gap for me is if they entered a broken email and lose their password they're locked out. But that can be fixed with a Contact ticket and admin\

dusk portal
#

;-;

ionic raft
#

I'd check your template...it looks like a broken url build to me

#

I'm looking at your url pattern syntax...

dusk portal
#

ohk

#
{% extends "app1/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
    <div class="content-section">
        <form method="POST">
            {% csrf_token %}
            <fieldset class="form-group">
                <legend class="border-bottom mb-4">Reset Password</legend>
                {{ form|crispy }}
            </fieldset>
            <div class="form-group">
                <button class="btn btn-outline-info" type="submit">Request Password Reset</button>
            </div>
        </form>
    </div>
{% endblock content %}```
#

this is the password reset (1st step html code)

ionic raft
#

Might have spotted something...

dusk portal
#

oh where

ionic raft
#

Here's what I have py path('password-reset/', auth_views.PasswordResetView.as_view( template_name='users/password_reset.html' ), name='password_reset'),

#

Check auth_views.PasswordResetView...

#

Yours is

    path('password-reset/', views.PasswordResetView.as_view(template_name='users/password_reset.html'), name='password_reset'),```
dusk portal
ionic raft
#

It's a built in lib...you need auth_views I think

dusk portal
#

ohh

ionic raft
#

in url pattern

#

Here's my url.py

urlpatterns = [
urlpatterns = [
    path('signup/', signup, name='signup'),
    path('profile/', profile, name='profile'),
    path('signin/', auth_views.LoginView.as_view(template_name='users/signin.html'), name='signin'),
    path('signout/', auth_views.LogoutView.as_view(template_name='users/signout.html'), name='signout'),
    path('password-reset/',
         auth_views.PasswordResetView.as_view(
             template_name='users/password_reset.html'
         ),
         name='password_reset'),
    path('password-reset/done/',
         auth_views.PasswordResetDoneView.as_view(
             template_name='users/password_reset_done.html'
         ),
         name='password_reset_done'),
    path('password-reset-confirm/<uidb64>/<token>/',
         auth_views.PasswordResetConfirmView.as_view(
             template_name='users/password_reset_confirm.html'
         ),
         name='password_reset_confirm'),
    path('password-reset-complete/',
         auth_views.PasswordResetCompleteView.as_view(
             template_name='users/password_reset_complete.html'
         ),
         name='password_reset_complete'),```
dusk portal
#

ohh

ionic raft
#

And my pword rest has been working great

#

Oh wait...also have

from django.contrib.auth import views as auth_views```
dusk portal
#

hmmm

ionic raft
#

I named as auth_views to clarify naming for views

#

I'd check your html templates though. That kind of error I see when the static url is not built correctly

dusk portal
#

hmm

ionic raft
#

I've got to get to bed....12.50 am here. Good luck though. Ping me tomorrow if you can't find it

dusk portal
#

same error uuf

#

ohk

ionic raft
#

But if it were me, I'd check every {% url 'name-here' %} in my html file

dusk portal
#

gn

ionic raft
#

That error message is basically saying, hey, I can't find that url you're clicking on...

dusk portal
#

yes

ionic raft
#

So it's in a template somewhere...Check the page with the link you clicked...it'll be there I bet

#

Good news, find + '{% url ' will get you all the references and you check each one

#

I'd also go with from django.contrib.auth import views as auth_views and use auth_views as the reference in your url_patterns

dusk portal
#

ill see ur code and follow along

#

ur repo link

ionic raft
#

My code is close to yours...

dusk portal
#

plz

#

ohk

#

i waana see

#

whole proj

#

have u posted in git

ionic raft
#

here's your code refined...

urlpatterns = [
    path('',v_views.register, name='register'),
    path('profile/', v_views.profile, name='profile'),
    path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
    path('password-reset/', auth_views.PasswordResetView.as_view(template_name='users/password_reset.html'), name='password_reset'),
    path('password-reset/done/', auth_views.PasswordResetDoneView.as_view(template_name='users/password_reset_done.html'), name='password_reset_done'),
    path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),
    path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'), name='password_reset_confirm'),
    path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view(template_name='users/password_reset_complete.html'), name='password_reset_complete'),
]
#

My repo is private. The idea is far too valuable to open up

#

LanesFlow is a gold mine

dusk portal
#

ohk

ionic raft
#

I inserted spaces after commas...and renamed views to auth_views

dusk portal
#

hmm

ionic raft
#

But the syntax for your url_patterns is sound. It's in the html template somewhere...almost certain

dusk portal
#

yes

ionic raft
#

Good luck!

dusk portal
#

yes

#

i have to study for school

#

im so much old

#

im 16

native tide
#

i need help, i have django-rest-framework and google Oauth i alrady have fully api for registration with google and django-rest-framework. But i dnk how to get the api for Next.js using Nextauth?

sweet jewel
#

hey guys, i am really new to programming and am trying to make a web app, i am building the application front end in svelte and backend in fast api. i have noticed that svelte needs nodejs to run and fast api requires uvicorn, so my question is that, while deploying my app will my app require both node.js and uvicorn for frontend and backend seperately, in which case wouldn't i be better of using nodejs for backend too in order to reduce the load on backend since i can avoid running uvicorn completely and run backend and frontend both on node.js itself? sorry if this is a noob question, since i am new to the scene i havent got much idea about anything, any help is appreciated.

quick cargo