Shazeb
how to create a slug automatically?
Shazeb
i dont want a model feild for that
Shazeb
i just want to take the title and convert it into slug
Mahmoud
How to create slug in class based views
Shazeb
i have 15entries in the database and now i want to add unqiue slug to every existing feild.
Shazeb
can someone help me with this? id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) recipe_name = models.CharField(max_length=50) slug = models.SlugField(unique=True)
Избранное
How to write a Model management command so that if you call it in the templates through the cycle, the request to the database does not go again every time in the cycle, but so that it is only once (even if this manager is called 200 times in the cycle)
Избранное
Tejas def get_outlines_count(self): count = self.get_descendants(include_self=True).aggregate(o_count=Count('outlines')) return count
Избранное
Д
Is it possible to implement this without third party packages?
functools comes with lru_cache but apparently it doesn't work with methods. that's why you need methodtools (https://docs.python.org/3/library/functools.html)
Д
if you can get your thing to work using that?
Д
but if you don't want to cache the WHOLE function but avoid the time-costing parts, then you can do something like pre-selecting or pre-fetching things - I'm not sure how well Django caches those between calls though, so you might have to save state, depending on where the Query\Objects live
Избранное
but if you don't want to cache the WHOLE function but avoid the time-costing parts, then you can do something like pre-selecting or pre-fetching things - I'm not sure how well Django caches those between calls though, so you might have to save state, depending on where the Query\Objects live
Surely you did not understand the essence of the question. The question was that the code works absolutely well here. But when I call this method in the template, every time the command is called in the loop, the same answer is returned for each foreach element. I tried using super to make an implementation, if there are some possibilities other than third-party packages, it would be great
Избранное
functools is part of the python standard AFAIK
OK. I will take a look at this implementation
Д
OK. I will take a look at this implementation
I'm assuming you want to avoid calling this a billion times because calling it once is really slow?
Д
not because you don't know how to program
Избранное
Избранное
and now I want to know the finished implementation, rather than how to debug the code
Д
maybe i'm lazy :)
so you don't know how to program and you want me to solve a problem for you that should be already solved?
Д
functools won't solve wrong code. it will make life harder.
Избранное
Д
I wanted to know the solutions in order to better relate to this problem.
okay so are you saying that you want the function to return a DIFFERENT answer on each call?
Д
or that it won't be called more than 1 time or what
Д
++
does the function have parameters...?
Избранное
does the function have parameters...?
you can add an id for the function
Избранное
OMG)))) you solved this problem)
Fan / Ac
👍
haha problem solver :)
Д
haha problem solver :)
I do this for the very sake of "solving real world problems"
Д
when people ask questions, I often solve them when they interest me, without telling the answer ;) no, but 99% of the time I talk people through, and I ask lots of questions
Д
when you do this for fun, you learn what mistakes happen. then you become a machine at solving problems.
Д
I've been doing this for probably 10 years
Д
I even sometimes do people's homework but don't give them the solutions.
Д
random questions? also real questions?
if they teach me something
Doragonsureiyā
Looks like you need an offtopic group, please continue this conversation at @pythonofftopic as it's not related to Python
Sourav
ModuleNotFoundError: no module named 'home' Can anyone help?
Doragonsureiyā
Miqo
Hi i want to connect my rect project to rest api but when i send post request to my api, it displays “403 status code”. I tried Cors, but it didn’t help. How to solve this problem.
Cratos Events
How do I check profanity in Django??
Ohunjon
And build a frontend for your api
Khalil
Hi pleas what is the best hebergement web for application django
Dostow
ModuleNotFoundError: no module named 'home' Can anyone help?
Most likely you haven't add the app in settings or you have the app in a subfolder
Dostow
A third option could be you are not executing the correct environment
Ankit
Can someone help me to launch a coding tutorials website?
Doragonsureiyā
Can someone help me to launch a coding tutorials website?
This is neither a job board nor a bulletin board.
German
i have problem with assertRaise In my code i has except ValueError: raise ValidationError( "qwerty" ) And when i'm writing tests: self.assertRaises(ValidationError, self.serializer.to_internal_value(self.data3)) where data3 is invalid value Why do i have E rest_framework.exceptions.ValidationError: [ErrorDetail(string='qwerty.', code='invalid')]
Д
i have problem with assertRaise In my code i has except ValueError: raise ValidationError( "qwerty" ) And when i'm writing tests: self.assertRaises(ValidationError, self.serializer.to_internal_value(self.data3)) where data3 is invalid value Why do i have E rest_framework.exceptions.ValidationError: [ErrorDetail(string='qwerty.', code='invalid')]
import unittest class TestAssert: def test_raise(self, parameter): if parameter: raise Exception("test") else: return True class MyTestCase(unittest.TestCase): def test_raise(self): A = TestAssert() self.assertRaises(Exception, A.test_raise, True) def test_noraise(self): A = TestAssert() self.assertTrue(A.test_raise(False))
Saadi
Use csrf_exempt in your views.
Saadi
I hope it will solve your issues.
Saadi
Hello every one. I am new to Django. So I have a very basic question that we use on our every project. What is the best way to user registration with email verification by using django class based views. And Login, reset password. I have so much confused because the veriety .
Saadi
🙂 For me it's true.
Д
🙂 For me it's true.
creating users to a system securely, and managing their logins securely is not easy.
Saadi
What is the good way of doing this job
Д
What is the good way of doing this job
people often use JSON Web Tokens (JWT) for authentication and authorization. that means there's a separate server that gives permissions to access the Django systems, but there are lots of things here that require very careful attention.
Д
I don't have any clean answers for this.
Д
I'm still trying to grasp how to do it properly.
Saadi
Yeah! this is going very complicated. I have searched a lot. But mostly I have got very basic solutions .
Д
Yeah! this is going very complicated. I have searched a lot. But mostly I have got very basic solutions .
Django has basic auth built-in; and you can install some extras to get the JWT stuff going too
Д
if you can write the frontend for it, I think yes
Д
you'll have to write the AJAX calls and the whole thing will be written from scratch. there are no templates (or well, the idea is to not have)
Andrej
Hello every one. I am new to Django. So I have a very basic question that we use on our every project. What is the best way to user registration with email verification by using django class based views. And Login, reset password. I have so much confused because the veriety .
You could use the django-allauth plugin which includes all of this. • Login (account_login) • Signup (account_signup) • Logout (account_logout) • Password Management • Password Reset (account_reset_password) • E-mails Management (account_email) • E-mail Verification • Social Connections ... and more...
Andrej
Thanks brother @Andrej1a
You're welcome. There are so many good plugins for Django. This is one of the reasons I like it so much.
Saadi
You're welcome. There are so many good plugins for Django. This is one of the reasons I like it so much.
@Andrej1a bro. Can you provide some more recourses from where I can master django. (Mostly I need class based views and Django ORM resources)