Məhəmməd
def vote(request, question_id): question = get_object_or_404(Question, pk='question_id') try: selected_choice = question.choice_set.get(pk=request.POST['choice']) except(KeyError, Choice.DoesNotExist): return render(request, 'polls/detail.html', {'question': question, 'error_message': "You didn't select a choice"}) else: selected_choice.votes += 1 selected_choice.save() return HttpResponseRedirect(reverse('polls:results', args=(question.id)))
Məhəmməd
ValueError at /polls/2/vote/ Field 'id' expected a number but got 'question_id'. Request Method: GET Request URL: http://127.0.0.1:8000/polls/2/vote/ Django Version: 3.1 Exception Type: ValueError Exception Value: Field 'id' expected a number but got 'question_id'. Exception Location: C:\Users\User\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\models\fields\__init__.py, line 1776, in get_prep_value Python Executable: C:\Users\User\AppData\Local\Programs\Python\Python38-32\python.exe Python Version: 3.8.5 Python Path: ['C:\\Users\\User\\Python Projects\\website', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python38-32\\lib', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python38-32', 'C:\\Users\\User\\AppData\\Roaming\\Python\\Python38\\site-packages', 'C:\\Users\\User\\AppData\\Local\\Programs\\Python\\Python38-32\\lib\\site-packages'] Server time: Thu, 20 Aug 2020 18:33:24 +0000
Məhəmməd
it says problem is in this line: question = get_object_or_404(Question, pk='question_id')
Anas
Any 1 did cascaded dropdown in Django?
Məhəmməd
it says problem is in this line: question = get_object_or_404(Question, pk='question_id')
I solved it. It might be pk=question_id instead of pk="question_id"
Josh
Hello Community version is free for download
Mike
Hello Community version is free for download
but i need for django framwwork and community version working django framework?
Never
I am porting from django 1.8 to django 3.1,i am having some problem with Middleware, systemcheckerror are shown,admun.E408,409,410,while i have done it right
Never
Anyone?plz
Alejandro
hi ... you know how i could export a pdf containing graphics
Alejandro
?
Alejandro
thanks
Stump Lowell
Hy
Stump Lowell
Please can I get some help here
Future
Please can I get some help here
you probably can if you write your problem in detail
Stump Lowell
Ok
Stump Lowell
I want to display a human readable error if a user try to log in with wrong credentials
Stump Lowell
Is not seeing the validation error I set on the forms.py Each time I put in wrong details it raise a value error instead Object dint return an http response return none instead
Anonymous
Happy day to you all
Anonymous
I am beginner. Is it good to learn Django alone or something with that. Like rest...
WhiteDevil
It is better to understand front end technologies such as React, Vuejs
Akash N
What are the changes required in html to connenct in mysql database in Django
Vishal
Pycharm can be downloaded for free community version from pycharm official website There is no requirement of license or crack to use community version it's sufficient to learn
Karthik
How slove type error
Georgi
How slove type error
By changing a type of variable probably. If you need float from int, you do float(variable_that_is_int) or vice versa- int(variable_that_is_float)
Velociraptor
Dear all,
Velociraptor
I want to add form that create child from the already opened parent page? parent-child[one to many relationship]
Velociraptor
how to do it?
Velociraptor
share links if there any ... or search key words.. i tried my level best but coulnt find relevant resources.
Gil
Hi!! About email to admins Django 3.1 I have configured DEFAULT_FROM_EMAIL, but seems that django.core.mail.mail_admins() no using it, says root@localhost Anyone with exerpience in that?
Дауран
hello i have such as issue un my django project , when i created 2 DetailView , AttributeError: type object 'Article' has no attribute '_default_manager'
Дауран
hello i have such as issue un my django project , when i created 2 DetailView , AttributeError: type object 'Article' has no attribute '_default_manager'
I have created 2 pages one of the news and for articles. which "news" page DetailView was worked but articles page DetailView was not worked
Manish
Hey, Can anyone help me with this:- https://pastebin.com/CTP7W4Dw
Manish
👆I am trying to display single data obeject on my webpage, without using any loop
Anonymous
Can someone send their own project which created by Django ?
Anonymous
I know it
Anonymous
But I am asking here
Anonymous
Among us
Anonymous
If they have
Mirco
what does it change ? maybe on GH you will find projects of someone that is here by yourself
Manish
https://stackoverflow.com/questions/63522446/how-to-access-specific-object-from-the-database-in-django-to-display-it-in-the-w
Manish
posts[0].title without iterating.
Nope doesn't work this way.
dexofan
Nope doesn't work this way.
objs.0.title in template should work
Mehmet
Is there an exception in Sqlite?because I have just tried here on MySQL and lazily executed with offset expression such below.
Mehmet
Item.objects.all()[2] creates sql below SELECT orderapi_item.id, orderapi_item.created_date, orderapi_item.last_updated_date, orderapi_item.transaction_id, orderapi_item.order_id, orderapi_item.item_type_id, orderapi_item.title, orderapi_item.description, orderapi_item.seller_user_id, orderapi_item.buyer_user_id, orderapi_item.listing_id, orderapi_item.creation_tsz, orderapi_item.price, orderapi_item.shipping_cost, orderapi_item.quantity, orderapi_item.product_data_base FROM orderapi_item LIMIT 1 OFFSET 2; args=()
Mehmet
I dont know whether sqlite supports OFFSET cursoring like above
Mehmet
Nope doesn't work this way.
What do you mean by does not work? Is it raising exception?
Manish
Yes, it's showing Django: TemplateSyntaxError: Could not parse the remainder......
Mehmet
Why dont you try to extract single row in view layer and by then send that with context?
Mehmet
Template layer is more error prune these kind of business logic overloading.
Mehmet
Extract all needed in view(like controllers on Java, .Net etc.) then send to presentation.
Raju
I'm new to djnago rest framework. this is my model: https://pastebin.com/fneJpAfW I'm trying to create a serializer. but i want to filter the category field with request.user and i want do it from serializer. that means the user who is creating new item only can see the category he added not all the category. Sorry for my broken English
Mehmet
Yeah if nothing works. i will prefer this way.
That is a definite best practice in MVC or MTV structures. There are some occasions such as Model.NotFound exceptions for these kind of offsetting. How do you plan to manage that on Template layer? Will you search a way to exception handling on the template?
Anonymous
I am going to make a website with payment functionality. Can I django it can be secure or not
Mr Intruder
Hey guys I'm doing a project in python and django but i don't know how to use OOP in that project if anyone is here for this problems solution...
Mr Intruder
Is there any good channel which you prefer?
anonymous
Anonymous
best solution
Yes I think so
Anonymous
Дауран
Github is full of projects
Where can I find any Django project with comments function
Дауран
I meant on articles or news blog
Anonymous
Mr Intruder
Anonymous
Ok thanks 🙏🏻
welcome ❤️
Anonymous
Mehdi
Hi whats the best video course until you are see for learning django?
Mehmet
need help payment functionality in django secure or not 😅
If you implement your payment functionality your own, it is a very detailed process, otherwise 3rd party payment providers will take the responsibility of security.
Mehmet
Every modern framework is able to fulfill all concerns about integrating payment functionality.
Mirco
need help payment functionality in django secure or not 😅
it's secure if you know what you do 😊