Greg
thanks
Ulug'bek | Python Developer
Hi guys. Do you know a resource for making your lessons in Djangoda educational system step-by-step
Prajakta
Hello everyone,
I have problem in my django project..in models i have 'class Books'.i have populated this database with some information..when i try to fetch this info from database to html ..it is not showing..
Below are some code samples
Views.py
Def show(request):
books = Books.objects.all()
return render(request,'app/show.html',{'key1':books})
Show.html
{%if key1%}
{% for i in key1}
{{i.name}}
{{i.auth_name}}
{%endfor%}
{%endif%}}
Model.py
class Books(models.Model):
name= models.CharField(max_length = 50)
auth_name = models.CharField(max_length = 50)
Prajakta
Rishat
Prajakta
Ok but in vscode i have closed tha tag properly..it's not showing any error..just not displaying data from Books table
Drag
Neo
I have a template view here that is intended to be part of the admin interface, how would one go about enforcing permissions similar to IsAuthenticated from DRF on it
Neo
Mirco
Neo
I'm assuming that this does not check if the user is superuser but in the context of my project we will never have an authenticated user that is not a superuser so it should do
Mirco
Mirco
Prajakta
Pratap
Hello guys I want little help
How to I use one environment variable for multiple projects. Is it possible?. If yes then How? Please help me i am beginner. Python version 3.10
CHANDRA SHEKHAR
CHANDRA SHEKHAR
SECRET_KEY IS UNIQUE FOR ONE PROJECT
Pratap
For activate in project
CHANDRA SHEKHAR
And for other variables you can store them in OS
Pratap
Virtual environment
Neo
huh
Neo
I don't understand the problem
CHANDRA SHEKHAR
I guess he is asking whether he can use virtual enviornment for creating multiple projects
Pratap
Yes
CHANDRA SHEKHAR
I guess if the packages requirements are same then in that case i think you could create multiple projects
CHANDRA SHEKHAR
But you shouldn't because it can cause
CHANDRA SHEKHAR
Conflicts between various projects
Neo
You can but i highly advise against it
Pratap
When I am trying to run project it shows python not found
Neo
That kind of ruins the whole point of venv imo
CHANDRA SHEKHAR
Neo
I don't see the issue anyway, just make another venv its not complicated ¯\_(ツ)_/¯
Pratap
Neo
Pratap
I am trying but problem not solved
Pratap
For every project require s separate venv
Alex
Pratap
It's possible to use 1 venv in multiple projects??
Pratap
Thanks for your support
Neo
Can you use the same virtual environment for multiple projects - Yes
Should you use the same virtual environment for multiple projects - No
Why - It defeats the purpose of virtual environments
What can i do - Create a new virtual environment
I tried but problem not solved - What is the problem with the new virtual environment?
Neo
Besides this is already out of the scope of django, move to main python group or ideally the offtopic group please, and thanks.
mxm
Mirco
mxm
Thanks! If anyone is learning Django, feel free to DM. I would love to learn together. I am trying to do my first project, ToDoList App. Very hard to understand online materials as I am not CS student(
karakurt
Hi guys. I'm newbie and I have a little question.
I was iterating sql_queries variable in my template and noticed the same query printed twice.
Did Django really made 2 identical queries or it somehow cached the result of the first query and then used it in the second case? I have a screenshot, but I can't post it here, sorry
Alex
you sure your urls are correct?
zax4r0
from django.urls import path, include
urlpatterns += [
path('api-auth/', include('rest_framework.urls')),
]
🤔 me also new
Anonymous
what does Count class and Value does in query expressions
e.g.Company.objects.annotate(num_products=Count('products'))
Alex
Ruslan
Hello, why i get error everytime?
GET /mycompany/vacancies/create/post?csrfmiddlewaretoken=5rWtoLeANxN7CaNLgEXONt8WU9iUA5vUAIhlIun5sfBiNshhopKrJ3ad02mdm98I&title=qwwq&specialty=1&salary_min=0&salar
y_max=0&skills=wqwq&description=wqwqwq HTTP/1.1" 404 5078
Ruslan
i use CreateView class
Ruslan
success_url = reverse_lazy('index')
Alex
Ruslan
share code
https://github.com/RuslanZaremba/find_a_job_in_it/blob/master/app_work/views/my_company.py
Ruslan
MyCompanyCreateVacancy
Ruslan
Last view
karakurt
Alex
can you elaborate please i did not get it
this operation is simply checking for no. of product in company model, it is helpful in case where the stock of product needed to be displayed to clients or app.... another example will find no. of books written by an author.
The same result can be achieved by using a filter and count() because it limits further operation thus annotate is used to perform.
Alex
Ruslan
ask
hello
how to autotranslate django.po files?
files for translating static parts of pages
Bekzhan
Hello. I wanted to ask how you can use CTE in Django DRF. Can you help?
Anonymous
My model date = models.DateField(auto_now=true)
I want to filter data by current month only
Alex
models.objects.filter( mydatefield__month=today.month)
Anonymous
Amit
Anyone make e-commerce website here??
Alex
Arsen
Arsen
Iike google or yandex translation
Arsen
May be this is solution
https://pypi.org/project/translate-po/
Arsen
Like that ?
ask
Arsen