Abhi
whenever i am making a call to login function i am getting this error, https://dpaste.de/CmA1
Abhi
what might be the problem ?
Anonymous
You're sending string instead of integer
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
why would anyone use dajngo with Apache or nginx ? django use a python server, right?
Essa
why would anyone use dajngo with Apache or nginx ? django use a python server, right?
It’s not meant for production use The django server At least with static files
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
so i will have to switch the server that django use when i deploy the web site 😩. though, i worked with Apache and Drupal for a while 😁
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
is it hard to make CMS like Drupal using Django?
Essa
I don’t know what drupal is But there tones of them already made with Django
Val
so i will have to switch the server that django use when i deploy the web site 😩. though, i worked with Apache and Drupal for a while 😁
I think Drupal is a CMS and Django is not. Django is used to build web applications and drupal is not
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
You don’t have too Some cloud ☁️ providers abstract all this overhead away
they will take care of Apache's configurations, but they will also change my project's Settings too?
Anonymous
Just use a wsgi compliant server on top of it
Anonymous
Guys, anyone working on any django project?
Anonymous
Because I would to join if anyone is working
Muhammed
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
i know that i will use get_context_data
inchidi
where you get the username?
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
from urls.py
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
it's passed as argument
inchidi
its named username? you can retrieve it by self.kwargs['username'] then
inchidi
i know that i will use get_context_data
yes, from get_context_data(self)
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
so it will be like this: class TestView(ListView): model = Post paginate_by = 12 context_object_name = 'posts' def get_context_data(self, **kwargs): user = User.objects.get(username=self.kwargs['username']) context = super(TestView, self).get_context_data(**kwargs) context['posts_num'] = Post.objects.filter(user=user).count() context['followed_num'] = Follow.objects.filter(follower=user).count() context['followers_num'] = Follow.objects.filter(followed=user).count() return context ??
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
you can add the user to context too but lil advice, dont name it user selected_user or something else better
it's a UserProfile view in the end !. why would i change the context variable user to something else? ( There is no other name for it in my mind right now 😅)
π’Ÿπ‘œπ“ƒπ’¬π“Šπ’Ύπ“π‘œπ“‰π‘’
this web site have really good tutorials https://godjango.com/69-the-class-based-view/
Django Bot
>> Links - Django tips wiki - Getting to know the Django ORM | Opensource.com
inchidi
Because I would to join if anyone is working
instead working with django project, wanna make telegram bot wrapper for django with me?
Anonymous
sure
inchidi
noice i'll pm you
Aluma
hey do you know an alternative for only() query on django 1.10?
Aluma
I tried values() and values_list() but it does not work 🙁
inchidi
Aluma
yeah
Aluma
and I get as output [{'field1':'attribute'}]
Aluma
liiterly just the string 'attribute'
inchidi
liiterly just the string 'attribute'
you can just grab the attribute because you know the key (field1) right? why its become a problem?
Aluma
and I want to get a list : ['value1', 'value2'], not a dict
Aluma
I did not understood you
inchidi
I did not understood you
wait this one wrong
Aluma
(the db is salesforce)
inchidi
I did not understood you
you can just do for d in queryset_values: print(d.get('field1')
Aluma
but i can't get the right values with values() look at the picture 🙁 I got the string 'attributes' as value while the keys are ok
Aluma
maybe it's a bug with salesforce?
inchidi
just realize that using values_list better for this case
Aluma
ohhh I got it!! the problem is with salesforce models
Aluma
salesforce models are not saved like a normal django models, so you can't query them like that
Aluma
https://stackoverflow.com/questions/2143438/is-it-possible-to-reference-a-property-using-djangos-queryset-values-list thats the answer
inchidi
nice
Aluma
thank you ❀️
Anonymous
Hi, i'm just beginning to learn django i want to custom my users that register on my web app like give rank to them or amount that pey for it and so on should i write all stuff or i can inherit from django user auth module?
inchidi
its model (database table) that have relationship with User (from django.contrib.auth.models import User)
Anonymous
You can use cache for that
Anonymous
Why did you delete that message?
Anonymous
@ErSoul
David
Oh, sorry, didn't get your answer on time (lag in here). But I thought I didn't ask the question correctly...
Django Bot
>> Blogs - Django Logging, The Right Way
Anonymous
I guess so
David
Ok now I have a more concrete question: Shouldn't HttpResponseRedirect render the template of the passed URL? Note: the view that returns HttpResponseRedirect, renders a different template that the view called by HttpResponseRedirect
Anonymous
And redirect to the stated url
Anonymous
Then it's all upto the view which controls the stated link
David
🤔 the problem is that after the status 302, it gets the requested URL (according to the Firefox and python console) with: "GET /my/url/ HTTP/1.1" 200 4473 But does not render the page on my browser
David
But if I put manually that URL on my browser, it does render like it should.
Anonymous
Hmm
Anonymous
Can you show the network tab of developer tools of your browser after doing all this
David
OK, give me a minute
David
there it is!
Anonymous
I would have liked a bigger picture
Anonymous
With more dara
Anonymous
Nvm
Anonymous
You are making Ajax request I guess
David
You are making Ajax request I guess
Yes I am. I'm using jquery post method.