#web-development
2 messages · Page 178 of 1
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' %}"
no not here
then
just in urls.py
delete what you've done here in views
don't change your views , put just the attribute name in your urls
yeah it is working
okey
try to work with name in both of your apps
can u please explain me how in backend it is working
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
it tells the template to look for something with name=(name of the url)
you added the name at app register ?
yes
i did still same error
i did brother
show your html
when i click on register it working
but the problem is when i open local host it is throwing me error
did you change all your a href ?
i'm using it only for one bro
currenctly working for one register thing
change it for all
actually i'm using template
it's better to work like this
so i got to use {% static %}
yeah i'm using that to render the static files
it works fine
but when i added register it got messed up
!pastebin
look at this one , you will understand
yeah i saw it
so basically , since i'm using rendering 2ndapp stuff from 1st app
i need to use this syntax
yeah
what should i give for empty anchor tag
like <li><a href="#"><i class="fa fa-pinterest" aria-hidden="true"></i></a></li>
yes you can leave this one
first page bro
what is the first page , i mean url and view
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.
this one
it didn't find the template
probably your url
not the correct one
check your url please
How are you creating the movie object?
I assume youre using Django?
Yes
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
You have two urls at the same path
did you work with signals ?
You'll have to call save i think after add
I do not think so. Not sure what signals is.
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
Signals would be a better use case here, yes
Could you send the code directly?
yes to automatically saves changes
Show contents of register/urls.py
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')),
]
I can give you GitHub. Would that be better?
yes
Yeah dm it to me. I gtg now
please answer this one
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?
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.
hacky but you can use heroku since its free tier will take care of cleaning up the files for you.
whats the problem?
why are you trying to access /home? it clearly does not exist
from django.urls import path,include
urlpatterns = [
path('admin/', admin.site.urls),
path("travello",include('travello.urls')),
path("register/",include('register.urls',)),
]```
you forgot at the end / in travello
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
?
this one
@near ocean If you are in you project urls you can have empty path
thank u
🙂
like really....how does it knows what files to delete or should i say how do i program it delete those files
do you have any docs link
it compresses your project source code and anything outside this compressed file gets deleted i think
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
i want to do this only that's why i was thinking of putting the files on remote storage service
how can i do this if you could tell me
it will be truly helpful
i am struck at this for days and ca't find an efficient solution
what do you want me to tell you?
cron jobs are very easy, look up a tutorial
i just want a hosting platformthat lets me do this
i am using the flask framework.
like if i can do this with heroku i will do it rightway or do you know any hosting platform
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
Thank you so much for your help and telling me that it is called cron job.
Cause I have a good experience but can't find a client
Hi! How do I start making a website? Any useful sites I should rely on? 🙂
go to youtube and learn the basics
The way not to do it is to take shortcuts with things like Bootstrap CSS, or some weirdo no-code solution
Learn it, and learn it right
Bootstrap/tailwindcss are life savers tho 
in some cases when you need something fast
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')
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.
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
I think I know the selector on what to do when the text is to big. But idk what you mean with autoscroll edit: Is not a selector but a property, it's overflow: scroll;
deep text conversation
Have you ever noticed on websites when text overflow it start to run from right to left automatically like a gif so the user can read the full text. I am sure I have seen it somewhere.
I don't recall seeing that. Also I'm not frontend pro 😄
Me neither. Trying to figure out the right keyword to Google. Lol
Thanks anyway
@tacit jewel overflow-x: scroll
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
Hi, This just adds a scroll bar which user can use to move around and read the text.
I was referring to no scroll bar and text getting moved automatically like a gif from right to left.
Probably one of your dependencies needs a c library to work. Try to find which dependency is it and then see how to install dependencies in heroku
@tacit jewel ah, thanks for the clarification. I think you refer to a marquee:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee
Although it seems depreciated but it would really helps me find the solution to my problem. Now at least I can Google with the right keyword. Thank you so much.
I would have to use JQuery to only run it when the text is overflowing.
So when you scroll downward it scrolls sideways?
Actually no it’s just supposed to scroll sideways automatically without any scrollbar if the text overflows.
I got my answer actually, I’m supposed to use something like marquee element (since it’s depreciated now).
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.
this channel moves too fast for me
does anyone know how to use these variables in bulma?
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!
_ is it okay to commit everything, or do I need to hide certain things? _
If this is going to be a public repository, I would not commit things like secret keys, etc...
By default, the Django configuration file (settings.py) has a secret key in it unless you are importing this as an environment variable or something like that.
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?
You should move the secret key into another file outside of your project folder or set it as an environment variable and import it from there.
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.
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...
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.
My main concern is not the site getting compromised, I hope I'm making that clear
What is your main concern then?
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
Nothing in your github repo should have any information about your device.
When I deploy my blog itself, that's when I want to make sure no one can see the backend code
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.
Makes sense, I'm just overly cautious about this kinda stuff haha
You send information about your device to websites every time you make an HTTP request.
Yeah there's that too
Have you ever looked at an access log before?
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.
Yeah it's just easy to forget, I mean nothing is really hidden to someone who cares to dig deep enough
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.
User agent strings are only the tip of the iceberg, not really that deep to be honest.
User agent strings can also be spoofed.
which is one reason they're not a great way to identify someone alone.
you have to use sass and declare these variables in your sass file
then import everything you need to build the full css file
these variables define the navbar
rn im importing bulma like this
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.
ya can't do it like that :./
to customize you need the npm package
or if your using Django
sob
Really interesting stuff, thanks man it's all going into my list of things to check out!
i am
oo
and it customizes for you
oh ill check it out
ty ^^
@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).
Whoa nice, that's really cool!
Yeah, that's typically the kind of thing you can see as the admin of a website.
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
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.
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
I get requests that are almost certainly hackers trying to break my website.
Also I'm trying not to use many plugins
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?
cloudflare barely even does hosting
Oh I'm only using cloudfare for caching and security, I've hosted my site on bluehost with WordPress
Is it like wordpress then?
their main service is a cache and a firewall
That's right
they also have static hosting and "not amazon lambda", but few use that
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.
They're just throwing stuff at the wall and hoping something sticks, then?
Other than that, the fewer plugins the better, as those can also be attack surfaces.
True, and they slow you down so much
I'm learning django so I can move away from wordpress and take full control of my site
Yeah, and they're crawling the entire internet, so they're bound to find someone who has 1234 or some stupid shit like that as their password.
~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
Yeah, https is a must.
I use Django on my back end.
cloudflare will generally ban suspicious IPs and block their accesses, but it is not perfect and you should not rely on it
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/
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
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.
Yep,I reckon they'd mostly do it for hijacking hosting room on servers?
I can't claim to know their motivations, but I'd say they're probably trying to get people's credit card numbers or things like that.
That's more likely that getting free hosting.
They're just looking for a quick buck.
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
😅 I don't know about that
I'm pretty sure they're just looking for sensitive information.
Uh so I regularly test my website on places like pagespeed insights, could the unique visitors possibly be those sites?
related to finances
I mean, if they're accessing your website, then they would show up in your logs.
Looking at visitor demographics, I only have visitors from the US, UK and India. A few in Ireland, China, France. That's it.
I find it hard to believe IP addresses are only originating from those places.
I get requests from all over the world.
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?
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.
If your not expecting traffic from there then it’s probably just spam bots. Just follow best practices for server and you should be fine. Also if you have public facing forms you might want to have a honeypot field or captcha to prevent spam submissions.
@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
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.
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?
Anyone have advice on creating a multi user registration form in django?
The official documentation has all you need and some great examples https://docs.djangoproject.com/en/3.2/topics/db/aggregation/
What do you mean by multi user form? Form that contains multiple user objects or form that can be accessed by multiple user??
I am currently developing a Stripe integration feature in Django. I used Stripe API exclusively to process subscription payments, with webhooks to send email. Today I just finished mocking all my API calls to test my payment flow and my views that use the Stripe API. I know exactly the feeling. Congrats!
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?
https://www.youtube.com/watch?v=iFTGQfWX-So pope and kie
First time! Hope you liked the video.
Stay-(The Kid LAROI, Justin Bieber ) - Outer Banks Pope and Kie edition
Give me some shows and songs I should do!
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.
Looks like it's this https://developer.amazon.com/blogs/post/TxOMW3RNF3FYRK/amazon-silk-tips-for-site-owners
Amazon Apps & Services Developer Portal
ok thanks, I will read through this
can someone please help i don't understand why user is not adding to my database
finally i got the solution
@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)```
if we are creating template for each app it's better use {% url ' ' %} or else we can use url/url
what's the error sir
i can't delete my posts
i have a object ft id 8
the code
error : ```py
"detail": "Method \"GET\" not allowed."```
postman look
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
Hello, who could help with docker ? I have this issue
which database are you using
postgresql
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
yes, I made this in django settings: ALLOWED_HOSTS = ['*']
no
postgresql config
as in
/etc/postgresql/config.cfg
(or some similar address)
where I can find postgres config ?
i have it at the path /etc/postgresql/12/main/postgresql.conf
are you in linux?
do you have postgres installed in windows?
yes, ah I need to go to the folder with postres ?
yes
ok, one sec
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
it is... sample, documentation
of the postgresql.conf file
I don't know how it all works in windows, it should be somehow similar I guess
ah I found these files
Q: What happens when using celery itself as the broker instead of rabbitMQ?
https://tekshinobi.com/django-celery-rabbitmq-redis-broker-results-backend/
I think celery will use redis as result-backend and as broker at the same time then
Musings about everything tech, galaxy and how to rule the Universe.
but I am not 100% sure
if this method helps me locally, but you say it's unsafe, how I can fix this problem in production?
and no, I have the same problem 😦
- restricting to specified list of allowed ips, which have your backend application
listen_addresses = '*'
instead of all ips
- 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?
- making sure allowed user has long password
https://blog.miguelgrinberg.com/post/using-celery-with-flask here broker and backend is redis
I copied this
listen_addresses = '*'
this setting will probably have to remain the same though
I mean it sets listening...
I'v already have this in settings
basically we can set only
- listen to localhost only, if you have database and app at the same server
- 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
,si
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!
Well done 👍
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
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.
Yeah. My only comment on Stripe for Django...was their documentation had a Flask example but nothing for Django.
Although PayPal has improved recently I believe
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
jinja2.exceptions.TemplateSyntaxError
hey does somebody know how to use the database models made in django in other scripts that dont really follow the django implementation
There's the peewee package which is kinda similar
ok i will take a look at it
SQLAlchemy is the most popular choice, but yes peewee and few others alternative solutions exist too
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
ok i guess i will try on the standalone mode so i dont have to rewrite my models
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 😉
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()
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
django manage.py commands could be sent from the code directly
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
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
urgh.
but this is still usefull
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...
jeah ig now you got my problem
here is example how i solved it for my discord bot
like i am looking for the right thing before i write smt and realize that that is a bad thing
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
ok that means
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
hmm ok
like i got what you explained but
that was more like how to start the bot right?
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
it is more how to not disrupt discord bot functionality
when you add any sync code to it
or the bot would basically not start itself at all
ok that is a thing that i would not have noticed on my own. so thanks
Ohh
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
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
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
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
redis is a special NoSQL super duper fast database
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
ok is there any downside of doing that
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
ok ... hmm
ok i will do some research and have lunch but thanks for the good starting point 👍
u a welcome
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?
surely. it sounds pretty much possible
Do you know any package that I can use by any chance?
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
is an HTML element which can be used to draw graphics via scripting (usually JavaScript). This can, for instance, be used to draw graphs, combine photos, or create simple (and not so simple) animations. The images on this page show examples of implementations which will be created in this tutorial.
This tutorial describes how to use the eleme...
I’m not very good at front end as well, so that’s why I’m asking
Thanks, I’ll check this out
hi i want develop a web that got checking system,auto email system and login system,what should use
that seems like something django would be good at
what is django?
a python web framework
https://tutorial.djangogirls.org/en/ this is an excellent tutorial for django
👌
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?
This is mostly handled by the browser itself
I don't think there's a way to do it.
But i suggest you look it up
Since I am not sure
hmm okay
Run collecstsatic
i did
oh
these variables
add those to your settings
any thoughts?
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?
I wanna use sass in django. Anyone know ytb vid or website can help me out thank you
you could use the sass compiler to compile css into your static files folder
then use {% static %} to get the css
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;
}
Hey i'm actually learning Django did someone could explain me what is utility of views.py
height: 100vh?
Just one layer of if.
I would say it looks correct
All the data is used it seems
Nothing is loaded which is unused I assume
Hello I am learning web development I any one is interested to learn together then contact me!
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
static files are handled differently with debug on and off in django
not sure which you have framework
im using flask
probably same problems
see im not using any css files so that could be why?
are you deploying from windows to linux?
nope
from linux to linux?
not that i know of anyway
from where to where you deploy
what is your OS
windows
lets assume that with 99% chance pythonanywhere has linux servers
you have bg2.JPG named image
yes
if your image in reality has bg2.jpg, it will work in windows
it will not work in linux
why?
because linux has case sensetive file system naming
bg2.jpg and bg2.JPG are completely two different files for linux system
so i should try both ways?
the best way would be for you installing linux (at least in virtual machine)
and just setting up and trying your project there
it will make your debug a hell way easier
hmm
if you deploy to linux, you should better work from linux
it will just make the job easier
yeah maybe
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
https://12factor.net/
10th rule
A methodology for building modern, scalable, maintainable software-as-a-service apps.
ill look into it
im just trying something atm
I fixed it 🙂
i just changed it to lowercase and that worked the job
http://hughjazz3095.pythonanywhere.com -- nothing impressive but you helped me do the background 👍 :
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
@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 😄
uuf
Is there any other languages that uses the slice notation like python?
looking for a job now
Anyone have experience with Django template language and styling in css? I want them to look at something I'm having trouble with?
@arctic wedge yes ask the question
@opaque rivet Nevermind I am an idiot and did not close a div. I figured it out. Thanks though for offering to help lol
My Flask website loses scrapped data inserted with python after I reloaded. Does anyone knows how to solve this?
Do you mind sharing the code on how you insert it? Any database should persist data after restart so something is not correct.
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()
well
you're not using anything but local memory
So that's the reason?
yes?
when a process is killed
it returns its memory to the OS
or, more accurately, the OS reclaims it
got it. Next step will be setting the connection with the database I guess.
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
Thank you! I'll make a document and get the data for the website from there.
yw!
also this is a p small thing but in general snake_case is idiomatic for Python variables and functions
you only use CamelCase for classes
gotcha.
Is it possible to use boostrap, Django and a custom CSS file in one project? Im having issues linking the custom css
yes i think so
lmao I hate it that the moment I ask a question 1 min later I solve it T_T
@vestal hound damn, tried with the local txt and it keeps erasing the page
explain your problem and what you expect to happen in more detail
maybe I misunderstood you
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
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?
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.
it's scraping
scrapping means "throwing away"
anyways
okay so
Anyway, now it's not scrapping
it's static
yes
what's the problem now?
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)
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>
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')
@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
Ow
you need to convert it into, say, a list
I'll try that now
yw
please remember the snake case thing 🥴
ofCourse
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGH 😢
CalmDown
So yes...zooming away from 100% view in the browser will mess with how lines appear... 😄
Should my Django site's main page be an app?
I mean it's just a template so does it require an app?
can i make a website using python??
yes
what are the basics?
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
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
hmmm
Technically you don't need an app, but its highly recommended
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
Just create a core app and use that
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
Do you have experience with php? We don't do this with python.
What are you trying to do? Browser can not read python
I do not have experiance with php, no
could you guide me to where I can learn how to do this?
Sorry to assume.
Checkout a python webframework like flask.
You will be able to expose a endpoint that will dump the contents of the file via the web.
I can learn php
You'll find python easier though
probably
You can try a flask tutorial. And once you get the basics down you should be able to use https://flask.palletsprojects.com/en/2.0.x/api/?highlight=send_file#flask.send_file
How do you execute a python file via html?
you don't.
You create a endpoint in your web framework of choice and you can expose a python function.
Did you have any luck with the flask tutorial?
web framework?
Like flask or equivalent.
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
You don't have access to a local filesystem with javascript no.
Yeah, so how would I pass this text to java? Json?
your browser can prompt the user for a file upload. Is that sufficient?
nah this is an embeded file.
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?
i don't know. What are you using as a webserver?
not really a webserver currently, just running the html file off my computer
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.
Can someone help with the NGINX config for websockets, specifially WSS?
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
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)
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 ?
thanks man!
i dont know if this is the right channel but i need help with webscraping
course_id is a string. If you wanna get the Course object, you have to use its backref(in this case course_payment). To see your object, type the code
for i in query:
print(i course_payment)
Thanks @jovial cloud - its been a while since I've use alachemy
You're welcome
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?
Hello, @ember adder
Both would work, but I've personally used the inheritance model
Thanks for the input.
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 :
Move the text area inside the form
I'm doing a tutorial on Flask, yay
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?
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
looking for free host to host my static website (except github)
heroku
what about free domain?
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
can you give me link ?
http://www.dot.tk/, but idk how to get it to give an actual domain
freenom
Can you explain how to avail this?
I already have github student pro account but dont see any option to get a domain
https://education.github.com/pack/offers?sort=popularity&tag=Domains you should be to figure it out from here
I never actually did this, since I got .xyz for a dollar for a year
so until that expires, I will save those offers
Done, now check your mail
am i able to build a complex website with many functions with just python, html and css?
yes, though javascript will let you have a more pleasant UX
define complex....
let's say for example i wanted to build an ecommerce site
If you want to make a website with very complex functions you will probably need to use a frontend js framework, like react.js 
Agree on this..
alright, so i should learn javascript first to a semi-pro/pro extent as well as html and css
if you want a dynamic UI/UX you should use javascript
my current stack is django & react.js
I guess intermediate js should be enough
alright, thank you for the help
But you need to know OOP
sweet
i already know it in python and they say that once you learn 1 programming language the others become easier to learn
yeah,
you don't need a JS framework
it just makes for a better website than pure backend templates
can also go with jquery for dynamic UI...
Yeah, when I started learning js I already knew python, stuff were a lot more easier to understand
you don't even need dynamic UI
It's the the difference in syntax, most of the concepts are the same
we're on the same boat my man, i've done python for the past 3 years and got bored. so decided to learn new language. plus it'll be better in the long run for job opportunities
👍
Hey, so how can I send a status code 200 after a specific request
It's difficult for my to explain sry.
What does java script do in website?
Can anyone tell what are all the ways to host a website??
a lot
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
how are you running this app?
Is django equal to or greater than node.js?
nodejs is like python
i mean python is what you would compare it to
nodejs language ?
what?
what i mean is nodejs is more comparable to python rather than django
django is a web framework that runs on python,
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
Hello guys i'm facing this issue
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
Dunno, try registering one again, this had worked for me
# 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
Hello why am i getting this error?\
'InMemoryUploadedFile' object has no attribute 'get'
Is this a form much like https://gist.github.com/yxkelan/3999031
show me the html code
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.
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?
<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>
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>```
yeah i just checked the closing >, also i'll keep that in mind
Give it a go with the fixed >
fixed
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
thanks for the help
Fabulous
noted
Good luck.
thanks, i'll try not to make these trivial mistakes and posting here, hopefully XD
It's all good. I make PLENTY of mistakes...and I learn through them.
bruhh
BRUH
did u fixed that?
yep
Yah. He';s good
just a missing ">"
ohh lol
thanks for replying
i too saw
Plus a couple of tips around setting up fields and forms
Oh, and exclude = [] for fields to explicitly hide are also good for security
well i saw it right after posting it, but didn't thought that it will fix the issue
btw while working with a form i saw u wrote {{form.as_p}} then csrf tokens , remember after u write method=POST
I never cease to be amazed how the most trivial of crap causes bugs
after that line u have to write csrf tokens
not after form
;-;
cool
App 2/7 done for LanesFlow...processes...
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
Define the best..
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.
oh have u worked with drf token authentication
Nope.
I've built the entire DB in my web app. The only thing I'm connecting out for is to Stripe for subscription payments.
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...
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
I spent June learning Flask. I really enjoyed it. My first framework too. Been on Django since July...love it.
How are you finding Django?
It's the little things...like alternating styles for looped grids per this...
hh
I'm really liking this design language and layout for this app. Hoping testing validates the UX
as i was new to docs world so completed https://docs.djangoproject.com/en/3.2/intro/ this docs 10 days then i was gone mad and decided to become good at django , so corey schafer's video , just django playlist , codingforenterpreneur then Dennis Ivy vids
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!
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
Yah...I called the blog "Articles" and did a task list too...
have u discovered django channels
oh
u learned about that search functionality backend cez it's imp
@ionic raft
Not following..."cez its imp"?
because it's important i mean
btw how u learned payment gateway wow i wanted to learn it too
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
can we have a good deal
very good
Oh yes...Stripe...
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
Reset password...likely easier than stripe...stripe was a bit nasty...not much out there...had to piece it together
Can even send the email over...
u coding from how many years
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...
i dont push that much to git
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.
ohh
I took 1 week off after having learned for over 2 months...then back to it
Wow....I couldn't do that. I want a record of the major commits...so i can track back if I need.
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
nice
So password reset...
What's the error
I followed Corey's password reset method. So not sure I'll be of much help.
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'),
]```
ik ik and yes that's the one best method
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\
I'd check your template...it looks like a broken url build to me
I'm looking at your url pattern syntax...
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)
Might have spotted something...
oh where
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'),```
where in name url or view
It's a built in lib...you need auth_views I think
ohh
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'),```
ohh
And my pword rest has been working great
Oh wait...also have
from django.contrib.auth import views as auth_views```
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
hmm
I've got to get to bed....12.50 am here. Good luck though. Ping me tomorrow if you can't find it
But if it were me, I'd check every {% url 'name-here' %} in my html file
gn
That error message is basically saying, hey, I can't find that url you're clicking on...
yes
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
My code is close to yours...
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
ohk
I inserted spaces after commas...and renamed views to auth_views
hmm
But the syntax for your url_patterns is sound. It's in the html template somewhere...almost certain
Good luck!
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?
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.
sure, they'll use a lil more resources, but not to the point where it matters, most big web apps run hundreds of different servers and services, overall it's not gonna affect you much / to a noticeable amount by running the two together as opposed to one large system.