Maxim
What it means: user = request.user, so I have not imported request, neither user. How django find my users?
maybe it should be self.user = request.user or the user variable is used next
Anonymous
With Serializer serializer = TweetSerializer(data=request.POST or None) but what if user is not authenticated? In django view, I said, redirect it to login page. How serializer will handle this?
♈
How to use store procedure in django ?
∆
In the templates folder , I had a html file , at first I have given body color as blue then after running server it worked fine Then I have changed the color, but when I refresh the page , body color hasn't changed from blue
Anonymous
Hard refresh
∆
Means?
∆
Even though I have runned server agn , no changes seen
max 17
class Collection(models.Model): title = models.CharField(max_length=255) class Product(models.Model): title = models.CharField(max_length=255) collection = models.ForeignKey(Collection, on_delete=models.PROTECT) how can I filter collections that dont have any products?
.
Hi guys i hope you are all good. Am working on a kanban board app with Django as backend and Vue.js. as frontend. I have 2 models: Status and Items. Items contains status as a foreignkey from Status model. api/models.py:Status class ... status ... Items class ... contains status - foreignkey of Status ... And am using class based views in my api/views.py I have created the api with django rest framework. And the vue app is a seperate app. My problem is I want to display items created in my app in a column whereby the column name is the Status.name and under every column I want to display all Items.name(items represents tasks that user creates) that contain the status(Item.status) that equals the Status.name of that column in my vue app. basic kanban board columns. Anyone have any idea of what logic I need to implement to achieve this. Any help is appreciated.
max 17
Collection.object.annotate(prod=Count("product").filter(prod__gte=1)
queryset = Collection.objects.annotate(Count("product")).filter(product__count=0)
max 17
Collection.object.annotate(prod=Count("product").filter(prod__gte=1)
it was not totally correct code but it helped me, THANKS!
Bassi
Traversery media
Bassi
Python django 7 hrs course explained from basics
.
Python django 7 hrs course explained from basics
Try code with stein and dennis ivy on youtube 👍
Bassi
Let me stick to a single course 😂
.
😂 alright goodluck
.
https://stackoverflow.com/questions/69863760/display-model-items-grouped-by-the-category-they-belong-to-kanbam-board-style My question on stackoverflow. If you have time please check it out. Thanks.
Артем
How on django to make choose of region in first visit on site?
Subhonjon
Hi, I wanted to install and configure LTE 3 admin for Django, can you help me?
Anonymous
But local storage not secure
Yes, you have to set expire time on token to like 5 min, so the risk is minimum
Capitaine Driccé
Hello team, i'm new here. Who can to send me a tutorial on CRUD MySQL with Django
Capitaine Driccé
I am a beginner
Capitaine Driccé
Anonymous
Np voiceless
Bassi
could some one explain how login system in django works
Bassi
i tried various tutorials but i'm finding it difficult day by day
Amir
Hello friends. Do you think it is better to have static and media files in the project root or in the parent folder?
Mirco
Hello friends. Do you think it is better to have static and media files in the project root or in the parent folder?
In a Production environment it's better to use a CDN to serve them So totally outside from Django servers
Mirco
And in debug mode?
In debug mode it does not matter It's ok to have it locally
Mirco
what is a cdn
Google it
Doragonsureiyā
what is a cdn
Step 1: Open a browser Step 2: Write down https://google.com or https://duck.com and press Enter Step 3: In the search box, write down the same words you asked here Step 4: Read the first results
Adiziel
Hello how can I list all sessions of a user and terminate special sessions from APIs
William
class Collection(models.Model): title = models.CharField(max_length=255) class Product(models.Model): title = models.CharField(max_length=255) collection = models.ForeignKey(Collection, on_delete=models.PROTECT) how can I filter collections that dont have any products?
If the collection field in the Product Model can store a null value then you can filter based on that. Collection.objects.filter(related_name=null).prefetch_related('related_name')
William
Ok
マクスイム • グセブ
I don't recommend to use custom way to store last login time because AbstractBaseUser class already has last_login field you need It seems like it's not mentioned in the docs but it's obvious from Django's source code https://github.com/django/django/blob/main/django/contrib/auth/base_user.py
マクスイム • グセブ
Hello how can I list all sessions of a user and terminate special sessions from APIs
The ones who use DRF API usually prefer TokenAuthentication or JWT Auth. Your goal is to blacklist or delete auth tokens. DRF TokenAuthentication: Import Token model from rest_framework.authtoken.models and delete the ones you want. JWT Auth: Blacklist tokens https://django-rest-framework-simplejwt.readthedocs.io/en/latest/blacklist_app.html
マクスイム • グセブ
Hello how can I list all sessions of a user and terminate special sessions from APIs
In case you use Django sessions (anyway) you can do request.session.flush()
マクスイム • グセブ
Hello friends. Do you think it is better to have static and media files in the project root or in the parent folder?
Yup, project root. I don't think you will use CDN to get some static files like images in your production. CDN should be used for external JS & CSS libraries, for example.
Nikolay
Hello. Please tell me how best to implement filling the column with information that complements the main content? For example, the main content is an article, and in the left column there are links to articles of related topics, a recommendation to watch thematic videos on the channel, etc. It is understood that this information is stored in the database, extracted from there and inserted into the template. But how to do it more correctly from the point of view of Jangi's ideology (this is my first project)? There are two aspects, for each of which several implementation options come to mind, but the lack of experience does not allow choosing the optimal one. 1) Method of displaying information. I can create a custom tag that will load data from the database and insert it to the page. Or you I simply pass a list with texts directly to the view through a variable, the contents of which are will displayed through a loop in the template. 2) Correspondence between main content and additional content. It is possible for each piece of additional content to store a list of page urls on which it should be displayed. Or keep a list of slugs of articles and site sections, which are almost the same thing. What is the best way to store such list? What type of field is best? Or make a many-to-many relationship between the main content and chanks of additional content. How do the pros implement such things?
Ali
Hey, I have a question about Django.
Ali
Here is my question on Stackoverflow. Would you please check this out and guide me? Thank you. https://stackoverflow.com/questions/69860283/best-way-to-declare-additional-data-and-modules-in-a-django-project
Ali
Is any official reference out there explaining these issues?
Mirco
For the second one, you can create a module called utils.py and put them inside it
Ali
Read 2 Scoops of Django book
you may find it funny but it's being delivered right now. 😁🤟
Ali
Thanks
Jerome
Yup, project root. I don't think you will use CDN to get some static files like images in your production. CDN should be used for external JS & CSS libraries, for example.
There are no rules Media files on a CDN are fine, static ones can be too. Django is not optimized to handle static files in production. It is advised in the docs to separate these files from the rest as much as possible for performance reasons. That said, it is perfectly possible to keep them in the root of the project. There is also the Whitenoise app which works well with Django when you have your statics internally.
Führer
anyone here know sqli
Shadow
What is the trace back error?
Zerat
What is the trace back error?
I can't show you sorry
A
Hi, did anyone here implement the sso with yaml in django ?
Amir.m.343
Hi everyone I have a question Can I make an app like gravity form for creating forms?
Deleted
https://stackoverflow.com/questions/69871579/pass-variable-in-quote
Amir.m.343
Gideon
Hello! Please reply, my IDE advises to put @staticmethod on get or post methods in the View class if "self" is not used there. This is right?
Gideon
Sorry for my English
Doragonsureiyā
thanks!)
You're welcome! 😊