Shubham
Try migrating it again
b
I wanna share an incident here, I forgot to mention model into admin file and the site's still working.
Jon snow
Anyone help me please?
Doragonsureiyā
Anyone help me please?
Please don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello I need help on $z" Just ask about your problem directly! With 56k+ people the probability that someone will help is pretty high. Also please read: http://catb.org/~esr/faqs/smart-questions.html
Leonardo
hi! i'm having problems to serialize a Enum with DRF, can someone help?
Leonardo
TypeError: Object of type GenreType is not JSON serializable
Leonardo
where GenreType is a Enum
Leonardo
from enum import Enum class GenreType(Enum): MALE = "MALE" FEMALE = "FEMALE"
Leonardo
from rest_framework import serializers from prescription.models import Prescription, Pacient class PrescriptionSerializer(serializers.ModelSerializer): class Meta: model = Prescription fields = 'all' class PacientSerializer(serializers.ModelSerializer): class Meta: model = Pacient fields = 'all'
Mirco
You cannot serialize the enum as it is and where you use that enum ?
Leonardo
You cannot serialize the enum as it is and where you use that enum ?
class PacientList(generics.ListCreateAPIView): queryset = Pacient.objects.all() serializer_class = PacientSerializer class PacientDetail(generics.RetrieveUpdateDestroyAPIView): queryset = Pacient.objects.all() serializer_class = PacientSerializer
Mirco
Use code sharing tool please Follow our simple rule
Leonardo
class Pacient(models.Model): class Meta: db_table = 'pacient' id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=100) age = models.PositiveIntegerField(validators=[MinValueValidator(1), MaxValueValidator(100)]) genre = models.CharField(max_length=10, choices=[(tag, tag.value) for tag in GenreType], default=GenreType.FEMALE)
Mirco
Then for the enum
Mirco
Use serializer method field
Mirco
And return obj.get_gnre_display()
Mirco
And you will get that field value
Leonardo
thank you! so i should not change my model, correct?
Mirco
Yup, the model is correct
Leonardo
thank you, i'll try
Anonymous
Django sendpdf
I find out html2pdf which works fine for client side pdf creation
Anonymous
Any advance django course
Doragonsureiyā
Any advance django course
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Sourav
Can anyone tell me best api documentation stuff for Django REST framework ? What i know so far is : 1) django rest swagger(seems to be deprecated) 2) drf-yasg 3) drf own way Plz suggest
Anonymous
Learn graphql
Sourav
Actually m confused...on drf official site...they have mentioned use generateschema for static and schemaview for dynamic schema
Sourav
And Redoc is also there
Sourav
Redoc has good 3 panel view but it is not interactive
Sourav
drf-yasg
But drf-yasg only supports swagger 2.0 and not openapi 3
Mirco
But drf-yasg only supports swagger 2.0 and not openapi 3
You can easily generate the openapi 3 from the swagger generated by drf-yasg
Gil
+1swagger
Mirco
Ok
https://mermade.org.uk/openapi-converter
Sourav
Thanks
Sourav
drf-spectacular/README.rst at master · tfranzel/drf-spectacular · GitHub https://github.com/tfranzel/drf-spectacular/blob/master/README.rst
Sourav
Ok
Siddharastro
Hello Im trying to configure uwsgi inside docker container for django, but when container starts running sends me the following error: no module named myapp
Siddharastro
the problem occurs in wsgi.py file
Siddharastro
solved: i just added pythonpath = /app/myapp to uwsgi.ini file
Вук с арбузом
When I use default password_change form auth_views.PasswordChangeView.as_view(), it has description field containing tips like "Your password can’t be a commonly used password. Your password can’t be entirely numeric." I'd like to change this text (probably translate to another language). Is there any way I can do it without writing my own form?
Aman
how can i show PDF which in encrypted in database .
Govind
Hi Everyone, How to upload image file using form? please help me.
Harish
Hi Everyone, How to upload image file using form? please help me.
https://coderwall.com/p/bz0sng/simple-django-image-upload-to-model-imagefield
b
hey guys I have a quick question things to learn in Django?
Aman
in our template
suggest me what i do
Cesar
Hello, does anyone know how can i send a variable to base.html file? in my base.html i have navbar that includes a Title of current page, how can i set it depending of the view calling it
Gil
Hello, does anyone know how can i send a variable to base.html file? in my base.html i have navbar that includes a Title of current page, how can i set it depending of the view calling it
https://docs.djangoproject.com/en/3.0/topics/templates/#the-django-template-language https://tutorial.djangogirls.org/en/django_templates/ https://docs.djangoproject.com/en/3.0/intro/tutorial03/ good luck
Gil
Don't worry, we come from the same way 😜
Ayomide
in the base...do something like this {% block title %} Home {% endblock %}........in the about page ..you can do something like this {% block title %} About{% endblock %}
Ayomide
hope it helps
Ayomide
yes...exactly
Gil
uhmm interesting, that way i don't have to put the title in the context inside the view (keeping it clean)
This is inheritance of templates, very interesting , the next lesson for you after understant sintax tempaltes and passing contexts https://docs.djangoproject.com/en/3.0/ref/templates/language/#template-inheritance
Ayomide
😊
Gil
I see two things to work -storage -frontend serve file/show/download Do you know how to store? Its not a easy decision
Aman
I don't know
Actually this is my first time on PDF.
Gil
I don't know
Mee to 😜 there s some work, is not easy. File into db in short time can be fun, long term huge database.
Gil
yes
May be better a filesystem encrypted, and only indexing files , giving read permission to users by backdend
Aman
okay i try.
Aman
okay i try.
But i really don't have any idea.
AJR
Hey guys, I just finished the beginner Django tutorial from Mosh. What would be a good transition from Mosh's beginner tutorial?