__init__
Why can't I filter object by using UUID as primary key in django??
Frederic
I'm defining my model and for some fields I've added birthday = models.DateField(name=_("User birthday")) and I get the error TypeError: getattr(): attribute name must be string. What am I doing wrong here ? name can't be translated ? Is Name even needed or is the field variable name is the same as the name passed in the constructor ?
Umesh
Can somebody share framework, ORM, Auth library and REST API videos??
Брат
Improve your question.
Classic viewset will look like: serializer_class = SomeSerializer queryset = SomeModels.objects.all But I need viewset with static data: {'name': 'Alex'} In simple django framework, it will just: def somedata(request): context = {'name': 'Alex'} return render(request, 'some.html', context)
Anonymous
thank you
You're welcome. Please let me know if it worked
Брат
I can do that in frontend itself, but Im practising with sending the data from backend
Saurav
Ok no issues just return json.dumps(python_dict)
Saurav
From your views
Брат
From your views
Sorry you mean from class SomeViewSet(viewsets.ModelViewset) or from def?
Брат
I mean I can return something only in def function
Saurav
Yes you can try.
Брат
Okay, thank you, I'll take a look to it, I'll let you know if it didn't work
Saurav
Sure.
Saurav
Or simpler you can use return JsonResponse(python_dict)
Saurav
With with your function based view.
Брат
With with your function based view.
yeah yeah, I was thinking that way too
Anonymous
how does django work? first the model, then the view, then the url?
Брат
how does django work? first the model, then the view, then the url?
somehow yes, if you use html and css for frontend
Брат
however in case that you use frontend like reactjs, vuejs and etc. you need to add serializers so you could pass the data
Брат
model -> serializers -> views -> url = API
Брат
By the way, Im newbie don't trust me
Saurav
Request-->url.py-->views.py+models.py-->template--> Response
Saurav
In simple way.
Saurav
For better read blogs on request-response cycle in django.
Anonymous
Thank you so much
Брат
Thank you one more time)
Saurav
Great to hear.
S.H.K
Hi How connect form html with other table database ??
Saurav
Hi How connect form html with other table database ??
Want to connect html form to database?
S.H.K
Want to connect html form to database?
Yes I have tbl1 and by django connect
Saurav
Yes I have tbl1 and by django connect
Refine you question for better help.
Alex
Ckeditor items popup working in back not popuping in front? Why?
You mean it is working in Admin site and not working in your template?
Dev
How to display the excel sheet data in the form of table in the web browser using django ? Anyone have the idea about this , how can we do it
Saurav
# load XLSX workbook wb = Workbook("workbook.xlsx") # save workbook as HTML file wb.save("workbook.html")
Dev
Not this way
Dev
Something other than this
Saurav
Not this way
Give way of logic/approach you want to perform.
Dev
I have an excel file that should be displayed in the form of tables in the webpage not the exact excel sheet but only the data, And with the help of some html to we should be able to choose the file and submit it ,here the thing is when we submit it, It should be displayed on the webpage (not the excel sheet itself) but in the form of table
Dev
Yes
Saurav
This was the logic for backend.
Saurav
If you want to select a file and wants to convert it to html then you have to create a form for that. After submitting the file you can convert it to html format by using above logic.
Dev
Ok thanks
Sina
Hi I have a problem in save emoji jn mysql in default admin panel
Sina
Hi I have a problem in save emoji jn mysql in default admin panel
(1366, "Incorrect string value: '\\xF0\\x9F\\x98\\x90\\xF0\\x9F...' for column 'message' at row 1")
Sina
Who can help me?
Naman
Hi I have a problem in save emoji jn mysql in default admin panel
https://stackoverflow.com/questions/44496101/how-to-insert-emoji-into-mysql-5-5-and-higher-using-django-orm
Meer
Hi I have a problem in save emoji jn mysql in default admin panel
you may change database to postgresql and then try it.
Meer
Hi I have a problem in save emoji jn mysql in default admin panel
Second Option is to change emoji to anyother format like string or code format then try to save it.
Rohan
All emojis have definite ascii representation
Rohan
That can be stored wherever
Sina
Why?
So, What should I do?
Anonymous
is there someone here knows how to delopy django + react with cpanle
Anton
Hi all! Pls help! I have model with CharField which contains choices for order like NEW/ACCPETED/CANCELLED/DONE (TextChoices) and I displaying my model via DetailView. How i can sort objects by choice? Objects with NEW/ACCEPTED choice must be at top
REZA
Hi all! Pls help! I have model with CharField which contains choices for order like NEW/ACCPETED/CANCELLED/DONE (TextChoices) and I displaying my model via DetailView. How i can sort objects by choice? Objects with NEW/ACCEPTED choice must be at top
Model.objects.annotate(my_order=models.Case( models.When(fieldname="NEW", then=1), models.When(fieldname="DONE", then=2), output_field=models.IntegerField(), )).order_by('my_order'))
Anton
Many Thanks
Anton
WOW its awesome! Thanks again
Deleted
Hey, guys , how to do 4 table join select in Django?
123
Hey, guys , how to do 4 table join select in Django?
What r u using normal orm or serialiser
Naman
Hey, guys , how to do 4 table join select in Django?
Are all the tables linked through many to many or foreign key relation?
Sinan
django db models deal with list of sting
Maxim
django db models deal with list of sting
it is worth formulating more clearly
Sinan
it is worth formulating more clearly
thanks it has been solved
Alex
I have a question. I have django 3.0 and postgres 9.6 and want to annotate a queryset of a model by values from its m2m table. Here is my try: Petition.objects.filter(incidents__fact_id__isnull=False).annotate(facts=ExpressionWrapper(F('incidents__fact_id'), output_field=ArrayField(IntegerField()))) So Incident has a fk on Petition and Fact. The problem is that the facts annotation gets only a single value from the set, but I need the whole set.
Hamed
I have a docker-compose.yml, how can I get an image of it?