Master
> I want to assign methods using the the urls on which it was previously working.
What?
Prasanthari
U using same urls for the men n women make separate apps or change path for any of them
Master
But both your views render SAME template
Master
So why bother?
Anonymous
Anonymous
So why bother?
Should i use post request to sent (men or women -- basically category name) to my template ?
Prasanthari
Project
Path(' categories/', include (main.site.urls))
N for app
Path('men/',views.men)
Path('women/',views.women)
Prasanthari
This will generate categories/men
Categories/women
Master
> Should i use post request to sent (men or women -- basically category name) to my template ?
Ok, now we going to something. Use {{category}} in your 'main_site/products.html' and change render(request, 'main_site/products.html') to render(request, 'main_site/products.html', context={"category":"MAN"})
Anonymous
Anonymous
Anonymous
Now my doubt is cleared.. thanks a lot @Hikaon @PrasanThari for your help. :)
Prasanthari
❤️❤️
Мансур Муҳаммадиев
hello my name is Mansur I am from Uzbekistan, there is a question do you know django web socket video chat or github
Ghorz
Actually i am facing a problem-
I am using a common app for my homepage, and categories(men, women etc), but they are not perfectly working like men category has 'women/' and women also has 'women/' . i have checked multiple times that men and women names are properly used or not.
my main project app's urls:
path('', include('main_site.urls')),
path('men/', include('main_site.urls')),
path('women/', include('main_site.urls'))
my main_site app's urls:
path('', views.homePageView, name='home'),
path('', views.men, name='men'),
path('', views.women, name='women')
my main_site app's views:
def homePageView(request):
return render(request, 'main_site/index.html')
def men(request):
return render(request, 'main_site/products.html')
def women(request):
return render(request, 'main_site/products.html')
Why don't you use slug as a parameter imsteyof having different urls and views
Rohan
Can anyone help me with Regex expressesions
Rohan
I want a regex pattern which contains no numbers and contains a-z and A-Z any special character
Prasanthari
Ghorz
Anonymous
The Summer
Guys i have one question
Suppose we are sending queryset
Users=User.objects.all() to index.html
And we are not using users;
index.html is empty
So will it still hit database ?
Prasanthari
Rishikesh
Prasanthari
Rishikesh
Do one thing...store that queryset in any variable named q
Rishikesh
And then print... q.query
Rishikesh
You will see the statement used to hit the database
Rishikesh
If you are talking only about template...then there it won't hit
The Summer
No i just wanna know will it hit or not bc some time i have to use silly logics
The Summer
And what if i print only 1 user ,i have 10k user and check
If xuser==user
Print xuser
Rishikesh
It will hit...dB......that is equivalent to e.g. "select * from users"
Prasanthari
The Summer
not related to html mean
Rishikesh
That checking you can do in template as well....
The Summer
see i send 10k user to template
now in template i will do
For user in users:
If user.id = x:
{{x}}
The Summer
So it will take time for 1 record or 10k record
The Summer
Like retrieving data or something i am not able to explain you properly
Rishikesh
The concept of view is that...you have to do all calculations/database queries in views...defined in views.py.....and use the generated results in template (html file)
Rishikesh
So in this way, even if you are using index.html empty or not... it will hit db
The Summer
Rishikesh
User.objects.all()...is a ORM query... equivalent to Raw SQL query (as a replacement)...😁
Rishikesh
Rishikesh
Rishikesh
Someone who have idea, please help @Horlarwumhe . Why don't you try to host your site for free on Pythonanywhere? It's simple, easy, consise with fully manageable features? I never preferred Heroku...so I can just suggest 😔😊.
Lugano
https://stackoverflow.com/questions/35456932/heroku-app-database-resetting
Ghorz
The Summer
Use DRF
Ty i will read about that
Ghorz
Or heliohost.org
The Summer
Or heliohost.org
Bro is there anything which can help to convert Django website into Php😂😂
Ghorz
Heliohost.org support FQDN on free tier, python anywhere free tier only support subdomain
The Summer
Bc I am working on a college project which is in Django but they dont allow anything else than PHP
Ghorz
Ghorz
The Summer
Lol I can make in PHP but it will take so much time that I made in Django
PHP sucks man
Ghorz
The Summer
BC they taught me PHP in 5th sem not django
The Summer
Can i
The Summer
Ask
Ghorz
The Summer
I am working on Question-answer site
So how can I display images in an order like
User have anwered like in this format
Text......etxt........image ..image .....text...text...text...image
The Summer
Like Quora do
Ghorz
Do you mean many image to one text
Ghorz
Or one image per text
Anonymous
Are you sure, you wouldn't prefer to use python?
The Summer
Anonymous
Ok
professor
onlie?
Maja Baki
Pls I need help