Anonymous
In views.py
Mirco
How to display a search result in a template with images?
make a search before asking here 😊
Ильяс
I need to display a search result instead of this block https://dpaste.de/kYjT how can i do it?
Anonymous
Can i follow django channel's official docs for implement a chat server to a existing webap or any good tutorial?
Ильяс
Mirco
could you please show an example
https://wsvincent.com/django-search/
Mirco
could you please show an example
and I think u need to study better django workflow
Anonymous
dynamic
yw 😃
Hey! I have attached the warning from the older migration files: /app/store/migrations/0001_initial.py:384: RemovedInDjango20Warning: on_delete will be a required arg for ForeignKey in Django 2.0. Set it to models.CASCADE if you want to maintain the current default behavior. See https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.ForeignKey.on_delete
dynamic
so you just need to set on_delete to your required rule ( CASCADE for example ) because in django 2.x is required for FKs
You mean the model right? There are 2 types of files: 1. The /app/store model itself 2. The /app/store/migration/0001_inital.py file (consider current migration generated file is 0002_xyz.py) I have made the changes to the model, but I'm confused with the fact as to if I have to make changes to the file of type 2.
Mirco
You mean the model right? There are 2 types of files: 1. The /app/store model itself 2. The /app/store/migration/0001_inital.py file (consider current migration generated file is 0002_xyz.py) I have made the changes to the model, but I'm confused with the fact as to if I have to make changes to the file of type 2.
the issue seems to be into django 1.9 on_delete was not required , so no problems with migrations even into 1.11 but 'cause in 2.x it's a required field even 1.11 evaluates on_delete to CASCADE into migrations files but in 1.9 on_delete is not added into them so you see the Django20Warning
Anonymous
Django styles don't loading after deployment django project. I'm using nginx + gunicorn Starting gunicorn: gunicorn -b 127.0.0.1:8009 myproject.wsgi Nginx config server { listen 80; server_name example.com; location /static/ { root /home/sr/bots/route_project/static; expires 30d; } location / { proxy_pass http://127.0.0.1:8009; proxy_set_header Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } Application is working but appears without css How can I solve this?
Anonymous
If I start it without gunicorn all works well
Mirco
you need to share your django settings as well
Anonymous
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) MEDIA_DIR = os.path.join(BASE_DIR, 'media') STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Anonymous
Also logs from nginx 152.3.13.510 - - [11/Jun/2019:15:15:31 +0500] "GET /static/admin/css/responsive.css HTTP/1.1" 403 564 "http://example.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Anonymous
yes
Mirco
yes
and STATIC_URL ?
Anonymous
I don't have this var
Anonymous
all the static files from django-admin btw
Mirco
I don't have this var
you need to set it and use that into nginx config as location
Sagar
Anyone have an example of calling a stored procedure(sp) and inserting data through that sp using drf? I tried searching , i find example only with orm
Mirco
I don't have this var
https://docs.djangoproject.com/en/2.2/howto/static-files/deployment/ follow this
Anonymous
you need to set it and use that into nginx config as location
I set STATIC_URL = '/static/' and location /static in nginx config. But styles still dont loading 😔
Anonymous
Request URL: http://example.com/static/admin/css/responsive.css Request Method: GET Status Code: 403 Forbidden
Anonymous
I have 755 perms to all files in static it have myuser as owner, nginx as group myuser in nginx group
Anonymous
hello i need some help who can help me
Anonymous
how can i send email from admin to user ?
Anonymous
https://docs.djangoproject.com/en/2.2/topics/email/
Anonymous
already tried 🙂
Anonymous
no results
Mirco
nginx logs tell you something interesting ?
Anonymous
Yes, find it in nginx error logs, but cant figure out how to fix 2019/06/11 16:57:26 [error] 19154#0: *163 open() "/home/sr/bots/route_project/static/static/admin/css/responsive.css" failed (13: Permission denied), client: 152.20.11.50, server: example.com, request: "GET /static/admin/css/responsive.css HTTP/1.1", host: "example.com", referrer: "http://example.com/"
Anonymous
which perms I need to change
Anonymous
/static/admin/css content https://pastebin.com/GBWc6WzQ
Anonymous
how to display all registered users views.py def user_list(request): user = [str(user) for user in User.objects.all()] return render(request=request, template_name='webapp/home.html', context={'user': user} ) template {% extends "webapp/header.html" %} {% block content %} <center> <h2> welcome</h2> {% for user in user %} <h4> {{ user }}</h4> {% endfor %} </center> {% endblock %}
Mirco
Ok, sry
We can read better
Anonymous
Find some answers in SO about 403 forbidden in nginx https://stackoverflow.com/questions/6795350/nginx-403-forbidden-for-all-files https://stackoverflow.com/questions/16808813/nginx-serve-static-file-and-got-403-forbidden Trying it
Mirco
Plz help
what's the matter ?
Anonymous
what's the matter ?
I want to display all registered users
Mirco
I want to display all registered users
and which problems are u getting with your current code ?
Anonymous
@pyflare the problem solved when I changed from user nginx to user root in nginx.conf. But I think I mustnt run nginx from root.
Artyom
Devs! Could somebody some help with django-import-export understanding?
Anonymous
In html templates {{ user }} will display current user, but i want all the users for that i tried this {% for user in user %} {{ user }} {% endfor %} But it is giving error, user has nor len()
Anonymous
But html template is not displaying it
Mirco
But html template is not displaying it
change your variable user to users into your view and into the template type for user in users
Anonymous
I need help with saving data in database Django
Eugene
.save()
Anonymous
.save()
Actually I made a model form in Django..it takes a question and my bot replies the answer..I save that answer by importing the model then.. my model.objects.create(answer=answer)
Mirco
Nothing displayed
share your current code
Anonymous
But it is saving the question in one place and answer in another place
Anonymous
Here are the images.. https://drive.google.com/file/d/1pSyk3Jh7ErhGtLCM-PIAvag2aOlaxJr1/view?usp=drivesdk https://drive.google.com/file/d/1v-MVF3eLoMvOPM2kvFc16Ck_Pi1pxZnh/view?usp=drivesdk https://drive.google.com/file/d/17yQ6zQBBQhjBxeCj_NuOGjU4keqnCLBU/view?usp=drivesdk
Bona
Anyone would you help me to fix this problem pls? https://github.com/PyReportJasper/pyreportjasper/issues/50 I have problems to connect jasperrepot to my Django project...
Anonymous
share your current code
views.py from django.shortcuts import get_object_or_404, render, redirect from django.contrib.auth.models import User def user_list(request): users = [str(user) for user in User.objects.all()] return render(request=request, template_name='webapp/home.html', context={'users': users} ) home.html {% extends "webapp/header.html" %} {% block content %} <center> <h2> welcome</h2> {% for user in users %} <h4> {{ user }}</h4> {% endfor %} <p> this website is WIP hosted by shekar neo </p> </center> {% endblock %}
Anonymous
if u log users list into the view , is populated as u expect ?
from django.contrib.auth.models import User users = [str(user) for user in User.objects.all()] for user in users: print(user) neo test one admin test1