R
Sorry i'm a newbie... If you can show me something better i'm glad to learn more 😀
from the view side you should validate that the request being performed is a get and deny it otherways, you could also validate that is an ajax request and regarding the queryset you could just use .first() https://docs.djangoproject.com/en/dev/ref/models/querysets/#first) and I would also validate that the value is not None and return it as json. Additionaly, I may be wrong but I dont see much sense in implementing an ajax view which always gets the same Person proto from db and increments that value (which can just be 0 or 1) by one, but I guess it might have some reason due to your domain logic
Nadir
I will try with .first Thanx. Every Person as a tipologia (0 or 1) but the prot increments by one from the last Person that have the same tipologia, so you can have 2 same prot. I hope i could have explain it
R
I will try with .first Thanx. Every Person as a tipologia (0 or 1) but the prot increments by one from the last Person that have the same tipologia, so you can have 2 same prot. I hope i could have explain it
then .first() is not what you are looking for, but your queryset isn't also 🙈 you could do it with smth like that: Person.objects.filter(tipologia=tipologia).aggregate(Max('prot'))
R
anyways, if I understand it properly, the user can't change his prot number so you could just don't use that ajax view and assign the prot number automatically on the server side when saving the model
Nadir
Yes you understand it right but i don't know how to, surely for my ignorance, get the value from tipologia without POST the entire form and i need that value to know which type of person i have.
R
Yes you understand it right but i don't know how to, surely for my ignorance, get the value from tipologia without POST the entire form and i need that value to know which type of person i have.
just allow the user to submit the form with post and then you assign him his prot number depending his tipologia when validating the form https://docs.djangoproject.com/es/2.1/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other or in the own create view https://ccbv.co.uk/projects/Django/2.0/django.views.generic.edit/CreateView/#form_valid before saving the object
Anonymous
Hi, can you help me: I want filter a foreign key list but I don't have idea for make it. For example: Post has comments, in comments model have post_id If posts can choose a status solved and not solved How I can filter in foreign key list not solved posts for comment on it without see solved posts. My English is bad, sorry
Anonymous
blog with django and bootstrap https://github.com/marcoscoder/blog-django-bootstrap hosted at: http://marcoscoder.pythonanywhere.com/blog/
Combot
Luis López (1) has increased reputation of Marcos (1)
Luis
Hope it helps :)
Anonymous
Hi friends..I am a beginner in software developing I know the basics of python ... and now I will start to learn django... So how can I start??... Any good tutorials for user registration and login and logout using session... 😊.... Thank u
Anonymous
Thank u....
Mukhammad Ali
How to order by manytomany relation?
Mukhammad Ali
Need to order by manytomany count. e.x.
Mukhammad Ali
class Single(models.Model): title = models.CharField() class ToOrder(models.Model): title = models.ManyToManyField(Single)
Mukhammad Ali
ToOrder.objects.all().order_by(title_count>1)
Mukhammad Ali
something like this
R
Need to order by manytomany count. e.x.
you can define the through model of your m2m relation and set the ordering or use smth like this https://github.com/gregmuellegger/django-sortedm2m (have not used this lib though)
Kev
ToOrder.objects.all().order_by(title_count>1)
you can try ToOrder.objects.all().order_by('title_count') for ascending order or ToOrder.objects.all().order_by('-title_count') for descending order
Mukhammad Ali
Found a better option, now checking to None )
Manish
hii
Manish
https://screenshots.firefox.com/TbIS2Q2scvhXw1HB/localhost
Manish
https://screenshots.firefox.com/tA5e78fCWeTdyLHk/localhost
Manish
please someone help me on reset password forms in django2.1
Manish
https://screenshots.firefox.com/tA5e78fCWeTdyLHk/localhost
i dont know why password in not resetting after this step
Rajjix
Show views.py and url.py related
Rajjix
class PostListAPIView(ListAPIView): serializer_class = PostListSerializer renderer_classes = (JSONRenderer, ) def get_queryset(self): return Post.objects.all()
Rajjix
when i request the page in my browser it shows verified json formatted data, but when i fetch it with react which is on another server it's not fetching the data
Rajjix
fetch('http://xx.xxx.xxx.xx/posts')it works fine when i fetch json data from other websites
Mirco
Rajjix
how could i forget
Rajjix
i'll check it now
Mirco
Rajjix
It works with postman
Luis
i dont know why password in not resetting after this step
Are you redirecting user after password change? Please, show views.py and urls.py
Денис
Hey. Can you tell me whether I can use 2.1.2 with django-cms or not?
Mirco
It works with postman
Good, so your endpoint is not broken 😂 Have you tried to use proxy url inside react settings , so you can use the same address for Django and react ?
Денис
I've just been stuck with Django 1.11 not compatible with python 3.7 but that's what I have out of the box on my system, no wish to install multiple 3.x
Manish
Are you redirecting user after password change? Please, show views.py and urls.py
https://del.dog/ilutaxajag.coffeescript this is url.py https://del.dog/atudarasuz.py view.py
Mirco
But i was actually looking to do something like so might as well do it now, Thanks
Add "proxy": "your-django-ip-port" to package.json So when u use fetch u can use just endpoint name without domain etc. fetch ('posts/') In this way every call to react port is proxied to Django one
Mirco
You’re a hero
Nope, just a curious guy 😂
Rajjix
Nope, just a curious guy 😂
Your curiosity saved me a lot of time 😍 works now
Mirco
Good! Happy 4 ya 😀😀
Manish
Please, show password_update.html too
https://del.dog/uregetifay.cs
Manish
Please, show password_update.html too
https://del.dog/eyotihizoy this is form.html
Luis
@iFlare3G can you give us a hand here? I can't find the problem
Mirco
What's the main issue ? No reverse match ?
Luis
Yep
Mirco
For password_confirm ?
Luis
For password_reset_complete
Rajjix
url positioning maybe? 🤔
Rajjix
Longest on top shortest on bottom is how i do it to avoid some conflicts just a wild guess tho
Luis
success_url is given to PasswordResetView.as_view , but does it need something like "complete_url"? or something like this ?
Luis
Or PasswordResetDoneView.as_view the success_url poiting to complete view?
Rajjix
I do use complete uri on success_urls starting with a “/“
Manish
isn't there any other way for authentication form except django.contrib.auth.forms?
Manish
like nodejs have
Mirco
Mmm the main issue is on defining urlpattern
Luis
I think namespace is the problem...
Mirco
Yup, maybe
Luis
app_name='profiles'
Manish
app_name='profiles'
well i can't remove this.
Mirco
Nope , that is used for namespacing your urls
Mirco
So in your template you can do profiles:url-name
Mirco
What url u pass to button that redirects to password complete ?
Manish