Django template inclusion issue
Hi,
being lost how include a template without that annoying newline added.
For example, separated and generalized logic for generating attributes for a html tag:
# templates/widgets/attrs.html
{% for name, value in attrs.items %} {{ name }}="{{ value|stringformat:'s' }}"{% endfor %}
When included in a parent template,
# widgets/list_widget_item.html
<li{% include "widgets/attrs.html" %}>List Item Element</li>
django renders it with unwanted newline
<li class="my-li-class"
>List Item Element</li>
Although valid and handled properly by most browsers, I'd like to get expected result instead of that compromise.
I've tried enclose inclusion with `spaceless` tag, however it removes *all* whitespace characters including (optional) leading space, not only the newline.
Any better solution to this straight and trivial demand ?
/r/django
https://redd.it/7fnv8c
Hi,
being lost how include a template without that annoying newline added.
For example, separated and generalized logic for generating attributes for a html tag:
# templates/widgets/attrs.html
{% for name, value in attrs.items %} {{ name }}="{{ value|stringformat:'s' }}"{% endfor %}
When included in a parent template,
# widgets/list_widget_item.html
<li{% include "widgets/attrs.html" %}>List Item Element</li>
django renders it with unwanted newline
<li class="my-li-class"
>List Item Element</li>
Although valid and handled properly by most browsers, I'd like to get expected result instead of that compromise.
I've tried enclose inclusion with `spaceless` tag, however it removes *all* whitespace characters including (optional) leading space, not only the newline.
Any better solution to this straight and trivial demand ?
/r/django
https://redd.it/7fnv8c
reddit
Django template inclusion issue • r/django
Hi, being lost how include a template without that annoying newline added. For example, separated and generalized logic for generating...
Django too complicated for someone like me?
I've been trying to create some sort of political quiz for a long, long while now.
I have little programming knowledge, although I've been using Python in not much depth for the past year.
My progress has been awfully slow, I haven't found the tutorials to be helpful at all and nobody else is really helping me in any depth... is it worth just giving up for now and returning to Django when I have more knowledge of Python?
All I've been trying to do is make a quiz, which has about 50 questions, all which have the options "Strongly Agree" to "Strongly Disagree" with a Neutral option. I wanted the result to be stored in some sort of database so they could be interpreted and a result be generated at the end.
I have gone from using two separate models like the Django tutorial have (Questions and Choices) to just one (Questions) that has the options hard coded into it... but I haven't been able to get those to show up anywhere (things jinja templating are completely lost on me)
/r/djangolearning
https://redd.it/7fesgx
I've been trying to create some sort of political quiz for a long, long while now.
I have little programming knowledge, although I've been using Python in not much depth for the past year.
My progress has been awfully slow, I haven't found the tutorials to be helpful at all and nobody else is really helping me in any depth... is it worth just giving up for now and returning to Django when I have more knowledge of Python?
All I've been trying to do is make a quiz, which has about 50 questions, all which have the options "Strongly Agree" to "Strongly Disagree" with a Neutral option. I wanted the result to be stored in some sort of database so they could be interpreted and a result be generated at the end.
I have gone from using two separate models like the Django tutorial have (Questions and Choices) to just one (Questions) that has the options hard coded into it... but I haven't been able to get those to show up anywhere (things jinja templating are completely lost on me)
/r/djangolearning
https://redd.it/7fesgx
reddit
Django too complicated for someone like me? • r/djangolearning
I've been trying to create some sort of political quiz for a long, long while now. I have little programming knowledge, although I've been using...
"The one thing that Python definitely does not want to be is a GENERAL purpose programming language." - GvR
http://ftp.ntua.gr/mirror/python/search/hypermail/python-1992/0001.html
/r/Python
https://redd.it/7fltpi
http://ftp.ntua.gr/mirror/python/search/hypermail/python-1992/0001.html
/r/Python
https://redd.it/7fltpi
reddit
"The one thing that Python definitely does not want to... • r/Python
139 points and 45 comments so far on reddit
is "Flask Web Development: Developing Web Applications with Python 1st edition" still readable or is too outdated?
this is the link for it on amazon,
https://www.amazon.com/Flask-Web-Development-Developing-Applications/dp/1449372627
I have it in print but don't know if it's worth the effort?
/r/flask
https://redd.it/7fq6es
this is the link for it on amazon,
https://www.amazon.com/Flask-Web-Development-Developing-Applications/dp/1449372627
I have it in print but don't know if it's worth the effort?
/r/flask
https://redd.it/7fq6es
When would I use Docker?
I’m currently work on 2 apps on my windows computer, using virtualenv and PostgreSQL. At some point I plan on deploying to the web. Where, I’m not sure. It might end up being my company’s webserver (I need web hosting in Canada which narrows the choices).
I just learned about Docker and I’m wondering if this type of tool is something I should start learning about and using? I’m not 100% sure of what Docker does so I’m just trying to figure out if it’s something I need to spend time on. Certainly the little bit I know makes it appealing: develop in a Docker container and then I’d be able to (more easily?) deploy my container and app to whatever webserver I choose.
/r/django
https://redd.it/7fokfz
I’m currently work on 2 apps on my windows computer, using virtualenv and PostgreSQL. At some point I plan on deploying to the web. Where, I’m not sure. It might end up being my company’s webserver (I need web hosting in Canada which narrows the choices).
I just learned about Docker and I’m wondering if this type of tool is something I should start learning about and using? I’m not 100% sure of what Docker does so I’m just trying to figure out if it’s something I need to spend time on. Certainly the little bit I know makes it appealing: develop in a Docker container and then I’d be able to (more easily?) deploy my container and app to whatever webserver I choose.
/r/django
https://redd.it/7fokfz
reddit
When would I use Docker? • r/django
I’m currently work on 2 apps on my windows computer, using virtualenv and PostgreSQL. At some point I plan on deploying to the web. Where, I’m not...
Implementing a Neural Network from Scratch in Python – An Introduction
https://www.datasciencecentral.com/profiles/blogs/implementing-a-neural-network-from-scratch-in-python-an
/r/Python
https://redd.it/7fq5ss
https://www.datasciencecentral.com/profiles/blogs/implementing-a-neural-network-from-scratch-in-python-an
/r/Python
https://redd.it/7fq5ss
Datasciencecentral
Implementing a Neural Network from Scratch in Python – An Introduction
This article was written by Denny Britz.
In this post we will implement a simple 3-layer neural network from scratch. We won’t derive all the math that’s requi…
In this post we will implement a simple 3-layer neural network from scratch. We won’t derive all the math that’s requi…
What kind of projects do you use Django for?
https://www.reddit.com/r/django/comments/7b36b8/what_kind_of_projects_do_you_use_django_for/
/r/djangolearning
https://redd.it/7fse3v
https://www.reddit.com/r/django/comments/7b36b8/what_kind_of_projects_do_you_use_django_for/
/r/djangolearning
https://redd.it/7fse3v
reddit
What kind of projects do you use Django for? • r/django
Hola! In which of the following contexts do you use the Django web framework? 1. Bootstrapped business websites (e.g. eCommerce, SaaS, etc) 2....
[R] StarGAN: Unified Generative Adversarial Networks for Multi-Domain Image-to-Image Translation
/r/MachineLearning
https://redd.it/7fro3g
/r/MachineLearning
https://redd.it/7fro3g
Python Guess The Number Game
Just made my first real app in python and was wondering if anyone wanted to give some feedback on it. All is appreciated!
Code:
import random
# Prints credits
print("\t\t\tGuess The Number")
print("\t\t\t \\ \\ \\ \\ \\ \\ \\ \\")
print("\t\t\t\tby")
print("\t\t\t Brook Jeynes")
print("\t\t\t \\ \\ \\ \\ \\ \\")
# Setting values
number_of_guesses = 3
computer_choice = random.randint(1,10)
# Testing number choice
while number_of_guesses != 0:
user_choice = int(input("\nI'm thinking of a number
between 1 and 10:\n"))
# If you guess the number print VVV
if user_choice == computer_choice:
print("Congratulations, you guessed my number")
print("My number was", computer_choice)
number_of_guesses = number_of_guesses - 1
print("You had", number_of_guesses, "guesses left")
number_of_guesses = number_of_guesses + 1
break
# If you didn't guess the number print VVV
elif user_choice != computer_choice:
print("You did not guess my number:\n")
if user_choice > computer_choice:
print("Your guess is too high. Guess lower...")
elif user_choice < computer_choice:
print("Your guess is too low. Guess higher...")
number_of_guesses = number_of_guesses - 1
print("You have", number_of_guesses, "guesses
left")
# Test number of guesses
if number_of_guesses == 0:
print("""
_______ _______ _______ _______ _______ _______ _______
( ____ \( ___ )( )( ____ \ ( ___ )|\ /|( ____ \( ____ )
| ( \/| ( ) || () () || ( \/ | ( ) || ) ( || ( \/| ( )|
| | | (___) || || || || (__ | | | || | | || (__ | (____)|
| | ____ | ___ || |(_)| || __) | | | |( ( ) )| __) | __)
| | \_ )| ( ) || | | || ( | | | | \ \_/ / | ( | (\ (
| (___) || ) ( || ) ( || (____/\ | (___) | \ / | (____/\| ) \ \__
(_______)|/ \||/ \|(_______/ (_______) \_/ (_______/|/ \__/
""")
print("You did not guess my number")
print("My number was", computer_choice)
/r/Python
https://redd.it/7ftn3c
Just made my first real app in python and was wondering if anyone wanted to give some feedback on it. All is appreciated!
Code:
import random
# Prints credits
print("\t\t\tGuess The Number")
print("\t\t\t \\ \\ \\ \\ \\ \\ \\ \\")
print("\t\t\t\tby")
print("\t\t\t Brook Jeynes")
print("\t\t\t \\ \\ \\ \\ \\ \\")
# Setting values
number_of_guesses = 3
computer_choice = random.randint(1,10)
# Testing number choice
while number_of_guesses != 0:
user_choice = int(input("\nI'm thinking of a number
between 1 and 10:\n"))
# If you guess the number print VVV
if user_choice == computer_choice:
print("Congratulations, you guessed my number")
print("My number was", computer_choice)
number_of_guesses = number_of_guesses - 1
print("You had", number_of_guesses, "guesses left")
number_of_guesses = number_of_guesses + 1
break
# If you didn't guess the number print VVV
elif user_choice != computer_choice:
print("You did not guess my number:\n")
if user_choice > computer_choice:
print("Your guess is too high. Guess lower...")
elif user_choice < computer_choice:
print("Your guess is too low. Guess higher...")
number_of_guesses = number_of_guesses - 1
print("You have", number_of_guesses, "guesses
left")
# Test number of guesses
if number_of_guesses == 0:
print("""
_______ _______ _______ _______ _______ _______ _______
( ____ \( ___ )( )( ____ \ ( ___ )|\ /|( ____ \( ____ )
| ( \/| ( ) || () () || ( \/ | ( ) || ) ( || ( \/| ( )|
| | | (___) || || || || (__ | | | || | | || (__ | (____)|
| | ____ | ___ || |(_)| || __) | | | |( ( ) )| __) | __)
| | \_ )| ( ) || | | || ( | | | | \ \_/ / | ( | (\ (
| (___) || ) ( || ) ( || (____/\ | (___) | \ / | (____/\| ) \ \__
(_______)|/ \||/ \|(_______/ (_______) \_/ (_______/|/ \__/
""")
print("You did not guess my number")
print("My number was", computer_choice)
/r/Python
https://redd.it/7ftn3c
reddit
Python Guess The Number Game • r/Python
Just made my first real app in python and was wondering if anyone wanted to give some feedback on it. All is appreciated! Code: import...
Need help with passing href parameters!
So I'm having trouble with passing an argument through href. I'm using twitter api and trying to return info on users, but it's returning nothing. What am I doing wrong in the view?
base.html:
<a href="{% url 'users' get_user=search.user.screen_name %}" class="user-profile" name="user">
urls.py:
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^$', views.index, name='views'),
url(r'^user/(?P<get_user>\w+)', views.user, name='users'),
views.py:
def index(request):
if request.GET.get('get_user', None):
user_search = request.GET.get('get_user', None)
get_user = api.GetUser(user_id=None, screen_name=user_search)
return render(request, 'scrape/user/users.html', {'get_user': get_user})
trends = api.GetTrendsCurrent(exclude=None)
searches = api.GetSearch(term='moments', raw_query=None, geocode=None, since_id=None,
max_id=None, until=None, since=None, count=30,
lang=None, locale=None, result_type="popular", include_entities=None)
return render(request, 'scrape/base.html', {'trends': trends, 'searches': searches})
def user(request, get_user):
return render(request, 'scrape/user/users.html', {'get_user': get_user})
/r/django
https://redd.it/7fsm87
So I'm having trouble with passing an argument through href. I'm using twitter api and trying to return info on users, but it's returning nothing. What am I doing wrong in the view?
base.html:
<a href="{% url 'users' get_user=search.user.screen_name %}" class="user-profile" name="user">
urls.py:
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^$', views.index, name='views'),
url(r'^user/(?P<get_user>\w+)', views.user, name='users'),
views.py:
def index(request):
if request.GET.get('get_user', None):
user_search = request.GET.get('get_user', None)
get_user = api.GetUser(user_id=None, screen_name=user_search)
return render(request, 'scrape/user/users.html', {'get_user': get_user})
trends = api.GetTrendsCurrent(exclude=None)
searches = api.GetSearch(term='moments', raw_query=None, geocode=None, since_id=None,
max_id=None, until=None, since=None, count=30,
lang=None, locale=None, result_type="popular", include_entities=None)
return render(request, 'scrape/base.html', {'trends': trends, 'searches': searches})
def user(request, get_user):
return render(request, 'scrape/user/users.html', {'get_user': get_user})
/r/django
https://redd.it/7fsm87
reddit
Need help with passing href parameters! • r/django
So I'm having trouble with passing an argument through href. I'm using twitter api and trying to return info on users, but it's returning nothing....
New Twilio site built on Django and Vue
https://www.twilio.com/blog/2017/11/building-twilioquest-with-twilio-sync-django-and-vue-js.html
/r/django
https://redd.it/7fui9e
https://www.twilio.com/blog/2017/11/building-twilioquest-with-twilio-sync-django-and-vue-js.html
/r/django
https://redd.it/7fui9e
Twilio Blog
Building TwilioQuest with Twilio Sync, Django, and Vue.js
Learn how Twilio built the gamified training experience TwilioQuest using Python, Django, Wagtail, Vue.js, and Twilio Sync. Ready player 1!
Flask support for gentelella bootstrap template
https://github.com/afourmy/flask-gentelella
/r/flask
https://redd.it/7fvwwi
https://github.com/afourmy/flask-gentelella
/r/flask
https://redd.it/7fvwwi
GitHub
GitHub - afourmy/flask-gentelella: Gentelella template powered by Flask
Gentelella template powered by Flask. Contribute to afourmy/flask-gentelella development by creating an account on GitHub.
3x faster than Flask; Quart as a upgrade to Flask
https://medium.com/@pgjones/3x-faster-than-flask-8e89bfbe8e4f
/r/Python
https://redd.it/7fva42
https://medium.com/@pgjones/3x-faster-than-flask-8e89bfbe8e4f
/r/Python
https://redd.it/7fva42
Hacker Noon
3x faster Flask apps
With minimal effort
What are the benefits of using Django to create a website as opposed to using something like WordPress?
/r/djangolearning
https://redd.it/7fpmcp
/r/djangolearning
https://redd.it/7fpmcp
reddit
What are the benefits of using Django to create... • r/djangolearning
2 points and 7 comments so far on reddit
A general query about django / javascript patterns and how to best organize/encapsulate
I am currently coding webapps in django and using a bit of javascript to do this and that. Naturally, I sometimes want my javascript apps from knowing the context of my Django template, so the way I've been doing it is hardcoding the js into the .html file.
Example
<script>
var my_var = {{ my_var_from_context }}
Clearly this is ugly as all hell as it forces me to keep my javascript code inside of the .html file. I'd like to make my .js file separate and load it.
Clearly thee are some options like write a function that takes arguments that can be captured in the template then passed.
e.g.
var my_var = {{ my_django_var }}
myFunctionFromScript(my_var)
Is this the best way to be doing this? Is there a better pattern? What are others doing?
Thanks for your help.
-Joe
/r/django
https://redd.it/7fwzqk
I am currently coding webapps in django and using a bit of javascript to do this and that. Naturally, I sometimes want my javascript apps from knowing the context of my Django template, so the way I've been doing it is hardcoding the js into the .html file.
Example
<script>
var my_var = {{ my_var_from_context }}
Clearly this is ugly as all hell as it forces me to keep my javascript code inside of the .html file. I'd like to make my .js file separate and load it.
Clearly thee are some options like write a function that takes arguments that can be captured in the template then passed.
e.g.
var my_var = {{ my_django_var }}
myFunctionFromScript(my_var)
Is this the best way to be doing this? Is there a better pattern? What are others doing?
Thanks for your help.
-Joe
/r/django
https://redd.it/7fwzqk
reddit
A general query about django / javascript patterns and... • r/django
I am currently coding webapps in django and using a bit of javascript to do this and that. Naturally, I sometimes want my javascript apps from...
Paypal, Django, Local Bank, Integration
I'm thinking about making a web system where people can send me money through their local bank account for buying an online item and I'll buy them that item using my paypal account. So this would be 2 step process. At first they will send me money through their local account and then I'll convert that money into paypal dollars and use those dollars to buy that item for them. I want to know is that possible and if it is, then from where should I start?
/r/djangolearning
https://redd.it/7etabj
I'm thinking about making a web system where people can send me money through their local bank account for buying an online item and I'll buy them that item using my paypal account. So this would be 2 step process. At first they will send me money through their local account and then I'll convert that money into paypal dollars and use those dollars to buy that item for them. I want to know is that possible and if it is, then from where should I start?
/r/djangolearning
https://redd.it/7etabj
reddit
Paypal, Django, Local Bank, Integration • r/djangolearning
I'm thinking about making a web system where people can send me money through their local bank account for buying an online item and I'll buy them...
Best API for scheduled tasks currently?
I need to set up automatic scheduled tasks. The tasks are pretty simple, like set `is_active_subscriber` to `False` when a user's subscription ends and auto-renewal is off.
I'm aware of cron, but I see that it hasn't been updated for a few years. For simple scheduled tasks, what API is the best option right now?
Thanks.
P.S. I'm building a MVP so I'll be expecting only a small amount of traffic when I first go live. So whatever method I end up using, it should be sufficiently scalable.
/r/django
https://redd.it/7fzled
I need to set up automatic scheduled tasks. The tasks are pretty simple, like set `is_active_subscriber` to `False` when a user's subscription ends and auto-renewal is off.
I'm aware of cron, but I see that it hasn't been updated for a few years. For simple scheduled tasks, what API is the best option right now?
Thanks.
P.S. I'm building a MVP so I'll be expecting only a small amount of traffic when I first go live. So whatever method I end up using, it should be sufficiently scalable.
/r/django
https://redd.it/7fzled
reddit
Best API for scheduled tasks currently? • r/django
I need to set up automatic scheduled tasks. The tasks are pretty simple, like set `is_active_subscriber` to `False` when a user's subscription...
I'm releasing a free code for the "Automate the Boring Stuff with Python" Udemy course
Use this link to sign up for the "Automate the Boring Stuff with Python" Udemy online course: https://www.udemy.com/automate/?couponCode=PY_ALL_THE_THINGS
It's free until the end of Friday, Dec 1, 2017. Afterwards it goes back to its normal $50 price. (Though you can use this link https://www.udemy.com/automate/?couponCode=FOR_LIKE_10_BUCKS to buy it for $10. And it's an open secret that if you browse Udemy in privacy mode, they'll show you the discount price to lure in a "new" customer. But course creators get a much larger cut when people use their referral codes.)
The course follows the book of the same name, which is available for free, in full, at https://automatetheboringstuff.com under a Creative Commons license. ([Which I encourage you to use to share your own creative works.](https://creativecommons.org/licenses/))
The course is 50 videos and made for people with no previous programming experience. The first 15 videos are free to view on YouTube: https://www.youtube.com/watch?v=1F_OgqRuSdI&list=PL0-84-yl1fUnRuXGFe_F7qSH1LEnn9LkW
And now I will go self-flagellate to atone for my part in legitimizing "cyber monday".
/r/Python
https://redd.it/7fxp46
Use this link to sign up for the "Automate the Boring Stuff with Python" Udemy online course: https://www.udemy.com/automate/?couponCode=PY_ALL_THE_THINGS
It's free until the end of Friday, Dec 1, 2017. Afterwards it goes back to its normal $50 price. (Though you can use this link https://www.udemy.com/automate/?couponCode=FOR_LIKE_10_BUCKS to buy it for $10. And it's an open secret that if you browse Udemy in privacy mode, they'll show you the discount price to lure in a "new" customer. But course creators get a much larger cut when people use their referral codes.)
The course follows the book of the same name, which is available for free, in full, at https://automatetheboringstuff.com under a Creative Commons license. ([Which I encourage you to use to share your own creative works.](https://creativecommons.org/licenses/))
The course is 50 videos and made for people with no previous programming experience. The first 15 videos are free to view on YouTube: https://www.youtube.com/watch?v=1F_OgqRuSdI&list=PL0-84-yl1fUnRuXGFe_F7qSH1LEnn9LkW
And now I will go self-flagellate to atone for my part in legitimizing "cyber monday".
/r/Python
https://redd.it/7fxp46
Udemy
Automate the Boring Stuff with Python Programming
A practical programming course for office workers, academics, and administrators who want to improve their productivity.
Free Python Games - Basic Python Games for Beginners
http://www.grantjenks.com/docs/freegames/
/r/Python
https://redd.it/7fzu88
http://www.grantjenks.com/docs/freegames/
/r/Python
https://redd.it/7fzu88
Using Python’s Pathlib Module - Practical Business Python
http://pbpython.com/pathlib-intro.html
/r/Python
https://redd.it/7fzvhj
http://pbpython.com/pathlib-intro.html
/r/Python
https://redd.it/7fzvhj
Pbpython
Using Python’s Pathlib Module
Using python's pathlib module.