Saman
Could u send your model?
And let me say something about nested serialization in the put, patch, and post methods. These have a heavy structure for updating. So I really recommend using a rest-framework-generic-relation package, which is suggested by rest framework documentation. https://github.com/Ian-Foote/rest-framework-generic-relations
This package handles the update and create, process for every update, and create methods
User model:
class User(AbstractUser, TimeStampedModel):
objects = CustomUserManager()
email = models.EmailField(_("email address"), blank=True, null=True, unique=True)
cell_number = PhoneNumberField(null=True, blank=True)
national_id = models.CharField(max_length=11, null=True, blank=True)
role = models.SmallIntegerField(
choices=UserRoleChoices.choices, null=True, blank=True
)
last_active_at = models.DateTimeField(null=True, blank=True)
is_active = models.BooleanField(default=False)
PersonInCharge model:
class PersonInCharge(models.Model):
entity = models.ForeignKey(
Entity,
on_delete=models.PROTECT,
null=False,
blank=False,
related_name="person_in_charges",
)
user = models.OneToOneField(User, on_delete=models.PROTECT)
positions = ArrayField(
models.SmallIntegerField(choices=PositionChoices.choices), null=True, blank=True
)
Christian
django api: in a patch APIView class view: how can we get the pk of the object?
Rohan Ekke
I deploy my website on pythonanywhere my site is working well but i am not able to view images i.e media file, when i turn debug=false then i am getting 404 error and when its true then i can see image on that site
.
Abolfazl
Hiccup
Hi, Everyone,
I am new to here.
Now, I am working with django backend project and I need to deploy my project using Github Action.
Please help me.
ㅤ
hii,
i was building a project where i need to "add more" fields button, for particular data field on a model,(i will take care of frontend, i'm confused on model and form, & i'm not into htmx)
i'm little confused about how it going to save, and implementing it,
please help me, if anyone knows,
thanks in advance,
MUHAMMED
How to use django with Rabbitmq and celery for mailing
MUHAMMED
I set up everything but job is triggering. But function doesn't work
MUHAMMED
Function alone is working fine. I used sharedtask and called. It won't working
Charly
Mr. Achiever
Hello Team,
I'm planning to create a web application similar to Udemy using Django. Can someone guide on how to start?
I've already created multiple web apps using Django for day to day tasks. But this time planning for streaming videos using Django.
Please suggest.
cj
Abdul
How install django in visual studio code bro
Rose
User Abdul has 1/3 warnings; be careful!
Reason:
flooding to draw attention
ali
User model:
class User(AbstractUser, TimeStampedModel):
objects = CustomUserManager()
email = models.EmailField(_("email address"), blank=True, null=True, unique=True)
cell_number = PhoneNumberField(null=True, blank=True)
national_id = models.CharField(max_length=11, null=True, blank=True)
role = models.SmallIntegerField(
choices=UserRoleChoices.choices, null=True, blank=True
)
last_active_at = models.DateTimeField(null=True, blank=True)
is_active = models.BooleanField(default=False)
PersonInCharge model:
class PersonInCharge(models.Model):
entity = models.ForeignKey(
Entity,
on_delete=models.PROTECT,
null=False,
blank=False,
related_name="person_in_charges",
)
user = models.OneToOneField(User, on_delete=models.PROTECT)
positions = ArrayField(
models.SmallIntegerField(choices=PositionChoices.choices), null=True, blank=True
)
Did you import the user model from django.admin.contrib.auth? If you did this, try defining AUTH_USER_MODEL and name it your custom model and import it instead of the user model like: settings.AUTH_USER_MODEL
if you didn't this, maybe it's use default user model. and in serializer, define your model fields explicitly.
M. Hossein
In websocket, is it a wise idea to send an error message when user-sent websocket body has issues?
Charly
M. Hossein
Charly
Hmm. Why is that?
Why the user needs that some bad written code is beign used/
M. Hossein
Charly
Charly
not the developer
Charly
M. Hossein
But the user will see an error which is impossible to him to solve?
No.
Let's put it this way.
You are sending a message to user X which does not exist. In frontend it's ignored. Probably the user is never going to use the websocket directly and the frontend framework is involved. But, it wouldn't hurt to inform developers that wanna use the websocket the detail of problem. Like 'Receiver user does not exist' or maybe 'message_body is required.'
Wouldn't that make it easier to debug?
ali
MUHAMMED
show what you have done
I am using windows based system. I have installed Erlang and then RabbitMQ. In the django app I have created a celery.py and added urls for RabbitMQon the settings. Then I have defined a function on django views with decorator @shared task. I have called this task using .delay option in One API. At that time in celery command prompt it gets reflected. Queue is updating. But function is not triggering I guess
Nasrullah
Is it possible to create objects for one class using another class modle?
Charly
Sagar
I have deployed django image upload project on railway.app , in the database it is showing the path of the image but In the admin panel when I try to open the image it is giving an error of path not found
ℳɾ.ℳơħάʍάđɾ૯zά
ℳɾ.ℳơħάʍάđɾ૯zά
#settings.py
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
#-----------------------------------------
#urls.py
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# Your URL patterns
] + static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
Sagar
ali
Sagar
yes
bansh
Rose
User Soham has 1/3 warnings; be careful!
Reason:
this is neither a job board nor a bulletin board
☯️
Hello friends
I have a Product model in my Django project, and I want to use product info’s in product list page and product detail page , and in product list page just need fields name , price , and photo , but in detail page need all info
The question is :
Is it better to write different serializers for both pages?
And how should I name them?
For example: ProductDetailSerializer?
Or what about product list page and home page?
Is there any pattern or rule to name them?
dr.Ibrahim
Hello everyone 👋
How can test local Django API on flutter application.
Yan
Hello,
I’m new to the Django framework and I have a problem.
I created an application in the project and added the model. Now I can’t display the model data in an HTML page.
Can you help me make the link?
dr.Ibrahim
dr.Ibrahim
João Pedro
Hi guys, how do you make authentications with django-ninja? Do you have any exemple?
nyctophile
Hi guys!
i need your experience with the problem i am having
I am trying to use Class based views in my project but having a problem with redirecting user to home page after trying to log in, here are my views https://hastebin.com/share/negoqapisi.xml
i am getting this below :
Method Not Allowed (POST): /main/home
Method Not Allowed: /main/home
[16/Feb/2024 19:23:19] "POST /main/home HTTP/1.1" 405 0
Not Found: /main/
Any help appreciated! Thanks
Mirco
nyctophile
Show your urls
https://hastebin.com/share/olopatamip.lua here
nyctophile
Mirco
nyctophile
nyctophile
Muflone
Muflone
the error refers you're tring to do a post to the /main/home url
Muflone
check your browser console where are you redirecting
nyctophile
Ashkan
Hello my friends. Do you know how I should connect the host to the site?
nyctophile
nyctophile
Muflone
click on the home/ row and select the headers page
Muflone
this is a POST request
nyctophile
this is a POST request
yeah i am getting this error when i submit username and password and i am not logging in
nyctophile
nyctophile
your <form> where you created it, in the templates I suppose
<div>
<form method="post", action="{% url 'home' %}">
{% csrf_token %}
{{ form.as_p }} {# Renders all form fields as paragraphs #}
<button type="submit">Create Group</button>
</form>
should i remove "action" ?
Muflone
Muflone
(youtube is the worst thing available on internet to learn development)
Muflone
follow the official python tutorial or the djangogirls tutorial
nyctophile
Seth van Dalstein
Hi, I forgot my passwords to superuser and staff, the project is not yet published, but only in the process of development.
Muflone