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)
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
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
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
I mention DRF and IsAuthenticated as an example, i simply need the user to be authenticated as superuser to access the page and that's about it.
Neo
LoginRequired
Neat. That works
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
Prajakta
endif wrong to {% endif %} not {%endif%}}
Corrected..but still not showing
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
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
Neo
I don't see the issue anyway, just make another venv its not complicated ¯\_(ツ)_/¯
Neo
Then what can i do?
Make another venv
Pratap
I am trying but problem not solved
Alex
I am trying but problem not solved
don't have multiple project in single venv
Pratap
For every project require s separate venv
Pratap
It's possible to use 1 venv in multiple projects??
Alex
It's possible to use 1 venv in multiple projects??
yes, but there isn't single valid reason to do so
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
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
Hi! I also started learning django a few days ago. Complete beginner. An hour ago I read it is advised to use different virtual environments for different projects.
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'))
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')
Anonymous
returns the no. of products in database
can you elaborate please i did not get it
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
マクスイム • グセブ
Hi! I also started learning django a few days ago. Complete beginner. An hour ago I read it is advised to use different virtual environments for different projects.
In my opinion, the easy way to use virtual environments in your project is to use an advanced Python package management tool like Poetry One of advantages of using Poetry is that it automatically handles creation of virtual environment for your project :) Here's a nice tutorial on how to use it on RealPython P.S. Depending on Poetry's version, some commands may be different, so please make sure to use ones from the docs
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
https://github.com/RuslanZaremba/find_a_job_in_it/blob/master/app_work/views/my_company.py
@Ruselza two problems encountered, 1. form method isn't defined in the template. 2. Form VacancyCreateform which is created from the model, set published_at as NULL
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)
Amit
Anyone make e-commerce website here??
Arsen
Iike google or yandex translation
ask
U can use custom translation
yeah, but maybe there is a simple way to do it. package for example
Arsen
May be this is solution https://pypi.org/project/translate-po/
Arsen
Like that ?