cj
coz my sudo password for postgre is not working
configure PostgreSQL the right way
Macurrent
configure PostgreSQL the right way
I was trying to start postges server to run using the command sudo service postgresql start This command prompted me to enter a password and my correct password was said to be wrong
Macurrent
configure PostgreSQL the right way
Can you configure when the server is not running?
Macurrent
service postgresql start ┌─[amani@parrot]─[~] └──╼ $service postgresql status ● postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor preset: enabled) Active: active (exited) since Mon 2019-05-13 23:58:54 EAT; 4s ago Process: 25265 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 25265 (code=exited, status=0/SUCCESS)
Anonymous
whats wrong with the code
Anonymous
from django.shortcuts import render from django.http import HttpResponse # Create your views here. def home(request): return HttpResponse('<h1>Blog Home<h1>') def about(request): return HttpResponse('<h1>Blog About<h1>')
Anonymous
it give an error like this Page not found (404) Request Method: GET Request URL: http://localhost:8000/blog/about Using the URLconf defined in django_project.urls, Django tried these URL patterns, in this order: admin/ blog [name='blog-home'] blog about/ [name='blog-about'] The current path, blog/about, didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Muflone
show your urls.py
Anonymous
from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('blog', include('blog.urls')), ]
Muflone
your blog.urls
Anonymous
from django.urls import path from . import views urlpatterns = [ path('', views.home, name='blog-home'), path('about/', views.about, name='blog-about'), ]
Raad
don't worry you can refactor.
You right but It might cost extra time 😁
:)
Hello there I'm looking for a python developer who can consult with me about my doubts. And I'll pay for it👍
:)
Sorry I didn't mention
:)
Like i just started django framework and i have some doubts like how to save 2 forms at same time how to query from database
:)
Something like that
Mirco
i can tell you just 1 app. when you will be developing and you see the app is going big then just isolate some models and logic and put them in another app. it is difficult to say (else you are an expert) that my project needs how much app
think about if u can re-use what you are trying to build for examples accounts could be an app because you could re-use it into another project with login/logout/registration etc.
Shreehari
guys i have made a blog with which users can create a post only if they are logged in and also added edit button for those post. But the issue is all the logged in users can edit any post.
Shreehari
can anyone share some bits of code to display edit button only if the author of the post is logged in ?
Shreehari
https://del.dog/iyasaqugig.htm
Mirco
You should share models and views
Shreehari
just a min
Shreehari
https://del.dog/duqixivoha.py
Mirco
can anyone share some bits of code to display edit button only if the author of the post is logged in ?
I don't see any check about login required for any of the views Anyone can see that views and manipulate them
Mirco
all users can view the post , but only logged in users can edit it
and where's the login required in your post_edit view ?
Mirco
even the template does not have any check about authenticated users , so anyone can edit posts
Mirco
yup, but logout and put the url of post_edit view in your browser 😊
Mirco
can is send some screenshots ?
nope, use imgur for sharing pics
Mirco
go to localhost:<your-port>/post/post_edit/ after logging out or post_new
Shreehari
nope, use imgur for sharing pics
https://imgur.com/a/Ee68S0H
Mirco
okay thanks
that's not the point here
Mirco
https://imgur.com/a/Ee68S0H
not post detail post edit and post add urls
Mirco
not post detail post edit and post add urls
you are just showing a button in the template for add a post or edit if the user is authenticated but if u try to open those urls , you can still edit/add even if u are not authenticated
Mirco
yes
so use login_required decorator on top of your post_edit and post_new views
Mirco
after doing that you can restrict the view to logged users
Shreehari
👍thanks a lot
Mirco
👍thanks a lot
the second step is to make a view where author can view just his posts , so you need to filter by author
Mirco
by filtering by author , you show only posts related to one author and so edit the right ones
Shreehari
I ll try it for sure Thanks for the help
Anonymous
i have over half million data in db ... to return a response it took minutes... is there any way to do it in seconds, i have tried caching but in my case its not usefull, dont want to use celery. Any other solutions ?
Anonymous
English only
Andrii
sorry. will fix
Andrii
#remote #job #python #django #parttime Required expert/interviewer in python+django stack to take interview. Interview will be takes from Indian developers mostly. In English. Interview should be with your question list and marks put in data-sheet on required topics for front+back. Then there should be given common feedback for the candidate. There are could be 2-4 interview per day but not much in total. Daily scheduling defined by you. rate from $25+/h
Anonymous
select_related if your query contains foreign keys or prefetch_related if m2m And cache data
thanks, i tried it but i need to process it which takes additional time... is there any technics where i can fetch aswell process data and and cache it, so that when actual request arrives i can simply return cached data ??
Anonymous
i mean any way to schedule any method on certain intervals within django context ?
Manish
Hey
Manish
Someone help me with django image field.
Manish
I want to assign an image to my image field which already exist on my server at /media/image/something.png
Nitesh
guys i have made a blog with which users can create a post only if they are logged in and also added edit button for those post. But the issue is all the logged in users can edit any post.
Inside your edit button in HTML file you can use {% if post.author == request user %} <button>Edit<\button> {% endif %}
Mirco
Nitesh
Yes, I answered wrong, sorry There should be a correction in updateview class.
Nitesh
form_valid and test_func are there within Update CBV
Yep
How can i install docutils in specific folder? Pip install docutils says requiements satisfied...but i have to install it in a template folder
Yep
New to django...and /admin/doc says that the index.html cant be found