Mirco
I want mycid once it'll be printed in viewall definition I'll write logic.
print must be removed once you deploy on Prod so you can remove it
Mirco
Nope. in consol
you don't use it for your view logic so it's useless
Mirco
Just for testing purpose
testing what ? you don't use it at all
Mirco
it's like print(2) without a sense
Anonymous
I want to get mycid from template and use that in views and then forward it into next html page. For testing purpose I am printing that ID to consol. But it is not coming into views. I can not remove it. That's the problem.
Aman
Hi all, I need a help in creating recruiting job listing app... In which A Recruiter creates and maintains job listings. A candidate can view all the job listings and apply for a job that he is interested in.
shruti
It is showing no module names rest framework.authentication.?
Anonymous
It is showing no module names rest framework.authentication.?
Have you addded the app to the INSTALLED_APPS list in settings.py?
shruti
Yes
Anonymous
Yes
Try adding rest_framework.authtoken after rest_framework and before djoser in INSTALLED_APPS as per djoser documentation
Anonymous
This is if you are using token based authentication
Luciano
Hello!!! I'm using requests library to get a JSON response but I'm having a hard time trying to decode some strings like "MARAÃ\x83Â\x91ON" (MARAÑON, in spanish) I already tried setting some encoding/decoding but I'm confused about which decoding to use and how could I implement it. Thanks in advance!!!!
Luciano
Could your share the code? And what is the python interpreter version?
Sorry! headers = {'User-Agent': 'custom-valid-UA'} payload = {'format': 'json', 'data': data } response = requests.get(url, params=payload, headers=headers, timeout=3) I get a correct JSON response but some strings are encoded like that
Luciano
Python 3.7.4
Luciano
If you're getting correct json, then you should receive it by response.json()
Yes, it's a big JSON so I don't paste it here but the part I need to decode it's like this: {'apellido': 'MARAÃ\x91ON'}
Luciano
which should be decoded as "MARAÑON"
Alex
Yes, it's a big JSON so I don't paste it here but the part I need to decode it's like this: {'apellido': 'MARAÃ\x91ON'}
Let me make it clear - you're getting json decoded data and at some point you're having that undecoded string, am I right?
Luciano
Let me make it clear - you're getting json decoded data and at some point you're having that undecoded string, am I right?
Sorry for not being clear enough! Yes, I get a correct JSON response, with all key/value pair and with correct decoded strings BUT when it comes to characters like 'ñ, á, é, ó' etc(spanish or latin characters) it gets a bad encoding. Hope it makes sense to you
Luciano
well, if i try this: request.encoding, I get nothing. If i try request.apparent_encoding, I get utf-8
Luciano
Yes, it does. Are you sure that the api uses utf-8 encoding? Because it seems to me that it doesn't.
Also tried things like request.encoding = 'utf-8' (or latin-1, ISO... etc) and nothing happens
Vxvek
Do any use vps hosting with Godady with cpanel file manager to host django website?? Anyone can Any one help me with this.?
Alex
Also tried things like request.encoding = 'utf-8' (or latin-1, ISO... etc) and nothing happens
I'm sorry, but I cannot break it. I think that the problem is with the api's encoding. Guess it stores data in some non utf8 encoding but returns it in utf8 encoded json. You have to read their documentation or message their techsupport.
Luciano
I'm sorry, but I cannot break it. I think that the problem is with the api's encoding. Guess it stores data in some non utf8 encoding but returns it in utf8 encoded json. You have to read their documentation or message their techsupport.
I've just made it! test = json.dumps(response.json(), ensure_ascii=False).encode('latin-1') test.decode('utf-8') Now I get the "MARAÑON" correctly!!!! (don't know WHY!)
Alex
🤷🏻‍♂️😳
You did great any way.
Luciano
You did great any way.
Thanks! I guess this is one of those wtf moments where I don't know why it works but it does the job haha
Muhammed
Do i need to combine Django with React, Angular or Vue?
Mirco
Do i need to combine Django with React, Angular or Vue?
it's not a need, it depends on your project
edwin
hello good to all, I am making an e-commerce website in Django 3.1.1, but when I want to add an order in the admin I get the following error: str returned non-string (type NoneType). I already tried several methods but none works for me.
edwin
it tells me that the error is in this directory: AppData \ Local \ Programs \ Python \ Python38-32 \ Lib \ site-packages \ django \ forms \ models.py at line 1240
edwin
can someone help me I would appreciate it very much
Anonymous
do you have some __str__ method in models?
Alex
Anonymous
can you send a full traceback and code of str method
edwin
ok
edwin
class Order(models.Model): customer = models.ForeignKey(Customer, on_delete=models.CASCADE) date_orderd = models.DateTimeField(auto_now_add=True) complete = models.BooleanField(default=False, null=True, blank=False) transaction_id = models.CharField(max_length=200, null=True) def str(self): return str(self.transaction_id) + '-' + str(self.customer.name)
Anonymous
The problem may be that your str method returns a null field, I mean that transaction_id has null=True, and str returns some null field, just try to comment this method, and if error will go away, then you have some null field in models
Alex
@EdwinTzuc please, post that traceback on a paste service (pastebin or any other) and post here the link.
Anonymous
ok, so he have some models.ForeignKey, and may be that class returns null
Alex
https://pastebin.com/DQ9j75s8
I asked for the traceback, not the source code.
Expert
Hello! I need help I added some parts in template html base.html Something like this <span>{% trans 'Next Step' %}</span> But the text is not translated to Portuguese when I switch locale to Portugal, others are translated. How can I add that translation string and where?
Taku
Does anyone have experience with Google location APIs?
Андрей
Hello, how to get auth user in gjango?
Dan
Hello, how to get auth user in gjango?
Try django-allauth or django.contrib.auth.urls in urlpatterns
Андрей
thx
Sarjat
Does anyone has a solution for this? https://stackoverflow.com/questions/64560113/how-to-accept-all-the-answers-from-form
Anonymous
Hello I need help. I am working on a project. And I have setup on path in urls.py( it opens a home page and images are working fine) but when I clicked on a button on that html page, it calls a path in urls.py and take me to the other page. While coming to next page, my images are not coming. Issue is the path in urls.py came between the image path. Please suggest what I can do ? So that my images can come easily.
Anonymous
Help https://pastebin.pl/view/ba494418
Anonymous
how to do if some one comment on my site it will also show to other user on my site without refersh ?
Alex
Help https://pastebin.pl/view/ba494418
it failed to find a favicon. You may simply ignore this message
Alex
isn't it harmful?
It may harm your and someone's aestatic feeling. But not an app, I guess.
Taku
Does anyone have experience with Google location APIs?
Doragonsureiyā
Does anyone have experience with Google location APIs?
Your question is not related to Django. Please move to @PythonOfftopic group and ask there.
Usmonov M
Hello
Usmonov M
who know how can I make index.html after finishing my django project
Raj__Django
How to do same page navigation using id in django ? Means in navbar if contact us is there if we tap on contact us then it should go to contact us section at end of page
Raj__Django
Sorry it is some css issue
Rohan
I want to make a book store site where storemanager can upload books and customers can order and buy books.I want to authenticate who is storemanager and who is customer.I want to user django built in authentication system to authenticate these two users.Can any one suggest how to make this happen?
Rohan
Trying to understand Abstractuser, i just want to know whether some one faced the same issue.Thanks.