park seo joon
do you have custom function "create_post"?
Yeah I have a custom class create_post in my models but even when I remove it and then just use the .create command it's still having same issue
Alex
can you share your codebase?
park seo joon
can you share your codebase?
I could only just type it out because I'm not with my PC now
park seo joon
I have specified the views and template should I specify the model aswell?
Alex
well, codebase is needed for reproducing the issue.
park seo joon
I'm coming
park seo joon
Class Post(models.Model) user = models.ForiegnKey(User, on_delete=models.CASCADE) post = models.FileField(upload_to='post', default=None) caption = models.TextField(max_length=300) date_created = models.DateTimeField(auto_now_add=True) no_of_likes = models.IntegerField(default=0) objects = PostManager() def str(self) return self.user.username class PostManager(models.Manager): def create_post(self, user, post, caption): post = self.create(user=user, post=post, caption=caption) return post
park seo joon
yeah
Here it is
Alex
Class Post(models.Model) user = models.ForiegnKey(User, on_delete=models.CASCADE) post = models.FileField(upload_to='post', default=None) caption = models.TextField(max_length=300) date_created = models.DateTimeField(auto_now_add=True) no_of_likes = models.IntegerField(default=0) objects = PostManager() def str(self) return self.user.username class PostManager(models.Manager): def create_post(self, user, post, caption): post = self.create(user=user, post=post, caption=caption) return post
from django.db import models from django.contrib.auth.models import User class PostManager(models.Manager): def create_post(self, user, post, caption): post = self.create(user=user, post=post, caption=caption) return post class Post(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) post = models.FileField(upload_to='post', default=None) caption = models.TextField(max_length=300) date_created = models.DateTimeField(auto_now_add=True) no_of_likes = models.IntegerField(default=0) objects = PostManager() def __str__(self): return self.user.username
park seo joon
Thanks alot
Shan
class InstanceBulkCreateUpdateSerializer(serializers.ListSerializer):     def create(self, validated_data):         instance_data = [Instance(**item) for item in validated_data]           return Instance.objects.bulk_create(instance_data) class InstanceSerializer(serializers.ModelSerializer):       class Meta:           model = Instance           fields = ["cmdbid","name","product"]         read_only_fields = ["cmdbid", ]         list_serializer_class = InstanceBulkCreateUpdateSerializer Im using bulk_create way able load data but without cmdbid value because validated_data exclude read_only_fields always. Is that any way to include all with cmdbid value without remove read_only_fields?
Nick
Good day! Does anyone have a ready-made template or a GitHub repository that can be used as a basis for developing a website? I want to avoid having to implement pages for login, password recovery, account settings, and so on. The most suitable would be a prototype website related to file storage, similar to Google Drive.
Priyanshu Pratap
Hey can i use django inbuilt authentication and integrate it with nextjs?
Charly
Using DRF
Django auth or drf auth?
Charly
For drf yes.
Priyanshu Pratap
Drf auth
Priyanshu Pratap
For drf yes.
Bro is i have to use JWT for it? Can't i use django inbuilt authentication??..i am not much familiar with drf
cj
Bro is i have to use JWT for it? Can't i use django inbuilt authentication??..i am not much familiar with drf
Django built-in authentication is just authenticate() and login() functions, you can use them whenever you want but if you want to use JWT, go for it
Maroua
i want some help with the login in dajngo please , i did the template and the urls also the views the only thing left is how to get the user's infos from the html template so it shows on the data base in /admin ?
Priyanshu Pratap
Ibnu
Is there anyway to get tags like nav_link .. I mean I make custom but if I want many component it's going to be difficult
Ibnu
How can I say If this link is active make this styling otherwise this is the default..
Ritik Sharma
I had connected django to mongodb. 1. When I first import json file to db containing 1k data and when user input the data by post method then data is not showing to the database 2. When firstly user input the data though post method that data is stored in database after that if I'm importing json file in same database it is showing error (E11000 duplicate key error collection) I'm unable to slove this error help me out plz..
Marc
hello everybody,i need the help for corrige my code. this is my error: UnicodeEncodeError at /contrat-pdf/13/ 'latin-1' codec can't encode character '\u2019' in position 475: ordinal not in range(256)
Dexter Spectre ࿗
can you help me find why in pages with csrf when i using my api , i got 400 status code with json parse error?
ruthless
Hello everybody, I can't connect postgresql database in django DATABASES = {     'default': {         'ENGINE': 'django.db.backends.postgresql_psycopg2',         'NAME': 'ecommerce',         'USER': 'postgres',         'PASSWORD': '123456',         'HOST': 'localhost',         'PORT': '5432',     } } My error: Is the server running on that host and accepting TCP/IP connections?
MD QASIM
HTML full course PDF any one does have
Bekzod Juraev
Guys give me advice.Which these options good approach (Custom user model or link new profile model to user)???
Bekzod Juraev
I did second approach linking to user because it was simple but people saying it is not good approach
cj
probably you forgot to add enctype="multipart/form-data" to your <form> tag
cj
I did second approach linking to user because it was simple but people saying it is not good approach
there are many approaches to solve problems because there are many different requirements and use cases, so use the one that fulfills your requirements and works for you
Charly
HTML full course PDF any one does have
This is a Django group. Ask in offtopic or do a couple google searches
Mehdi
Thanks 😁🌹❤️
Love Berlin
Hello , I am using django with uwsgi, and python version 3.8 , from last 2 years I had no issues , all of a sudden I am getting uwsgi. Worker died and segmentation fault issue , did anyone experienced this issue ? Any solution?
Love Berlin
Any on the logs?
Full logs , I am unable to share , but here is the actual main log ——-DAMN ! worker 1 (pid: 707) died : ( trying respawn ... Respawned uWSGI worker 1 (new pid: 711) DAMN ! worker 2 (pid: 708) died : ( trying respawn ... Fri Jul 5 19:22:22 2024 - [emperor] vassal abc_new Respawned UWSGI worker 2 (new pid: 712) DAMN ! worker 4 (pid: 709) died : trying respawn ... Respawned uWSGI worker 4 (new pid: 713) DAMN ! worker 3 (pid: 710) died : trying respawn ... Respawned uWSGI worker 3 (new pid: 714) !!! UWGI process 712 got Segmentation Fault !!! !!! uWSGI process 714 got Segmentation Fault !!! !!! uWSGI process 713 got Segmentation Fault !!! !!! UWSGI process 711 got Segmentation Fault !!!
Maroua
Create a django form, you can also use crispy forms.
i'll try it , thank you !!
Maroua
Use forms in html... and in your views under post get the data from the form using request.POST.get method and create the user and save it...
i did it , but i think there is an error somewhere , i'll try this again , thank you !
Parsa
Django auth or drf auth?
How to get the values form request if i post in view Curl ..... _p def all_data(request): return JsonREsponse(request.)
Pedram
How to get the values form request if i post in view Curl ..... _p def all_data(request): return JsonREsponse(request.)
form= TestForm(request.POST) if form.is_valid(): # do something else: # return validation
Haleem
Anyone use onesignal to send transactional email like sending email for change password, new account and all from website. It seems onesignal is cheaper than sendgrid
Doragonsureiyā
Anyone use onesignal to send transactional email like sending email for change password, new account and all from website. It seems onesignal is cheaper than sendgrid
This is not a Django specific question, please delete your offtopic message. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
Taha
Hi guys 😊 How can I connect one thing with post method from js to Django view?
Taha
Nope Just JavaScript vanilla
The Inspired
ok ok
The Inspired
plain django provides both frontend and backend
The Inspired
if you want to use Django only as an API provider, take a look at DRF
The Inspired
https://www.django-rest-framework.org/
The Inspired
technically, you can write HTML, CSS and JS inside Django only
Ваня
Hi, for some reason django not return data from db, pls send help
Ваня
No errors in sight
Ваня
Even if i just accessing a variable directly through jinja i get this <QuerySet []>
Ваня
https://hastebin.com/share/yidufepala.bash
Moderator
I want to start django framework with rest API anyone suggest any YouTube channel??
Doragonsureiyā
I want to start django framework with rest API anyone suggest any YouTube channel??
Are you looking for Django REST Framework documentation? Here you have it: https://www.django-rest-framework.org/
Mehdi
Bruh is there anyway to give a request,POST a name ? i got 4 form with POST method in ONE PAGEE
Priyanshu Pratap
I am not able to use session variables in django i did all preliminary steps like configuring middleware and engines and session age as well but still its not working. I am using mysql as a database and using nextjs as frontend and django as backend...please help
Mehdi
use unique field names for each form
html : <form class="row" action="" method="POST" enctype="multipart/form-data"> and views : if request.method == 'POST' : how yo use ? 😅
Kasem
How can I solve template page not found in class based views?
ㅤㅤ
Guys how python django framework use in web development
ㅤㅤ
?
ㅤㅤ
Official docs please
I found it is useful for back end part