Charly
I am geeting some error while installing requirements in python. Can anyone help me ?
If the issues is bay installing django then ye, if is for general python packages then ask at @python show your errors
Charly
Unable to send media in group
You don't need media to share etxt
cj
Unable to send media in group
why do you want to send media here?
Shivam
why do you want to send media here?
I am geeting some error so i want to share the photo of error
Jame
What is the respective sql equivalent of the 2 django annotation filter below? Assuming 'Book' has Foreign key to 'Publisher' Publisher.objects.annotate(num_books=Count('book',distinct=True)).filter(book_rating_gt=3.0) Publisher.objects.filter(book_rating_gt=3.0).annotate(num_books=Count('book'))
kiran
I want to execute a function everyday to change model value. Is there any way
Jame
test? quiz? exam?
https://docs.djangoproject.com/en/3.1/topics/db/aggregation/ It is from django document...I just curious how would it look like in sql equivalent
Jame
You can take it as quiz if you like the challenge 😁
Ali
When time we should start to use Django version 4.2
Ali
Okay thank you bro
Karthik
can any one tell me how to integrate swagger into my project ?
kiran
Okay let me try..
Ali
can any one tell me how to integrate swagger into my project ?
It can help you https://www.jasonmars.org/2020/04/22/add-swagger-to-django-rest-api-quickly-4-mins-without-hiccups/
kiran
CRONJOBS = [ ('*/2 * * * *', 'main.cron.my_cron_job') ]
kiran
def my_cron_job(): print( "iam running mann")
kiran
will this print data in terminal for evry 2 minutes
Airodragon
I am building a CRM using django, which frontend I should use that will be light and friendly.
I am building a CRM using django, which frontend I should use that will be light and friendly.
It depends on your self You can use any frontend framework you want such as Vue JS or React JS
Raad
I am building a CRM using django, which frontend I should use that will be light and friendly.
https://www.accordbox.com/blog/lightweight-javascript-framework-review-for-django-developers/ Read this article and you will find your answer
Raad
Hello I'm having hard time to translate the choices in my model. I have this one ONLINE = "Online" VISIT = "Direct " RESERVATION_SOURCE_CHOICES = ( (ONLINE, ONLINE), (VISIT, VISIT), ) I'm using it in my code everywhere something like that if res_source == ONLINE: ..... Could you please help me guys ?
Raad
I did this but nothing happened. ONLINE = _("Online") VISIT = _("Direct") RESERVATION_SOURCE_CHOICES = ( (ONLINE, ONLINE), (VISIT, VISIT), )
Ajay Kumar
Hello I'm having hard time to translate the choices in my model. I have this one ONLINE = "Online" VISIT = "Direct " RESERVATION_SOURCE_CHOICES = ( (ONLINE, ONLINE), (VISIT, VISIT), ) I'm using it in my code everywhere something like that if res_source == ONLINE: ..... Could you please help me guys ?
Hello! It looks like you're using Python to define a RESERVATION_SOURCE_CHOICES tuple with two options: ONLINE and VISIT. To clarify, ONLINE and VISIT are string constants that represent the values for the RESERVATION_SOURCE_CHOICES tuple. When you use RESERVATION_SOURCE_CHOICES in your code, you can refer to ONLINE and VISIT to indicate the selected option. For example, in your code, if res_source is equal to ONLINE, then the condition if res_source == ONLINE: will evaluate to True. Similarly, if res_source is equal to VISIT, the condition if res_source == VISIT: will evaluate to True. I hope that helps! Let me know if you have any further questions or concerns.
Raad
https://stackoverflow.com/questions/20233319/django-translate-model-choices u making that?
Thanks man, I missed that. I was using gettext Now some of them got translated and some still not translated . but when i created a new record, the text got translated. Is this because the text already saved in the db?
Raad
in DB save only key. translation saved in files
can I use ugettext_noop to translated the one in db?
Raad
for what purpose?
Because the saved record appearing in English. If i create same record, the text get translated
Raad
in db is not appear at frontend
I'm pulling the data from db and showing it on frontend
Alexey
I'm pulling the data from db and showing it on frontend
yes. and it must automatic convert to locale u need
Alexey
look at serializators. may be u make raw query and dont use translations
Raad
look at serializators. may be u make raw query and dont use translations
I'm not using raw query in my code at all. Anyway, thanks a lot. This a second time that you helped me out
Amnas
I want to upload multiple image in in single post which is the best way to do that did i need to create a separate model like this class Post(models.Model): title = models.CharField(max_length=255) description = models.TextField() created_date = models.DateTimeField(auto_now_add=True) def str(self): return self.title class Image(models.Model): post = models.ForeignKey(Post, on_delete=models.CASCADE) image = models.ImageField(upload_to='images/')
Alexey
how u will separate them? by ID? better make field name and save there filename
Lolilop
django not saving session key at database at production, what should I do to solve this problem? I did everything which mentioned at stackoverflow
EFK$$$
Hello here Can anybody give me some examples of create a using wallet in each user please Eg User=models.Foreigenkey(User) Blanace=models.IntegerFields(default=0) I mean how can I put the models in views whenever new user register any help
Hello here Can anybody give me some examples of create a using wallet in each user please Eg User=models.Foreigenkey(User) Blanace=models.IntegerFields(default=0) I mean how can I put the models in views whenever new user register any help
You can create a wallet object in save method of User model. Something like this: class User(models.Model): ... def save(self, *args, **kwargs): created = self._state.adding super().save(*args, **kwargs) # Create Wallet object for created user here. if created: Wallet.objects.create(user=self)
This code will not try creating a new wallet when updating a user ?
Yes, you right. I forgotten check if user created or not then create a new wallet. Thanks.
Careful
thans for the article. I use signals 😅
thans for the article. I use signals 😅
Actually Django official docs warned about using Signals and I think it's better use models than use signals.
Careful
OK. thanks
Careful
When to Use Django Signals · David Seddon https://seddonym.me/2018/05/04/django-signals/
Juan
Hi, I'm trying to implement limit offset and pagination in api backend, but it's quite difficult for me , Can use of rest_framework limit offset and pagination can be used together?
Juan
This the settings REST_FRAMEWORK = { # "DEFAULT_PAGINATION_CLASS": "nocharges.pagination.MyPagination", # "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination", "PAGE_SIZE": 20, "DEFAULT_PERMISSION_CLASSES": [ "rest_framework_api_key.permissions.HasAPIKey", ], "DEFAULT_AUTHENTICATION_CLASSES": [ "config.authentication.JWTAuthentication", "rest_framework.authentication.SessionAuthentication", ], 'DATETIME_FORMAT': "%Y-%m-%d %H:%M:%S", 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination' }
Juan
and ModelViewSet class NochargeViewSet(ModelViewSet): queryset = Nocharge.objects.all().order_by('-created') serializer_class = NochargeSerializer filter_backends = [DjangoFilterBackend, SearchFilter] filterset_fields = ['domain', 'category_free'] search_fields = ['title', 'overview']
Juan
#need_help
Александр
Hello. Has anyone encountered a problem why images are not displayed on the page in django?
Ali
Your static url can be wrong
Александр
in settings?
Ali
Yes send your setting codes html codes
Александр
added everything as it should, tried everything, any ideas?
Ali
Bro give access your media url and root in your root url
Ali
import this ones from django.conf.url.static import static from django.conf import setting
Ali
Then add this code end of your url patterns ....] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Ali
It will fix the error
Александр
https://linkode.org/#KHLnJPfkHSbqeHWgjzUOb2
vahiden
Hey guys i want create bookly website i learn python css html and django is enough or should learn javascript ?
Aman Deoli
I want help in writing drf serializer for the manytomany field
vahiden
No. Enough~
Thanks lot
cj
Hey guys i want create bookly website i learn python css html and django is enough or should learn javascript ?
you should learn some JS too, not strictly necessary but useful enough to add some fancy features to your front-end
YAVIS
Thanks lot
You're welcome. I wish your success.
Aman Deoli
Where should I share code so that you all can help with it