Posts by Vitor Freitas • 198 points
5 posts
-
1
votes1
answer635
viewsA: Django 2.0 - Amigavel Urls
Just a little adjustment in re_path, add the ^ to indicate regex start and mark regex string with r: re_path(r'^(?P<slug>[\w-]+)/$', views.details, name='details'), In your model, you can use…
-
1
votes1
answer102
viewsA: How to add methods to a Queryset?
You can extend the Model Manager and add a method of Queryset customized. See an example below where I added a filter for companies located in the Southeast and for SME companies: class…
-
1
votes1
answer507
viewsA: Django + AJAX - POST 404 (Not Found)
I believe it is a scope problem in Javascript. When you access $(this).attr('name'), the $(this) is referring to the method ajax and not to the element with ID #like. So what’s going on is that…
-
2
votes1
answer99
viewsA: Django 1.11. Serving robots.txt, sitemap, etc.
Generally the most correct is to delegate this task to Nginx or Apache, which in most cases will already be serving the static files of the project. If you are using Nginx, follow an example: server…
-
0
votes1
answer131
viewsA: How to create tuple with key receiving value?
Instead of returning a tuple, you can return a dictionary with the parameters you want to use in the filter. Then just expand the dictionary using **: def home(selected_page=None): _config =…