Posts by JonatasCD • 297 points
18 posts
-
1
votes1
answer84
viewsA: bs4: How to wrap an incomplete html code?
For that you will need the parser html5lib. pip install html5lib I tried on my console and this was the result: In [2]:import bs4 In [3]:content=''' <head> <title> my page </title>…
-
1
votes1
answer62
viewsA: What are the differences between using a . txt and . bat file in python?
There’s not much difference, I’d say. Especially in this context, I understand, create a log for your python code. That’s right? Anyway, in essence, the file would not even need to have extension,…
-
2
votes2
answers114
viewsA: Error creating a simple Django table?
I don’t know which tool you’re using to write your code, but most of them have a mechanism that helps you keep indenting correctly. For python, there are 4 spaces for each indentation level. So when…
-
0
votes1
answer682
viewsA: Login 2.0 Django, authentication
Maybe the problem is that your model Loginteste does not inherit from the basic classes of Django. If you are interested in having a custom template for your users, I suggest you refer to the…
-
0
votes1
answer55
viewsA: Errors in Django server validation?
By the traceback of errors you posted, you can see that you are using Python 3.6.x, correct? You did not specify which version of Django you are using, but anyway HTMLParseError was discontinued in…
-
2
votes2
answers280
viewsA: How to move multiple ZIP files at once with Python
I think you’re looking for shutil.move(): shutil.move("pasta/atual/seu.doc", "nova/pasta/seu.doc") Not only for files, but also for directories. I recommend a read on documentation.…
-
2
votes2
answers3768
viewsA: What is the equivalent of PHP explode in Python?
Using the very example of explode from the PHP documentation, you simply need to do pizza = "piece1 piece2 piece3 piece4 piece5 piece6" pizza.split(' ') ['piece1', 'piece2', 'piece3', 'piece4',…
-
1
votes2
answers723
viewsA: Autocomplete doesn’t always work on Pycharm
You installed the pygame, right? Have you checked that the python interpreter configuration is correct? I mean, are you pointing to the virtualenv or Docker you’re working on? In the interface…
-
1
votes1
answer114
viewsA: Web Crawler with Django’s view.py
According to the documentation of Django, the way to return an Object HttpResponse with a template and context: from django.http import HttpResponse from django.template import loader def…
-
0
votes2
answers3426
viewsA: Importing library in python
As @Haynesss commented, Pycharm indicates every time a variable or even an import is not used. It’s good practice. Anyway, as a bonus, it is always interesting to define which python interpreter you…
-
0
votes1
answer51
viewsA: Multilingual site
So, since you didn’t post your code, I’ll put a super basic based on Django 2.0.x In your file settings.py, you need to define the following values: LANGUAGE_CODE = 'en' USE_I18N = True LANGUAGES =…
-
0
votes1
answer108
viewsA: Django tests are not recognized
The name of the methods that are tests, should start with test_ Then it would look something like: from django.urls import reverse, resolve from django.test import TestCase from . import views #…
-
0
votes1
answer82
viewsA: How to click a checkbox when another obscure element is it?
It’s unclear to me why you can’t click this checkbox. It’s because it’s hidden or because it only appears based on other checkboxes? One solution that the QA team found in my work, was to create a…
-
2
votes1
answer179
viewsA: Python library
At the moment, much of the documentation is written in English. Some libraries already have initials to translate documentation into other languages, see Django, for example. If English is still a…
-
0
votes1
answer74
viewsA: Django admin line conditional background color fill
Here’s what I just tested in the Django 2.0.x admin from the Chrome console. Before, for every column of a field, Django adds a class in the format field-nomedocampo. This should render in html:…
-
0
votes1
answer119
viewsA: Grouping values in Django
One way to solve this could be. py.models class Grupo(models.Model): titulo = models.CharField(max_length=20) class Ferramenta(models.Model): titulo = models.CharField(max_length=20) grupo =…
-
0
votes1
answer327
viewsA: Display manytomany on list_display on Django
Maybe you’re looking for something like: def get_apensos(self, obj): return ", ".join([str(p) for p in obj.apensos.all()]) This is because I believe you want to list the appendages of the object…
-
0
votes1
answer284
viewsA: How to copy record with Detailview and picking up on pk (Django)
Given what you have exposed, I believe your url is something like site.com/entry/123. So your.py urls should be set to something like: url(r'^entry/(?P<entry_id>\d+)/$', entry, name='entry'),…