#web-development
2 messages Β· Page 119 of 1
U will get my point
In his case it's just loading time
But in my case the template is not rendering expectedly
And also loading time as well
So?
Would using CBV, admin, just the framework in general for Django be considered as tools? To develop a project
What
@glacial orchid the most I can do is to provide you the server invite of official django server and a server for django developers
Which hosting should I use for Django?
I have used both pythonanywhere and digital oceans for my django website, pythonanywhere sets up gunicorn and a web server for you automatically, while in digital oceans and even others like Linode, give you a VM where you have to configure everyhting
pythonanywhere is free for basic hosting
thx
DO and linode are paid, btw
I heard GCP is good too
I tried using Heroku for my django + react app and it was a nightmare
Hello, hope you''ll are doing well. Can anyone help me figuring out why my django application is throwing this error.
It is a very simple application, am learning the basics as of now. If anyone can figure out, please do let me know. Thanks in advance!
when you use extends, you need to give the full path to the file from the templates dir
like {% extends "base/base.html" %}
include the folder which the base.html file is in
I did give the full path, still it's giving error.
yes, I edited this after you said. Still throwing error.
is the folder named pages or page?
pages
then in the return render statement, it should be pages instead of page
Thankyou very much.
π
also
if you look at the error message
django tells you where it looked for the template
under template-loader postmortem
Yes, I'll keep that in mind π
so there, it said page/index.html but it should be pages
so that means you prolly made a mistake while rendering the template
Yeah
the error is in the error π
whatever I do, celery still tries to connect default broker url
I useflask_celery
it does not recognize settings object
it's defaulted to amqp://guest:**@127.0.0.1:5672/
Can I get some help with flask and aws? my web is unreachable, but I have added ports 80 :/
did you allow the port from aws dashboard?
yes
ok what about nginx
you mean this?
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, debug=False)
uhm, this can work too, but it's not for production
have you passed url to celery instance? π
app = Celery("backend",
broker=broker_url,
namespace="zoomgif", include=["backend.tasks"])
does django force you to use the ORM to use the doc templating even if you're using a web api for a backend?
it really seems that way
I'm not sure but I think that yes haha
yeah, i've been looking at using fastapi to serve docs instead because of that lol
you don't need to use the orm to use templates
@low blade you just provide context to a view and then the template reads the context
right, but it seems like the context must be a class that inherits from django.db.model
context is just a dictionary
you can have a templateview like
class SomeView(TemplateView):
template_name = 'my_template.html'
def get_context_data(self, *args, **kwargs):
context = super().get_context_date(*args, **kwargs)
context['myvar'] = 'hello world'
return context
then in my_template.html you can use myvar
that being said, if you are not going to use the ORM and the database integration that django provides, maybe using something else is preferable.
oh i was just missreading then
and yeah, i don't think that im liking the amount of magic that seems to happen in django. i pretty much just need something to spit out html docs and make requests to a backend api for certain things
django has a lot of magic
yeah lol i think if django happens to do something that takes a ton of work to do in fastapi, i'll switch back, but fastapi has been pretty straightforward for me thus far
How do you test multiple types of file uploads in a django application?
I am trying to avoid having to create a test file for each and every supported file format
Is anyone here?
not anyone that knows how to do what you're asking, im guessing lol
most people don't just sit on discord too though and wait for questions. just need to be patient
why?\
Because it is 12 different types of supported files
If i had the file content of a valid file then that would be nice
@vestal hound So I guess the only way is to make physical files and carry them around my codebase?
you could store the binary representation as a test fixture
@vestal hound how is that different from a file on disk?
practically, not at all
Ok thanks
I am trying to create an html element based on the number of objects I have in a list(python). Does this have a name or am i thinking about this totally wrong? I am very new to web development.
is anyone here good with nested serializers with the DRF? I'm having an issue with getting the views to display the way i would like
With django is there a way to delete and create from different tables at the same time? Class based views
like a list of five things and you want them all to be in separate <p> tags?
yes
you'd do that with the django template language loop thingy
Thanks. I will look into it.
https://tutorial.djangogirls.org/en/django_templates/
imo one of the best resources for a quick look
Hey I'm building an flask app where each user has their own calendar that others can book or schedule meetings on. Does anyone know of any packages or apis that would allow one calendar per user? And that would provide the apis for a user to manage their own calendar?
If I am writing an API and I have a nested relationship, but I want to be able to have views for both the parent and child, how can I achieve this? Parent has many children, so I want two views. /parent should show the parent's info with many children, and /children should just show the children for the parent that accessed the route (I have implemented this using tokens already)
You can have an api like this:
/parent/{parent_id}
/parent/{parent_id}/children
/child/{child_id}
/parent/{parent_id}/children/{child_id} could also be in there.
the way that my API is setup is such that I don't use the FK in the route, I just use the token to get the current user. So they can only access their own attributes by using a generic route. In the get methods I just fetch the Parent object using the token. Perhaps this is a bad setup?
so there's no
/parent/{parent_id}
its simply
- send request to /parent
- send with token or rejected
- token contains {parent_id}
- parent route queries for the parent with {parent_id}
- returns relevant data
@surreal harness is the Token an Auth Token of some sort?
yep
Wait so how many 'resources' do you have?
well let me just convey with the real objects
I have a User and a User has many SocialNetworkAccounts
so going to /me should be able to get all of the relevant user info, there might be some other stuff like email or whatever, but social network accounts will also show nested
going to /socialnetworkaccounts i want to just show the nested social network accounts
basically, a partial amount of that data
the reason being that I want them to be able to update that information in that view, if I sent a POST request to /socialnetworkaccounts with some new info, it should modify only that nested part and touch nothing else
i don't think the primary key being there or not should affect this part of what i want to achieve
since I can already get the specific user object consistently
just some JSON
I wouldn't really recommend this
and why is that?
you can definitely do it like this though
Are you familiar with the RESTful paradigm?
maybe not thoroughly
In theory one of the drawbacks with your approach is caching. every call to /socialnetworkaccounts is different depeneding on the logged in user so it cant be cached
not a big deal for you use case
yeah not worried about that right now but i understand
Also its kind of confusing. Because in order to get the backend record/model object you want to interact with you have to make a call to 'current_user()'
Probably going to run into difficulty writing tests for this too
right but this prevents some malicious access, no?
for example, if someone is hitting a user object that they shouldn't be hitting, sure it will get rejected
but this prevents that possibiltiy was my thought
I'd recommend going with the restful approach, where you essentially encode everything you want to do in the request. Your requests will be idempotent and very easy to test and debug and also make your life easier if you ever leave and comback to development after some amount of time
i see
I see your argument is around security? But you could simply have ACLs or permissions to handle this instead
ok sure, i mean, i'm a noob so idk
can you link something regards to how we should structure using the RESTful approach?
is it some paradigm for setting up proper api routes?
Ok gotchya
Without understanding the full context of your app, like how much time you want to spend on it, who's going to use it, if its for work/business/fun etc I can't speak to the optimal 'business' approach
lets just say i have 3 days
however technically speaking this is probably a sub optimal approach. Although It's totally ok and even recommended to go with sub optimal approaches to meet business use cases
Basically the "best" approach technically would be to have a RESTful paradigm.
hows it different than mine
You have 2 resources, Users, and SocialNetworkAccounts
yes
Your routes would be this
/User
/User/{user_id}
/User/user_id/SocialNetworkAccount
/User/user_id/SocialNetworkAccount/{social_network_account_id}
/me - alias for /User/{user_id} where user_id == current_user()
We then CRUD (Create, Read, Update, Destroy) each route with the HTTP verbs (POST, GET, PUT/PATCH, DELETE) respectivley
So if you want to add a social network account to user 5,
POST /User/5/SocialNetworkAccount with some JSON data in the body
If you want to remove a social network account 12 from user 5
DELETE /User/5/SocialNetworkAccount/12
If you want a list of all SocialNetworkAccounts on User 5
GET /User/5/SocialNetworkAccounts
You can also have the routes:
/SocialNetworkAccount
/SocialNetworkAccount/{social_network_account_id}
But I think for your use case this isn't needed.
Now you also want to limit what users can CRUD (create, read, update, and destroy) certain records. So you will need to add checks in your routes to verify that the user_id in the route is equal to the current_user(). If not, return a 401
Of course with each request you are also including the token. probably in the header.
Does this make sense?
im digesting this yeah
ok yeah, this makes sense to me
using the viewsets i can just create routes for the specific children and have the linked nested serializer, and then update those individually
in terms of limiting what the users can CRUD there's no generic way to do this right? i just need to have some is_valid method to check the fields that I care about i'm assuming
but yeah I understand thanks
@stuck swift can I ask you about the caching? Are you saying that it is easier to cache results if there are PK routes for the api?
Hey my b made dinner.
np
Sort of yeah. For your app it may not really matter much, but in general if more users had access to more resources then yes. For example
If your app had no Read only restrictions and every user could view every other users list of SocialNetworkAccounts, then the URL
/User/5/SocialNetworkAccount
would always return the exact same thing (unless this list was modified of course)
this means it could easily be cached. However a custom route like /socialnetworkaccounts would always change depending on the logged in user.
true, and if i wanted to prevent every user from being able to see every other user I could still do that by having some object level permissions I guess
the thing I'm running into now is, for example, if I want to update an individual user's socialnetworkacccount, I can arbitrarily edit an object that isn't mine by providing some random Id or whatever, which is really bad
Here's a good article I just pulled up on RESTful api desgin and caching
https://www.fastly.com/blog/optimise-api-cache-improved-performance
ok cool, thanks
Django
unfortunately i don't think I have enough time to change the route levels, so I'm going to have to go with the generic /socialnetworkaccounts route like I was saying before
I can add individual checks on the PATCH method but it seems very...ungeneric
i mean this is baby's first API dev anyway so
for your routes you want to add a check for each UPDATE or CREATE route that looks at the current user and the id in the URL. Basically.
if current_user().id != user_id
throw 401
past your UPDATE route and I'll have a look
Also if you wanted to be l33t you'd create a python decorator to decorate the routes where the url id must match current user id, assuming this is a common thing.
Also another benefit of the RESTful routes are that they follow a "Pattern". software eng is all about "Patterns".
Patterns allow you to abstract things and ultimatley wirte less and less code.
def partial_update(self, request):
if not request.data.get('id'):
return Response({"message": "object id not specified"}, status=status.HTTP_404_BAD_REQUEST)
user = get_user_from_token(request.auth) # helper method
user_social = UserSocialNetworkAccounts.objects.get(id=request.data.get('id'))
serializer = UserSocialNetworkAccountsSerializer(user_social, data=request.data, partial=True)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
that first check is specifically because like you said im not using the id in the route, so I need to check for it inside of the object being passed in to the request, but if I had the PK level routes like you said it wouldn't be necessary
yeah i was thinking about using the permission_classes thing to check for that actually
where do you map the url to this function?
in my urls.py I have something like this
path('sns', UserSocialNetworksViewSet.as_view({'put':'partial_update'}), name='sns')
ok 1 sec, I've never actually used Django
I know that partial updates should be done in patch actually, maybe we will change that
oh yeah...Django has a lot of specifics so it might be a bit hard to understand. not sure
how can i only give a django group access to a page and not to the others.
like only the ppl in the grp blog writers have access to page "New Post"
@surreal harness
so is '/sns' the actual url that maps to te partial_updated function?
yeah, there's a get method too actually
in the view method, check request.user and check their groups. if the group id does not match what you want, redirect them to an error page or something instead of the New Post route
something like
def new_post_view(request):
user = request.user
if user.group_id != BLOGWRITERS_ID:
return redirect("somewhere else")
Try changing it to
path('user/(?P<value>\d+)/socialnetworkaccounts', UserSocialNetworksViewSet.as_view({'put':'partial_update'}), name='sns')
I want to and will in the future, but I think I can't right now
Then add a paramter "value" to the partial update funtion. It might have to be a named param not sure
unfortunately the mobile developers define the API spec and for 1.0 we have to do it as they say
but I get the idea. basically it is better in general to have PK in the routes than to not
hah
you know how time crunches are
Yeah. There are so many reasons why too. They become very apparent with larger apis.
If you have 150 models and dozens of relationships across these models you'd quickly realize doing it the RESTful way is a no brainer
yeah. i might go aggro and just demand that we have object ids in the routes
escpecially when you get into complex permission/ACL usage
it also makes the implementation quite annoying too
class CreatePostView(LoginRequiredMixin, View):
template_name = 'blog/new_post.html'
def get(self, request):
form = BlogPostForm()
user = request.user
if user.group_id != BLOGWRITERS_ID:
return render(request, self.no_permission_template_name)
return render(request, self.template_name, {'form': form})
def post(self, request):
form = BlogPostForm(request.POST)
if not form.is_valid():
messages.error(request, 'Invalid form', extra_tags='dnager')
return render('create_post')
post = form.save(commit=False)
post.user = request.user
post.save()
return redirect('blog_post', post_id=post.id)``` like this?
@covert kernel you can write a custom decorator for that group and add to the view, also check in the template the user group name to show it or not
If they look to increase who can access routes and want to add more models an relationships requiring they conform to REST it totally within scope and reasonable.
@covert kernel you can take a look at this example https://medium.com/@MicroPyramid/custom-decorators-to-check-user-roles-and-permissions-in-django-ece6b8a98d9d
A decorator is a function that takes another function and returns a newer, prettier version of that function.
ACL means permissions on a resource. I think it stands for Access Control List. So basically an ACL defines who can access something.
oh right gotcha
So you could set permissions on who can READ SocialNetworkAccounts via an ACL on the SocialNetworkAccount Model.
@gaunt marlin something like this?
def is_member(user):
return user.groups.filter(name='Member').exists()
I think it's a more generic way of saying "Permissions"
Anyone know the structure for a nested for loop inside a for loop with jinja?
{% for result in results: %}
*other code here*
{% endfor %} {% endfor %}```
prints a lot
cant figure out why
@covert kernel use can use the existed user_passes_test decorator to implement it easier
from django.contrib.auth.decorators import login_required, user_passes_test
user_member_required = user_passes_test(lambda user: user.groups.filter(name ='Member').exists(), login_url='/') # redirect to other path
def member_user_required(view_func):
decorated_view_func = login_required(user_member_required(view_func))
return decorated_view_func
@member_user_required
def index(request):
return render(request, 'index.html')
like so
lemme try
@native tide is results data in i?
@gaunt marlin how can i do that on a class?
class CreatePostView(LoginRequiredMixin, View):
template_name = 'blog/new_post.html'
def get(self, request):
form = BlogPostForm()
user = request.user
return render(request, self.template_name, {'form': form})
def post(self, request):
form = BlogPostForm(request.POST)
if not form.is_valid():
messages.error(request, 'Invalid form', extra_tags='dnager')
return render('create_post')
post = form.save(commit=False)
post.user = request.user
post.save()
return redirect('blog_post', post_id=post.id)
yes
@gaunt marlin i is just the integer between 1-11. I get the output of both results but I get 11 copies of said output
@covert kernel take a look at this https://docs.djangoproject.com/en/3.1/topics/class-based-views/intro/#decorating-the-class
in python a for loop after a for loop is supposed to run output per parent for loop, right? Is that not how it is in jinja?
for n in loop:```
i
n```
@native tide What do you actually want? Your telling the inner for loop to run 11 times? Is this intended?
user_member_required = user_passes_test(lambda user: user.groups.filter(name ='Blog Writers').exists(), login_url='/')
decorators = [login_required, user_member_required]
@method_decorator(decorators)
class CreatePostView(LoginRequiredMixin, View):
template_name = 'blog/new_post.html'
def get(self, request):
...
def post(self, request):
...```
how can i pass th<e user in th<e decorators @gaunt marlin ?
@stuck swift I need to add a number next to each output of results
usually a loop in a loop works
@covert kernel it should get auto get request.user if you applied the decorator to a class, no need to pass anything
@native tide can I see your full code?
Also is it just a number from 1-11?
@covert kernel use custom one like so
@method_decorator(member_user_required, name='dispatch')
class CreatePostView(LoginRequiredMixin, View):
what does " name='dispatch" do?
@covert kernel
you use it if you apply to the whole class instead of method in the class
Or, more succinctly, you can decorate the class instead and pass the name of the method to be decorated as the keyword argument name:
explained in the docs
oh ok! thanks alot, u rock!
@native tide can you take advantage of the builtin enumerate function and remove the outer for loop with the range?
{% for i, result in enumerate(results): %} *other code here* {% endfor %}
@stuck swift thanks for the help, your idea helped me find this, which provided a solution https://stackoverflow.com/questions/20233721/how-do-you-index-on-a-jinja-template
The problem was just that it was repeating the full second loop each time, so like instead of 1 a 2 b 3 c I got 1 abc 2 abc 3 abc, if you know what I mean
I am getting
SMTPAuthenticationError: (534, b'5.7.9 Application-specific password required.
I have two factor authentication set up
Before this
I just enabled less secure app be turned on and was able to send email manually but unable to do so after two factor authentication
My moto is to send email to the user of my app to reset the password
@stuck swift mind if I ask you a question? How can I prevent a POST request with new object creation from containing some id field for an object that already exists?
nvm, think i got it
hey guys wanna ask how can i set in sqlite table minimum lengh?
random question - do async, but CPU-bound Promises in JavaScript block the browser tab? (i don't have any slower devices to try) (for example, if you have say a sudoku solver or other algorithm in an async () => {})
i think it does block
does anyone know how drf serializer work?
def perform_create(self, serializer):
for f in self.request.data.getlist('graphs'):
serializer.save(graphs=f)```
when the server got the posted file, the files are saved correctly in the storage, but in the API it only saved 1 file like this
```"graphs": "http://127.0.0.1:8000/1991-06-20-mw74-minahassa-peninsula-sulawesi-2.miniseed",```
how can i make this "graphs" become list of files?
class BlogPost(models.Model):
title = models.CharField(max_length=64)
content = MarkdownxField(max_length=16384)
created_at = models.DateTimeField(auto_now_add=True)
last_edited = models.DateTimeField(auto_now=True)
user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
``` ok so this is my blogpost of model
and
[
{
"title":"Flask vs Django - Which Is Better?",
"content":"Ei dicta apeirian deterruisset eam, cu offendit invenire pri, cu possim vivendo vix? Nam nihil evertitur ad, ne vim nonumy legendos iracundia. Vix nulla dolorem intellegebat ea? Te per vide paulo dolor, eum ea erant placerat constituam? Dolores accumsan eum at.\r\n\r\nInteresset consequuntur id vix. Eam id decore latine, iusto imperdiet ei qui. In ludus consul reformidans eam. Nec in recusabo posidonium, cu tantas volumus mnesarchum pro. Nam ut docendi evertitur, possim menandri persecuti ne sed, cum saepe ornatus delenit ei?\r\n\r\nIn mel debet aliquam. In his etiam legere, doming nominavi consetetur has ad, decore reprimique ea usu. Eam magna graeci suavitate cu, facete delenit cum ne. Ponderum evertitur tincidunt ei mel, ius ei stet euismod docendi.",
"user_id":"NewUser1"
},
{
"title":"You Won't Believe These Clickbait Titles!",
"content":"Cu justo honestatis mel, pro ei appareat mediocrem suavitate. No his omnis ridens. Ludus ornatus voluptatum mei ut, an mentitum noluisse forensibus cum. Eam affert pertinax consequuntur ei, nisl zril meliore te vis? Ad animal persius concludaturque vix, eu graece audiam mel.\r\n\r\nVitae libris mentitum pri in. Cu rebum veritus sea, ex usu consul dolorum, pro tale maluisset consulatu ut. Quo ad clita persius ancillae. Vel illud blandit at, vel eu hinc graeco, usu doctus praesent ea! Vim rebum deserunt ex.\r\n\r\nIus lorem omittam id, est suavitate definitionem ad! Id vim insolens tacimates, pri at decore causae. Ex duo bonorum repudiandae? Vix no vidit facete impedit. An oportere indoctum eam.",
"user_id":"NewUser1"
}
]``` this is posts.json file, how can i add th<ese posts to it thro the shell?
import json
from blog.models import BlogPost
with open('posts.json') as f:
p = json.load(f)
for post in p:
post = BlogPost(title=post['title'], content=post['content'], user=post['user_id'])
post.save()```
this is what i tried but then
ValueError: Cannot assign "'NewUser1'": "BlogPost.user" must be a "User" instance.
so how can i set it as a user instance?
I am not too familiar with that, but maybe you need user__id, with two underscores?
ok lemme try
TypeError: BlogPost() got an unexpected keyword argument 'user__id'
Yeah, no, sorry, I really donβt know
np, thanks
@covert kernel The user you're trying to input into the ForeignKeyField is not a user instance, it's a string.
Hi, how can I use a property in Min(). I want to use the result of this property @property def fictional_quote_price(self) -> Decimal: return self.quote_price - self.total_score here @property def environmental_impact_project(self): return Applicant.objects.filter(project=self).aggregate(Min('fictional_quote_price')) but i get the following error: Cannot resolve keyword 'fictional_quote_price' into field.
https://forum.djangoproject.com/t/sending-email-to-reset-password-in-a-blog-app/5478
Please visit the django forum and help meπ
Hello there, I am making my first django project (a blog application) and I am almost finished but when I enter my email in password-reset view, it says that email has been sent without throwing any error but my gmail is not receiving any email and not even showing any error so that I can solve that. The app is not showing any error while this...
if it sent and return no error, maybe check your spam folder. Some service like gmail filter emails @glacial orchid
- I created the Django_project folder in my desktop
- Created a virtual environment named 'venv' inside the Django_project folder
So far i have a Django_project folder and inside that i have 2 sub folders,(.vscode, and venv) - i used Django_project>django-admin start project web_app commad and now i have 3 sub folders in the main folder .vscode, venv and web_app
is this the right way?
@worn pier start project will create the django workplace folder, you don't need to create the Django_project folder from the start
@gaunt marlin no bro
I read the doc
What's happening is because it says my email is not registered in the system but I have registered it in settings.py file still not working
Please visit the forum and helpπ
i read in an article that it is good practice to name your virtual env as venv, to make source control easier, or something like that, so inorder to organise multiple environment with same name it is better to put it in a folder right?, im new to this
you tried investigate the options that KenWhitesell
told you?
because you didn't post your custom view code and not telling him if the email you posted in settings.py is related to a system user or not
@snow estuary
What do you mean by system user?
flask or django
What are the pros and cons?
@glacial orchid your users in user table need to have the email that in settings.py
Hello guys i cant get all user input when he sign up from the use table anyone could help! (im using django) Thank you.
User*
Yes
I am one of the user in User model and I have posted my email address in settings.py
no that not what i mean...
do the users data in your users table has email = the one in the settings.py?
user.email = the one in settings
I don't get you
What I did is EMAIL_HOST_USER = my email
And my email is in users email table
Is there something I am missing
Hi, I want to get the value of average_mki_value average_mki_value = Applicant.objects.filter(project=self).aggregate(Avg('mki_value')) print(average_mki_value) when I print I get this {'mki_value__avg': 208875.0} How can I get just the value (208875.0)?
You are saying that email of a ll the users should be posted in settings.py? When u said user.email=the one in settings
Guys how to use google maps with django
He asked for help not for you to come here
π
Hello there, I am making my first django project (a blog application) and I am almost finished but when I enter my email in password-reset view, it says that email has been sent without throwing any error but my gmail is not receiving any email and not even showing any error so that I can solve that. The app is not showing any error while this...
Visit the forum π
https://pypi.org/project/django-google-maps/ I found this though
Not for Gmai I guess
um
If u have read the forum u may understand my problem
I have posted my email in settings.py and I have a user in app with that email but still email is not sent
But no error is thrown
Perhaps
Email is not registered in system
But I dont understand what this mean
Cause I have done EMAIL_HOST_USER = myemail
not like this
u must import os in settings.py first
then EMAIL_HOST_USER = os.environ.get('myemail')
@glacial orchid
Done that too that's just to hide the credentials not necessary for this to work
Can you tell me what is the error you are receiving?
Have you read the forum and the doc I sent?
If no
Then do that first
The documentation is a documentation
Nope I sent specific
Yeah but I'm reading things blindly without knowing why
@glacial orchid https://www.youtube.com/watch?v=-tyBEsHSv7w
In this Python Django Tutorial, we will be learning how we can use email to send a password reset link to a user so that the user can reset their password. Users will be able to fill out a form with their email and have a unique token sent to them, and if their token is verified then they will be able to create a new password. Let's get started....
have a look at this
it worked for me.
you might need to allow less secure apps to access your account.
If an app or site doesnβt meet our security standards, Google might block anyone whoβs trying to sign in to your account from it. Less secure apps can make it easier for hackers to get in to your
If the email address provided does not exist in the system, this view wonβt send an email, but the user wonβt receive any error message either. This prevents information leaking to potential attackers. If you want to provide an error message in this case, you can subclass PasswordResetForm and use the form_class attribute.
When Corey ran server with url Password reset and password reset done
He got an error
I did not
That's where problems began
I did it's working but just in shell
I did
do it without environment variables
That's what's happening to me
Did
Not worked
Just tell me how to register an email in system and what this mean anyway
@covert kernel Can you tell me how its working for you? My problem is with the ports, idk how to get free ports >.<
530, b'5.7.0 Authentication Required.
roc
What
since it does not send you any error, are u sure the account you are sending the message to exists?
Yes
It's my personal email address
Oh, because I deleted m from .com and it said "successfully sent the message"
Anw, can you fix my problem π¦
any library for integrating neo4j to flask
Then nthng is free
I went to sendgrid.com
That's also not free
Even it is , the formalities are too complex
Until July 2019
rip
follow me on instagram
You seem to be passionate about python
roc_tanweer
I will when I get my phone
someone knows how to fetch discord data like guild ids in flask?
Ok for now I'll add u here
Donno flask
@vernal furnace u know about registering email in system
What exactly does this mean
I don't understand
This is why I am not getting any error and it's shown that email is sent like said in doc
idk what that really means
Np
Not yet with css bro sorry
on django, is it normal to have an app named homepage
@sand gate Yeah, what's the issue?
Why didn't u help me ?
U just faded away
Because I can't help with everything
U know django?
If u do
U can help
If no
No issue
you can just ask
no, I mean that you should just post your question
gatekeeping rarely helps anyone
and "know Django" is a pretty subjective question
yeah django is huge
you could be asking about something very specific
template interpolation has nothing to do with async access to the ORM, but both are Django
so what is your question
Mine?
Hello there, I am making my first django project (a blog application) and I am almost finished but when I enter my email in password-reset view, it says that email has been sent without throwing any error but my gmail is not receiving any email and not even showing any error so that I can solve that. The app is not showing any error while this...
@glacial orchid so not many people are going to read a whole forum thread
generally specific, well-defined questions get much quicker answers
just my two cents
Most of it is written here
it's not a thread
What service are you sending email through?
and sorry man I don't know how emails work with django I only know the basics and api stuff
Blog app
What service.
To reset password
What is the email service in your settings.py?
EMAIL_HOST = 'smtp.gmail.com'
You can't use gmail anymore.
I don't know why, I just know they decided not to allow it to be used that way anymore.
I think it happened like 6 months ago.
Maybe more. I went to mailgun when that happened.
Mailgun is free to some small limit. Enough for errors at least.
I think 1000 emails maybe?
Right, because if you go over your free limit, then they charge you.
That's how most of them work now.
It will charge when u cross 5000 emails a month
Well it's not that important
I am just learning now
I'll see this later
Wait
O have yet another probt
Problem
Wanna hear
?
Aight
The problem is.....
I can't work in django without internet
I happened few days ago
Until then django was working fine
Any solution?
The problem is
Loading time takes forever
And template does not render as expected
But with internet
Everything works fine with no problem
Maybe a dependency problem. Are you importing anything in your html or python from the internet?
Guessing bootstrap?
You can usually download those files and host them locally instead to bypass that problem.
https://stackoverflow.com/questions/52304811/how-to-fix-massive-lag-on-django-development-server
This problem
Matter of fact is that it's answer is not even on stack overflow π
Nope
I told u it worked fine
I did nothing and this happened out of nowhere
Believe it or not
I just started my pc and saw this
So when you're offline, it loads differently or it does not load at all?
It takes forever to load
And renders like shit
What about the rendering changes? Is it just your css?
Meaning, does your content render, just without styling?
I dunno
It's just weird render
Wanna be frnd?
I'll share more data on this with u
If you give more details, it will be easier to debug the problem. Try to explain how the render is different.
I am not on my pc atm
That's why I asked u wanna be?
Aight
Just @ me.
{% if....%} but don't use Colin(:) in that code block
ok but its not working
Explain wt u wanna do
if the user choose 1y member ship then it will show 720$ and 6m:360$ and 3m:180$ and 1m:60$
how to do this?
JS
Suppose u coded user_input = input()
So you can do
{% if user_input == 1y %}
720$
{% endif %}
You can't hot-reload your website on an option-selection with Django templating, you can only refresh the page with the price if the user submits a POST request with a form.
Hello bro
U mean making a form for this pricing?
is brython actually used or is that more of a gimmicky-kind of thing?
@glacial orchid He had an <options> tag, so I assume he wants to change a different price on each selection. That's a JS task
Okay
Dunno JS
Sorry to interfere π
Yo
Also this wouldn't work because it's Django... there is no access to the terminal for the user:
Suppose u coded user_input = input()
I thought that would work
I need a lot to learn from you guys
@thin dome You could use this:
<select onchange="JS function here()"> </>
And that JS function can refresh the page with the updated price...
I had posted a problem in my django
Wanna hear?
can i ask for some help with css here too? π
or maybe does anybody know a server for stuff like that?
Yes... but don't ask to ask, just ask the question
Lolπ
it wasn't a joke
Oops
i created a footer
like how can the size of the footer or the height adapt to the amount of lines that are in the footer? you know what i mean?
currently the text just gets cuttet away and i cant scroll down
should i post my css code?
Yeah
!pastebin
It will help
you have overflow:hidden, do you know what that means?
oh well i can guess what it means π
no it was css
i jsut followed a tutorial and then started changig stuff for my purpose
no javascript used in it
what does it have to be?
In your code?
yes
Didn't look like just css
yes its css
okay so if i set overflow on scroll i can scroll now in the footer
is there a way so i can scroll on the page?
but the file is in .html
Well, just remove it? Search up what overflow does to understand what it does
That's because you have a set height...
Anything over the height (130px) will be cutoff if overflow is hidden
what are you talking about π€
css file
Makes no sense to me
not js
What is
Css is just for styling
thats not js
only css and html
the onchange attribute takes a JS function.
yea i will just make it higher than xD
Or just remove it...
what?
Read the code again, onchange takes a JS function. JS can be intertwined with HTML
ok i understund i think
ok thanks sir
When you select a new option within the select, the onchange function will run and do whatever you want it to, such as updating the price... but that functionality is your job
ok sir and too
Intervened?
thx too
There was no need to ping me for that, intertwined. JS and HTML can be in the same file.
Don't be mad
No one is mad herre
Just saying bro
Btw
U didn't answer me
I can't use my django in offline mode now
Is django installed in your env?
Internet is needed to load fast and Template render
Can you send the errors?
Will post here later
K
Not on my pc rn
@hot kraken
https://stackoverflow.com/questions/52304811/how-to-fix-massive-lag-on-django-development-server
are you using virtualenv
Nope
well there's your solution most likely
@glacial orchid have you used any image or request with links?
Create a new template and try loading it. Just a clean hello world template
Oh!!
I did nothing
I was working in windows shell
And my pc got turned off due to electricity prblm
And when I opened my pc and there wasn't internet at that time
I saw that happening
And from then
It's happening whenever there isn't net
And check if it takes long also
That should not cause any problem. But try to reboot your pc
@glacial orchid
Oh
Whats the reault of a clean template?
Didn't try that
Try it. If it works then django is all right. Problems with your template.
And if not then create a new django project and paste the code
In it
Then why is everything alright when internet is available
why discord oauth2 works locally but cannot be handled on heroku?
clicking Authorize sends back to the authorization page
by authorization page I mean the discord's prompt
I dont know about heroku that much but it works perfectly on aws
It should work on that also
I tried aws just a few min ago but it seems very complex and I failed to deploy
Go through the docs.
there is nothing appearing on my logs on heroku I see the requests but it's causing an infinite auth loop
It covers everything.
That's just a vague question, @native tide . Oauth is inherently complex (not really but getting it setup can be).
And every situation you use it in needs to be tested for that one setup.
Unless you have concrete examples, you just need to keep debugging.
it's working locally and I have set up all error handlers
Your user successfully registers locally?
Ok, so you need to make sure you're using a live key for production. That's one difference.
Do you know anything about where it's getting stuck?
Check the discord auth allowed lists if you have enabled
no
I faced same on twitter
Ok well then that makes it hard for us to know. π
Put some stuff in your django to write to your logs/terminal and see what doesn't show up.
Log in with twitter was working locally but not on aws
there are no errors on logs
Is any access or request deny message?
hey,
if i have a html file witht he footer and a navbar and stuff and i want it to be shown on every other page. how could i do that without copy pasting the code on every other page?
Use a {% extends "base.html" %}@silver tinsel
OAUTHLIB_INSECURE_TRANSPORT this was set to true might this be the cause?
but then it gets loadad as an extra window
@silver tinsel You should read up on how extending templates works in Django. The Django docs are pretty clear about how templates work.
I dont think you should turn it off
currently i am just doin a simpl html css website without any backend
But the frontend on Django work a specific way with its templates.
@silver tinsel
Oh, you're not using Django?
@native tide check oauth permissions
yea i've done a tutorial with django and everything worked there. but now i am trying to do a simpl website wihtout any backend just html and css
So is this simple site using Django or not at all?
no its not
if you want to use the same thing on multiple pages, use include.
lookup html includes
@native tide i think i have to give a closer look at ot
okay thanks
Welks.
to what
What link are u talking about
I told u already
I had used django offline many times before
Everyone uses it offline in developing mode
I am afraid
I am not my pc rn
U may go to here
https://stackoverflow.com/questions/52304811/how-to-fix-massive-lag-on-django-development-server
To understand my feelings
ah yea thats what i want but now i have the problem that its not allowed to reference files that are on your system π
is the site on a server or local?
local π
If you have index.html, and you include navbar.html, it should work.
I'm not sure where you are seeing that error.
issue kinda resolved. i was redirecting back to login on error
I can't import one py file into another py file even they are in the same project folder , can anybody help?
from module import x
or
import module
@vivid bough What else do you know? What error is it giving?
No module named error
Check ur spelling
What's your import code look like?
Got any idea about my issue
Don't wish to bother you much
Just stop me whenever u feel like it
if doesn't work create a folder like "modules" in same directory and then from .modules.module import x
@glacial orchid I already answered you and you said you aren't at your PC.
I will try it out. Thank you.
Oh
U using class base view or function base
@plush heart try to see if request.META['HTTP_REFERER'] gets the url of the page sending the request
Or, print request.headers and see if the origin is there.
and if so you can access it
I'm confused why you would want to do this based on the directory path?
I now fixed the infinite authorization loops. But now I'm receiving an error that's not resolved
Yeah me too Demi
@plush heart What's the end goal you want to do? Prevent something, authorize something, or what?
so you have one URL that handles deletions? It sounds like you'd be better off having an API endpoint which you can consume whenever you want to delete a note
You don't direct users to your urls.py paths instead?
When would you need to do that?
You want to show one link or another, based on where they are on the site?
Well then wouldn't each separate page have different links, depending where they are?
So if I'm at /notes/ versus /other_notes/, each of those have their own page, right?
If you're deleting a note, why can't you redirect to the same URL - wherever you are on the site? That's what I don't understand
So why would you not have different links on each page?
Or is it a shared page with some kind of javascript affecting the rendering?
Maybe just get a new group. π
May I ask a q demo?
Demi*
Autocorrect..
How long have u been doing django
I mean I can't understand any of these thing
Feeling depressed so asking
Ohπ
It takes a lot of work to become good at any language/framework, so don't get down on yourself.
π I respect u
Sir
It's been 3 months in python
And less than a month in django
I've been there. I know it's hard at the beginning.
It's hard even now. I still get stuck on bugs for hours or days.
Probably not a discussion for web_dev. π
Np
if you r new to python i dont think django is the best to start with
I got stuck for the whole day on sending email for resetting password but nthng working
Don't worry I have been through hard stuff
I like it that way
That's why I didn't choose flask
Nthng is hard if u have passion
@dense slate
When I am giving my email to reset password
It redirect to password-reset-done view but email is not sent
And matter of fact is that it all happens without creating Password-confirm-view
Any idea?
It shows email is sent but nthng happens
This is the last concept I wish to learn for my blog app
@glacial orchid are you using django?
Yeah
@glacial orchid have you set an email to sent mail from?
Yeah
EMAIL_HOST_USER = myemail
you have to also set password for that account so that you can send it
Did that
@glacial orchid are you using any 3 rd party package?
@silver tinsel Why not start with Django? It has most things included, lots of libraries, plenty of tutorials and docs...
It's a great framework.
Nope
Ah, if you're new to Python... Yea I can see the reason behind that.
yea thats what i meant
I worked with Python about a year before jumping into any Framework.
django is great for sure
but defently not so easy to undersatnd for a total beginner
Don't worry bro
It depends on person if he wish easy or hard way
Well, you also want to set yourself up for success.
And not get constantly discouraged.
@stable kite He's trying to use gmail.
ya i know
Gmail doesn't work like that anymore.
what?
What did u do in about 1 year with just python
i think it works
WEB DEVELOPEMENT WITH FLASK IS WORTHY AND STILL RELEVENT FOR 3 4 YEARS CAN ANYONE PLZ ANSWER i am noob .
I had to move to mailgun with its API because using gmail with SMTP no longer was supported.
If there's a way to use gmail, I sure don't know it anymore.
anyone plz answer
@winged gull Flask is relevant. If that's the question.
it works but you need to modify your account settings.Which is not advisable
Who knows the future? π not me
Mailgun needs credit card cant give
Maybe there are some other free services, I'm not sure.
demi yes i want to build cv with web development projects ??
@winged gull Go for it!
yes bro
Mailgun? No
how can i make my footer stick to the bottom? so if i add a large main part i only see it when i scroll down
Who said anything about mailgun
So
Did you read the link
Yeah k read
I am able to send mail in shell but not in my app
@silver tinsel I think that's more a CSS question than a python question.. but have you looked at tutorials to do that? Are you using bootstrap?
did you setup your smtp settings
@glacial orchid What happened to me, when I was using gmail successfully, is that I stopped getting them. They sent sucessfully, but they would not arrive in my inbox.
gmail still works fine with django
I did
A pro prgrmmer said there should not be any problem with me
But still there is
From when
Maybe 8 months ago or so.
Low security app access?
yep
I did
ok so can you show us your smtp settings in settings.py
Even after enabling two factor authentication
And setting up app password nthng works
ok so can you show us your smtp settings in settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('User_Email')
EMAIL_HOST_PASSWORD = os.environ.get('User_Password')
and whats your view (for sending emails) looking like
It's passwordresetview.as_view()
Default template
I have my own also
Own template
So you've done something like this?
@csrf_protect
def password_reset(request, is_admin_site=False,
template_name='registration/password_reset_form.html',
email_template_name='registration/password_reset_email.html',
subject_template_name='registration/password_reset_subject.txt',
password_reset_form=PasswordResetForm,
token_generator=default_token_generator,
post_reset_redirect=None,
from_email=None,
current_app=None,
extra_context=None,
html_email_template_name=None):
I used class base view
Not this type of view
So no
But I saw am article doing similar thing
an*
I don't blv view has any issue
I think I have somehow not registered my email in the system
And dunno what to do about that according to documentation
Alright
It's 11:31 pm here
See h guys later
Good night
Hello, where can i find a better host for django?
like unlimited db and some 10 GB storage
I use DigitalOcean for my servers. You can get pretty good rates there.
can I get list of all the parameters without knowing the name of them? (flask-restx)
I'm trying to build some kind of proxy app, which will receive the request and then pass all the parameters, headers again to some server
Eyo boys, can someone give me an example of some tasks you had to do for a job interview?
I heard thats common practice to get a task with like an hour to complete
you know how to use a template (html) with quart with data transmission?
learn to google dude π
i see you ask a lot of questions without bothering to google first
hmmm
im trying to do password reset verification
im a bit lost tbh kind of just copy pasta code and trying to read some docs
im getting this weird error
the error is in regards to this portion of my code
def send_reset_email(user):
token = user.get_reset_token()
msg = Message('Password Reset Request',
sender='noreply@example.com',
recipients=[user.email])
msg.body = f'''To reset your password, visit the following link:
{url_for('reset_token', token=token, _external=True)}
If you did not make this request then ignore this email and no changes will be made.
'''
mail.send(msg)```
I'm getting a strange issue in Django:
Exception Value: object of type 'int' has no len()
@swift sky Is that Django?
Yup, when creating an object using a Django admin form.
It seems like the inlines model that I'm adding to another ModelAdmin form isn't working properly. It's inserting it into the form with an id of 0.
Eyo boys, can someone give me an example of some tasks you had to do for a job interview?
@halcyon lion did you Google this?
Yup, when creating an object using a Django admin form.
@lofty portal show model and form
Hey @lofty portal!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
β’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
β’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Hey @lofty portal!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
β’ If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
β’ If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
hi
Can it be detected by other applications that I screen sharing from Discord, for example a system I entered via Google
?
?
Can it be detected by other applications that I screen sharing from Discord, for example a system I entered via Google your thΔ±nk
Okay I screen sharing from discord
my screen google any web can this be detected
@lofty portal .
This is where I asked my question... Am I not in the web-development chatroom?
I thought it was a question about web security and permissions
Nope. It's a Django Admin-site form submit error.
@vestal hound I think I showed my code. Haven't used paste.pythondiscord.com before...
help I am getting error 500 on node side and 400 from my python
def data_getter():
with open('../session-data/session_data.json') as session_data:
data = json.load(session_data)
data[request.form['sessionID']] = {'callSid': request.form['callSid']}
json.dump(data, session_data, indent=4)```
^ where I am receiving the post
'callSid': callSid,
'sessionID': this.sessionId
})
axios.post('https://00000000000.ngrok.io/give_data', send_data, {headers:{"Content-Type": "application/json"}}
).then(res => {
console.log(`statusCode: ${res.status}`)
}).catch(error => {
console.log(error)
})``` where i am sending the post
KeyError: 'callSid'``` error from python
Error: Request failed with status code 500 at createError (/app/node_modules/axios/lib/core/createError.js:16:15) at settle (/app/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (/app/node_modules/axios/lib/adapters/http.js:244:11) at IncomingMessage.emit (events.js:326:22) at endReadableNT (_stream_readable.js:1223:12) at processTicksAndRejections (internal/process/task_queues.js:84:21) { error from node hosted on gcp
hello, would someone be how to enter information into a website. Example: I want to connect to my mailbox using a python program. How do I get the program to enter my username and password? thanks you very much!
you can use selenium for that
Is there any place that I can store value in html except using query string?
the data will be store when generate html, not from the user
I don't know what it's used for at all?
it's used for automates browsers actions
imagine that I want to brute force on my mailbox, I have to use the selenium library to be able to try the password that I tell him to try?
that is to say I do not understand. Do you have an example please?
no, you should use some sort of requests library for that
Selenium is used for 2 things, mainly
- automated browser testing
- scraping websites that use JS
shouldn't beautifullSoup be used for that?
code:
bs4 is for parsing HTML
but how do you get that HTML in the first place?
I do not understand everything. Sorry! Just so I was looking for a bookstore or something that would allow me to have a typing in a web page. I will learn more about selenium thank you very much π
okay so
normally
you use your browser
with the keyboard and mouse.
Selenium is a library that lets you control your browser with code
so you can, for example, tell it to click on a button
one use of this is to navigate a website programmatically
oh it's really cool and powerful
but suddenly we can navigate using buttons or links but if there is a text box how do I fill it if I need it?
same thing
give focus to the box and fill it
how to make tables for accounts in postgresql?
Perhaps this channel could use a pin for how to ask questions. It would be helpful to make sure that people asking questions have at least investigated potential solutions and can show the relevant code so we can help in a meaningful way. Can we create some kind of guide or bot command for that?
<@&267628507062992896>
probably not a good way to do that
instead of pinging admins, try suggesting it in #community-meta
Hello everyone, I have an api I am calling that returns a very large json object. I have it writing to a file that I am attempting to ingest via FileBeat.
Output of the json result however in order to be read by file beat, it will all have to be on 1 line. How can I json.dump the object to export on just row 1?
Using requests to call api
Py3
Oh. . .
Json.dump(response.text.replace('\n',''), output_file)
Encase anyone was curious, tested
# wc -l file.log
Returned 0
We're a large, friendly community focused around the Python programming language. Our community is open to those who wish to learn the language, as well as those looking to help others.
@dense slate um
in tutorial Corey Schafer did the same to format the date but mine is not working
any idea?
I just want to remove the time
see @dense slate
hey guys, am stack somewhere. How can i use django session captured in views.py file to the model, like populate the model field the request.session
Mean u want to fill a form and save that in the database?
Does capture implies that?
The syntax is correct but I think Django templating language respects spaces. Try removing all whitespaces after |
I'll try π
I have made spacesπ
Or u wish to capture the data from the database when u open a form?
Explain urself
not a form, just an input value that i have captured and store it in a session. Now i need to populate the model attribute with that session
im trying to do ajax with django
i dont know why but m getting this error: $.ajax is not a function
you forgot to include jquery to your project
i believe it's trying to find $ class object but fails
thanks ill try it
hello everyone
Greetings everyone i had some questions
how to make some Jumplink in Django?
so i had a HTML page "Index.html"
in that Index HTML have a Navbar
Home,Info,etc
for instance some user click on Info on Navbar and it will show
<h3>Info!</h3>
i've tried using this
<a class="nav-link active" href="{% url 'SomeApps:info'%}#info">Info!</a>
and this is my Info
<a name="info"><h3>Info!</h3> </a>
i've tried this and search it on StackOverflow
https://stackoverflow.com/questions/25940811/how-to-add-anchor-to-django-url-in-template/25942548
and didn't work.
My Django version 3.1.3
Thank you.
Hey Guys,
I've been trying connecting My flask app with Mysql db.
The connection was succesful but when I am accepting an input from user it shows error:
TypeError: an integer is required (got type str)
here's my flask code:-
from flask import Flask, request, render_template, url_for, redirect
from flask_mysqldb import MySQL
import yaml
app = Flask(__name__)
db=yaml.load(open('db.yaml'))
app.config['MYSQL_HOST']=db['mysql_host']
app.config['MYSQL_USER']=db['mysql_user']
app.config['MYSQL_PASSWORD']=db['mysql_password']
app.config['MYSQL_DB']=db['mysql_db']
app.config['MYSQL_PORT']=db['port']
mysql=MySQL(app)
@app.route('/',methods=["POST","GET"])
def login():
if request.method =="POST":
coachDetails=request.form
name=coachDetails['username1']
passw=coachDetails['password1']
cur=mysql.connection.cursor()
cur.execute("INSERT INTO CoachData(cname) values (%s)",(name))
mysql.connection.commit()
cur.close()
return 'success'
else:
return render_template('reg.html')
@app.route('/show')
def user():
return render_template('show.html')
if __name__=='__main__':
app.run(debug=True)
here's my Yaml code:-
mysql_host: '127.0.0.1'
mysql_user: 'root'
mysql_password: 'yash'
mysql_db: 'loginEx'
port: '3306'
here's my MySql table structure:-
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| cname | varchar(20) | YES | | NULL | |
| cpass | int | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
it's actually urgent so I would be really thankful.
can anyone tell is it compulsory to use serializer on every class in models in django rest framework? do ping me if someone knows
watch codewithharry tutoriol as I am not able to understand your code
maybe some issue in fetching data
How do I figure that out?
share an ss after putting some data in database
I will
its not fetching data issue, could you send full traceback of the error?
ah wait
here's the traceback:-https://dpaste.org/OUMv
cur.execute("INSERT INTO CoachData(cname) values (%s)",(name))
| cpass | int | YES | | NULL | |
trying to insert str values into int-typed pass probably
nope
full traceback shows your port should be int
in your yaml change port from
port: '3306'
to
port: 3306
I changed the datatype of the cpass column to varchar
Trust me I tried this and got this error:-
MySQLdb._exceptions.OperationalError MySQLdb._exceptions.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (10061)")
no still getting the typed error
check the port is open for connections
To display all open ports, open DOS command, type netstat and press Enter.
To list all listening ports, use netstat -an |find /i "listening" command.
thats how you do it in cmd
Okay I don't find any connection with 3360 port
Yeah, sorry for the typo
ok what you shuld do now is to launch the mysql right
To start the mysqld server from the command line, you should start a console window (or βDOS windowβ) and enter this command:
shell> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld"
The path to mysqld may vary depending on the install location of MySQL on your system.
Anyone running into something like this:?
I develop a small e-commerce site and when I add the product to the cart I always have this error
my views.py
my models.py
what I don't understand if I go into the django shell it works
@lofty portal Yes I try with the console and it gives me the Category object but in the views.py it shows me the 404 error
Yeah, sorry, I was too quick to respond. That's a generic message just telling you that you shouldn't show the debug in production...
What IDE are you using?
In VScode you can debug your Django app and see the variables when you submit the form. It may show you what the underlying issue is.
@lofty portal no I am using sublim text and the main error is: "No Category matches the given query."
What's the query? Perhaps that's not matching what you expect it to?
@lofty portal I am developing an e-commerce site but when I add a product to the cart I get this error and above I have the images of my code!
No need to get snippy. I'm trying to help, and I can see your code.
i cant migrate my data to heroku , showing this weird error,plz help me
@cunning birch I would highly recommend getting VScode, it's free and you can probably debug the issue using that.
@mental lodge Are you in the correct path when you run that script?
yes
When you type ls it shows up?
Was it uploading before, or is this the first upload?
yes
first upload
Sorry, I'm just asking generic questions hoping it will spark something for you to figure it out.
I don't use heroku, so I'm not quite sure. I usually just run my own ubuntu server with nginx and gunicorn.
have been trying for the past 5 days, got stuck
Are you running through a tutorial or something?
yeah
Maybe try backtracking and going through the steps again to see if you missed something. I do that sometimes and find that there was some little thing I missed.
followed corretly ,but i cant find a lead to move further
cant find a solution with that tutorial
exactly
Have you gone on the remote server to see if the project was uploaded there properly?
you mean host?
Yup
Ok, so the site is running already for you?
You're just trying to migrate an update to the database for a change you made to a model or something?
yeah,i got stuck with that heroku migrate part
You can also look at the logs by typing heroku logs --tail, maybe find something useful there.
no no the entire project is done , only the site hosting part is pending
okay will try this
thanks dude
Sorry I couldn't help more.
not a problem , thanks anyway
This is another tutorial on the whole thing. May be helpful to double check in comparison to the other tutorial:
https://www.geeksforgeeks.org/how-to-deploy-django-application-on-heroku/
thanks a lot dude, will check this too
or this one, this one seems better(or maybe because I like the site design more...):
https://dev-yakuza.posstree.com/en/django/heroku/
will check it
Does deployment Costs bucks?
@cunning birch I think that's saying that the query you are trying to find (probably the item id), doesn't exist in that table.
So if you're looking for a particular UUID, that id doesn't exist in that model.
@glacial orchid Virtual servers cost money, yes.
But you can get basic ones as cheap as $5/month.
Or even free, like on https://www.pythonanywhere.com