__init__
Why can't I filter object by using UUID as primary key in django??
Saurav
Saurav
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
Брат
Frederic
Anonymous
thank you
You're welcome. Please let me know if it worked
Saurav
Брат
Брат
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.
Брат
Anonymous
how does django work? first the model, then the view, then the url?
Брат
Брат
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
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
Saurav
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
Who can help me?
Sina
Meer
Rohan
Rohan
All emojis have definite ascii representation
Rohan
That can be stored wherever
Sina
Why?
So, What should I do?
Meer
Maxim
Meer
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
Anton
Many Thanks
Anton
WOW its awesome! Thanks again
Deleted
Hey, guys , how to do 4 table join select in Django?
123
tech-tycoon
Sinan
django db models deal with list of sting
Maxim
Sinan
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?