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
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
Sadra
Sadra
Sadra
Sadra
Sh
I have tried it but no luck. Since its pandemic, need something urgently.
Sh
Thanks for the information.
Anonymous
Sadra
Sadra
Anonymous
Anonymous
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
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
Sadra
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)
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
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
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
Jun
Владислав
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
Владислав
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
Islom
Vivek
Владислав
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?
Well Done
Владислав
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
software
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
Mirco
Mirco
Kashif
Anyone knows, how to shows visualizations on webpage using Django?
sarth
Mirco
Mirco
Doragonsureiyā
™
Ombra
Anonymous
Anonymous
I need help in django
Anonymous
Can someone help me??
Mirco
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