cj
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
cj
cj
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)
Doragonsureiyā
Macurrent
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'),
]
Muflone
Anonymous
Raad
Le Createur
Raad
Le Createur
:)
Hello there I'm looking for a python developer who can consult with me about my doubts. And I'll pay for it👍
Mirco
:)
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
Le Createur
Mirco
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
Shreehari
Shreehari
Mirco
Mirco
even the template does not have any check about authenticated users , so anyone can edit posts
Shreehari
Shreehari
Mirco
yup, but logout and put the url of post_edit view in your browser 😊
Mirco
go to localhost:<your-port>/post/post_edit/ after logging out or post_new
Shreehari
Nmn
Shreehari
Shreehari
Shreehari
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
Shreehari
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
Mirco
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
Mirco
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
Anonymous
Nitesh
Nitesh
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