Anonymous
Hii dear how to create sub menu in my Django block Like this: menu menu1 sub menu1 sub menu2 sub menu 3 sub menu 4 menu3 menu 4 My model class Menu(models.Model): name=models.CharField(max_length=555) slug = models.SlugField(null=True, blank=True) def str(self): return self.name class Submenu(models.Model): name=models.CharField(max_length=100) menu_id=models.ForeignKey(Menu,on_delete=models.CASCADE)
Anonymous
Plz help me
Lamboo
Hii dear how to create sub menu in my Django block Like this: menu menu1 sub menu1 sub menu2 sub menu 3 sub menu 4 menu3 menu 4 My model class Menu(models.Model): name=models.CharField(max_length=555) slug = models.SlugField(null=True, blank=True) def str(self): return self.name class Submenu(models.Model): name=models.CharField(max_length=100) menu_id=models.ForeignKey(Menu,on_delete=models.CASCADE)
class Submenu(models.Model): name=models.CharField(max_length=100) menu_id=models.ForeignKey(Menu,on_delete=models.CASCADE,related_name="submenus") And then, in your view, to retrieve all the submenus of a menu instance, you do: submenus = menu_instance.submenus.all()
Yes
Yes Me, [10.05.21 09:54] C:\Users\ANGEL\Desktop\student-management-system\student_management_system>python manage.py makemigrations Traceback (most recent call last): File "C:\Python\lib\site-packages\django\apps\config.py", line 165, in get_model return self.models[model_name.lower()] KeyError: 'customuser' How to solve this error ?
Sh
I am a Professional Django developer with 5 yrs experience. I can take up any project or freelance work at reasonable rates. Please Contact me.
Sadra
What changes we have to make in settings.py in django for production and hosting our website??
There is a checklist available that u need to double check each statement. Make sure nothing will be longer in --deploy flag of manage command
Sadra
Hi, I use postgres and I have a question: how I can create model with an arrayfield of unique user's id? I want that user's id will be removed from the array when I delete the user P.S. Now I use standart auth user
What do u mean by "unique users"? Whenever you remove a user, that will be dropped from the database which means, that will no longer be available in any query set.
Sadra
I am a Professional Django developer with 5 yrs experience. I can take up any project or freelance work at reasonable rates. Please Contact me.
Why not trying upwork or fiverr or something?? Hope you find your favorite position asap. ❤️
Sh
I have tried it but no luck. Since its pandemic, need something urgently.
Sh
Thanks for the information.
Sadra
I have tried it but no luck. Since its pandemic, need something urgently.
I've heard about helping newbie developers and making money from that.
Sadra
I've heard about helping newbie developers and making money from that.
Kinda text chat. But you help them to fix their issues.
Anonymous
So?
like:
Anonymous
So?
Like this: menu sub menu1 sub menu2 sub menu 3 sub menu 4 menu1 sub menu1 sub menu2 sub menu 3 sub menu 4 menu3 sub menu1 sub menu2 sub menu 3 sub menu 4 menu 4 sub menu1 sub menu2 sub menu 3 sub menu 4
Sadra
but when I show my sub menu in template they show all menu name
Hold on.. You are trying too keep the static data in the DB??
Sadra
Is that the menu that you show in the navbar??
Anonymous
ken
hi.if i run django from custom gunicorn script, do i need to systemctl enable gunicorn also? or just the script only? thanks
ken
Absolutely yeap.
so both the script and gunicorn? got it. plus,how do i tell if gunicorn is deploying my project or the script
ken
(because i have N number of workers spawned from script)
Sadra
so both the script and gunicorn? got it. plus,how do i tell if gunicorn is deploying my project or the script
Systemctl manages your services and ports. You enable the gunicorn with Systemctl. That script runs a session though.
ken
i tried deploying wiyh both gunicorn at startup and the script also. how do I tell what thing is serving it though? thanks again
Sadra
I've seen a trick that shows whether the web sever is being served by the gunicorn or not in Flask. I've never experienced that in Django honestly. :(
ken
Checkout the logs.
the app is being run by gunicorn.service (uses system wide apps) instead of gunicorn startup script (that uses venv) any workarounds bruh??
Ahmed
no idea
Anonymous
How to create custom base user model but keep the super user fields different
Doragonsureiyā
How to create custom base user model but keep the super user fields different
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
Islom
How do I track user actions in model forms, if you do something in admin Django, you can clearly see log entries, but when I try to let's say, CRUD model instance using forms, nothing is appearing in log entries.
Anonymous
How to create custom base user model but keep the super user fields different
Vivek
Hello guys can someone please help me out? How do I retrieve data from a model in variable so that I can use it in conditional statements
Владислав
Guys, please help with UpdateView! # Обновление поста class PostUpdateView(SuccessMessageMixin, UpdateView): model = Post template_name = 'modules/post/post_create.html' form_class = PostForm success_url = None success_message = "Материал: %(title)s успешно добавлен!" def get_context_data(self, **kwargs): context = super(PostUpdateView, self).get_context_data(**kwargs) if self.request.POST: context['formset'] = PostAttachmentFormSet(self.request.POST, instance=self.object) context['formset'].full_clean() else: context['formset'] = PostAttachmentFormSet(instance=self.object) return context def form_valid(self, form): context = self.get_context_data() formset = context['formset'] with transaction.atomic(): current_user = self.request.user form.instance.updated_by = current_user if all([form.is_valid(), formset.is_valid()]): self.object = form.save(commit=False) attachments = formset.save(commit=False) for attach in attachments: attach.post = self.object attach.created_by = current_user attach.save() form.save_m2m() form.save() else: context.update({'formset': formset}) return self.render_to_response(context) return super(PostUpdateView, self).form_valid(form) Changes are not saved, and generally an error occurs [{'id': ['Required field.']}, {'Id': ['Required field.']}, {}, {}, {}] Does anyone have a good updateview, createview with inline-formsets ?
Islom
Hello guys can someone please help me out? How do I retrieve data from a model in variable so that I can use it in conditional statements
data = ModelName.objects.filter(title="my data) if data == "hello": do something
Владислав
Guys, please help with UpdateView! # Обновление поста class PostUpdateView(SuccessMessageMixin, UpdateView): model = Post template_name = 'modules/post/post_create.html' form_class = PostForm success_url = None success_message = "Материал: %(title)s успешно добавлен!" def get_context_data(self, **kwargs): context = super(PostUpdateView, self).get_context_data(**kwargs) if self.request.POST: context['formset'] = PostAttachmentFormSet(self.request.POST, instance=self.object) context['formset'].full_clean() else: context['formset'] = PostAttachmentFormSet(instance=self.object) return context def form_valid(self, form): context = self.get_context_data() formset = context['formset'] with transaction.atomic(): current_user = self.request.user form.instance.updated_by = current_user if all([form.is_valid(), formset.is_valid()]): self.object = form.save(commit=False) attachments = formset.save(commit=False) for attach in attachments: attach.post = self.object attach.created_by = current_user attach.save() form.save_m2m() form.save() else: context.update({'formset': formset}) return self.render_to_response(context) return super(PostUpdateView, self).form_valid(form) Changes are not saved, and generally an error occurs [{'id': ['Required field.']}, {'Id': ['Required field.']}, {}, {}, {}] Does anyone have a good updateview, createview with inline-formsets ?
The solution to the problem was to add the ID to the template. {{ formset.management_form }} {% for attach in formset %} {{ attach.id }} {% endfor %}
NIDESH
Django multi tenancy with isolated DB , any good article or YT video for learning them?
Vivek
data = ModelName.objects.filter(title="my data) if data == "hello": do something
I dont know why but filter was not working, I tried get and now it worked thanks anyways
Владислав
how to display in ListView m2m fields belonging to news? context['title'] = str(context['posts'][0].category + m2m-subcategory?)
Sumit
Hi, has anyone have used django with celery and redis? How to pass password for the connection. I am receiving this error Cannot connect to redis://localhost:6379//: Authentication required which seems reasonable because I am not passing password . I have tried CELERY_BROKER_URL = "redis://:mysecurepasword@localhost:6379" but this also doesn't seem working.
Ruslan
Hi, can you help me with django transaction? How to use them with async class-based views? I tried, but i can't use decorator transaction.atomic or use it with manager
Владислав
which is better to use, one-to-one or abstractuser?
Ruslan
which is better to use, one-to-one or abstractuser?
it depend what you want? i like to use abstractuser, because u can create your own methods and use it in template easily
Владислав
it depend what you want? i like to use abstractuser, because u can create your own methods and use it in template easily
I want to make a username / email login, I want to make a points system for a user, a subscriber system. I'm just worried about the subsequent revision, if suddenly I want to enter data after creating an abstract user and let's say I want to modify it in a year, will it be critical?
Владислав
it depend what you want? i like to use abstractuser, because u can create your own methods and use it in template easily
Moreover, if I make myself a profile one-to-one, then I will add exactly 4-5 requests in each view, even with optimization. This is also repulsive.
Владислав
preview = models.ImageField(verbose_name='Превью изображение', upload_to=image_directory_path('posts/'), blank=True) Guys, I have such signals for overwrite and delete. Can you tell me how to make an exception so that it does not delete the default picture? @receiver(pre_delete, sender=Post, weak=False) def delete_preview(sender, instance, **kwargs): try: path_to_old_preview = instance.preview.path if os.path.exists(path_to_old_preview): print('Остаточные картинки удалены...') os.remove(path_to_old_preview) except: return False
Anonymous
How can i give gap in loop?
software
Hi friends In jinja template how to show time in h:m formate and also date in 2021.5.9 fromat
Mirco
Hi friends In jinja template how to show time in h:m formate and also date in 2021.5.9 fromat
Easier and better way Do it inside the view 😎 so your template will just need to show that data
Mirco
Any other method with templates
https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#date
Ombra
hi,can someone help me to deploy my site? i keep getting these errors on digitalocean (sorry if maybe it's a stupid error but it's my first time deploying a django website)
Ombra
"error while running python manage.py collectstatic --noinput"
ㅤ
Hey anyone any best idea about . To create api with nested serilizer for post request
sarth
how to send push notification on website when database record updated. please help to find any resource
Kashif
Anyone knows, how to shows visualizations on webpage using Django?
Mirco
sarth
have a look at it, bottom section
ok sir, i check it ..thanks alot
Doragonsureiyā
ok sir, i check it ..thanks alot
You're welcome! 😊
™
thanks i'm gonna check it out
I have done with this one. many of them did not work.
Anonymous
I need help in django
Anonymous
Can someone help me??
Doragonsureiyā
I need help in django
Don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello, I need help on $z!" Just ask directly! The better you are at explaining the problem, the more likely you are to get help. Asking smart questions