Enabling the Flask Interactive Debugger in Development with gunicorn
https://nickjanetakis.com/blog/enabling-the-flask-interactive-debugger-in-development-with-gunicorn
/r/flask
https://redd.it/8n07ad
https://nickjanetakis.com/blog/enabling-the-flask-interactive-debugger-in-development-with-gunicorn
/r/flask
https://redd.it/8n07ad
Nick Janetakis
Enabling the Flask Interactive Debugger in Development with gunicorn
I'm a big fan of setting up my development environment to be the same as production. That means running gunicorn in dev mode.
Tutorial notebooks for demonstrating Jupyter capabilities?
My group at work has set up a JupyterHub instance for researchers in our office to use. There's a meeting tomorrow where my boss has asked me to talk to some of the other managers about what Jupyter is and why it's needed. Are there any good notebooks out there that can demonstrate some of the features of JupyterHub and Jupyter notebooks in ways that are easy for potentially non-technical people to understand?
/r/IPython
https://redd.it/8n09dy
My group at work has set up a JupyterHub instance for researchers in our office to use. There's a meeting tomorrow where my boss has asked me to talk to some of the other managers about what Jupyter is and why it's needed. Are there any good notebooks out there that can demonstrate some of the features of JupyterHub and Jupyter notebooks in ways that are easy for potentially non-technical people to understand?
/r/IPython
https://redd.it/8n09dy
reddit
Tutorial notebooks for demonstrating Jupyter capabilities? • r/IPython
My group at work has set up a JupyterHub instance for researchers in our office to use. There's a meeting tomorrow where my boss has asked me to...
Need HELP with building Recommender systems (using python)
Hello there! I am new to this amazing world of Machine Learning and have just completed Andrew NG's course in it. I want to get my hands dirty and build a Movies Recommender Systems from scratch. I searched a lot and most of the websites I landed on gave results using libraries in python which made the task extremely easy. My question is can we build such a system without using any library? (I mean not using libraries like sci-kit learn, surprise, numpy etc. )
Please help me out here.
/r/pystats
https://redd.it/8mzncv
Hello there! I am new to this amazing world of Machine Learning and have just completed Andrew NG's course in it. I want to get my hands dirty and build a Movies Recommender Systems from scratch. I searched a lot and most of the websites I landed on gave results using libraries in python which made the task extremely easy. My question is can we build such a system without using any library? (I mean not using libraries like sci-kit learn, surprise, numpy etc. )
Please help me out here.
/r/pystats
https://redd.it/8mzncv
reddit
Need HELP with building Recommender systems (using python) • r/pystats
Hello there! I am new to this amazing world of Machine Learning and have just completed Andrew NG's course in it. I want to get my hands dirty and...
CreateView and inlineformset_factory use with junction table
I'm trying to expand the use of the official django tutorial which builds a voting app. At the moment what I'm trying to do is to allow a user to create a poll, input the poll name, the poll options and invite the users he wants by email from the already registered users. In order to do that I have created a junction table called `EligibleVoters` with foreign keys to the `Poll` table and the `auth_user` table
my `model.py`:
class Poll(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published', auto_now_add=True)
is_active = models.BooleanField(default=True)
activation_date = models.DateTimeField('Activation Date', blank=True, null=True)
expiration_date = models.DateTimeField('Expiration Date', blank=True, null=True)
public_key = models.CharField(max_length=30, blank=True)
hash = models.CharField(max_length=128, blank=True)
timestamp = models.DateTimeField(auto_now=True)
def __str__(self):
return self.question_text
def was_published_recently(self):
now = timezone.now()
return now - datetime.timedelta(days=1) <= self.pub_date <= now
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'
class Choice(models.Model):
question = models.ForeignKey(Poll, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str__(self):
return self.choice_text
class EligibleVoters(models.Model):
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
poll = models.ForeignKey(Poll, on_delete=models.CASCADE)
email = models.EmailField(null=True)
my `forms.py`:
from django.forms import ModelForm, inlineformset_factory
from django import forms
from .models import Poll, Choice, EligibleVoters, PollKeyPart, User
class PollForm(ModelForm):
activation_date = forms.DateTimeField(required=False)
expiration_date = forms.DateTimeField(required=False)
class Meta:
model = Poll
fields = ['question_text', 'is_active', 'activation_date', 'expiration_date']
class ChoiceForm(ModelForm):
class Meta:
model = Choice
exclude = ()
ChoiceFormSet = inlineformset_factory(Poll, Choice, form=ChoiceForm, extra=1)
class EligibleVotersForm(ModelForm):
class Meta:
model = EligibleVoters
fields = ['email']
EligibleVotersFormSetPoll = inlineformset_factory(Poll, EligibleVoters, form=EligibleVotersForm, extra=1)
EligibleVotersFormSetUser = inlineformset_factory(User, EligibleVoters, form=EligibleVotersForm, extra=1)
my `views.py`:
class NewPoll(CreateView):
model = Poll
fields = ['question_text', 'is_active', 'activation_date', 'expiration_date']
success_url = reverse_lazy('voting:index')
def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
if self.request.POST:
data['choices'] = ChoiceFormSet(self.request.POST)
data['eligible_voters_poll'] = EligibleVotersFormSetPoll(self.request.POST)
data['eligible_voters_user'] = EligibleVotersFormSetUser(self.request.POST)
else:
data['choices'] = ChoiceFormSet()
data['eligible_voters_poll'] = EligibleVotersFormSetPoll()
data['eligible_voters_user'] = EligibleVotersFormSetUser()
return data
def form_valid(self, form):
context = self.get_context_data()
choices = context['choices']
eligible_voters_poll = context['eligible_voters_poll']
eligible_vot
I'm trying to expand the use of the official django tutorial which builds a voting app. At the moment what I'm trying to do is to allow a user to create a poll, input the poll name, the poll options and invite the users he wants by email from the already registered users. In order to do that I have created a junction table called `EligibleVoters` with foreign keys to the `Poll` table and the `auth_user` table
my `model.py`:
class Poll(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published', auto_now_add=True)
is_active = models.BooleanField(default=True)
activation_date = models.DateTimeField('Activation Date', blank=True, null=True)
expiration_date = models.DateTimeField('Expiration Date', blank=True, null=True)
public_key = models.CharField(max_length=30, blank=True)
hash = models.CharField(max_length=128, blank=True)
timestamp = models.DateTimeField(auto_now=True)
def __str__(self):
return self.question_text
def was_published_recently(self):
now = timezone.now()
return now - datetime.timedelta(days=1) <= self.pub_date <= now
was_published_recently.admin_order_field = 'pub_date'
was_published_recently.boolean = True
was_published_recently.short_description = 'Published recently?'
class Choice(models.Model):
question = models.ForeignKey(Poll, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str__(self):
return self.choice_text
class EligibleVoters(models.Model):
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
poll = models.ForeignKey(Poll, on_delete=models.CASCADE)
email = models.EmailField(null=True)
my `forms.py`:
from django.forms import ModelForm, inlineformset_factory
from django import forms
from .models import Poll, Choice, EligibleVoters, PollKeyPart, User
class PollForm(ModelForm):
activation_date = forms.DateTimeField(required=False)
expiration_date = forms.DateTimeField(required=False)
class Meta:
model = Poll
fields = ['question_text', 'is_active', 'activation_date', 'expiration_date']
class ChoiceForm(ModelForm):
class Meta:
model = Choice
exclude = ()
ChoiceFormSet = inlineformset_factory(Poll, Choice, form=ChoiceForm, extra=1)
class EligibleVotersForm(ModelForm):
class Meta:
model = EligibleVoters
fields = ['email']
EligibleVotersFormSetPoll = inlineformset_factory(Poll, EligibleVoters, form=EligibleVotersForm, extra=1)
EligibleVotersFormSetUser = inlineformset_factory(User, EligibleVoters, form=EligibleVotersForm, extra=1)
my `views.py`:
class NewPoll(CreateView):
model = Poll
fields = ['question_text', 'is_active', 'activation_date', 'expiration_date']
success_url = reverse_lazy('voting:index')
def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
if self.request.POST:
data['choices'] = ChoiceFormSet(self.request.POST)
data['eligible_voters_poll'] = EligibleVotersFormSetPoll(self.request.POST)
data['eligible_voters_user'] = EligibleVotersFormSetUser(self.request.POST)
else:
data['choices'] = ChoiceFormSet()
data['eligible_voters_poll'] = EligibleVotersFormSetPoll()
data['eligible_voters_user'] = EligibleVotersFormSetUser()
return data
def form_valid(self, form):
context = self.get_context_data()
choices = context['choices']
eligible_voters_poll = context['eligible_voters_poll']
eligible_vot
ers_user = context['eligible_voters_user']
with transaction.atomic():
self.object = form.save()
if choices.is_valid():
choices.instance = self.object
choices.save()
if eligible_voters_poll.is_valid() and eligible_voters_user.is_valid():
eligible_voters_poll.instance = self.object
eligible_voters_poll.save()
eligible_voters_user.instance = self.object
eligible_voters_user.save()
return super().form_valid(form)
And my html file:
{% extends 'base.html' %}
{% block content %}
{% load static %}
<h2>Poll Creation</h2>
<div class="col-md-4">
<form action='' method="post">
{% csrf_token %}
{{ form.as_p }}
<table class="table">
{{ choices.management_form }}
{% for form in choices.forms %}
{% if forloop.first %}
<thead>
<tr>
{% for field in form.visible_fields %}
<th>{{ field.label|capfirst }}</th>
{% endfor %}
</tr>
</thead>
{% endif %}
<tr class="{% cycle row1 row2 %} formset_row1">
{% for field in form.visible_fields %}
<td>
{% if forloop.first %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% endif %}
{{ field.errors.as_ul }}
{{ field }}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
<table class="table">
{{ eligible_voters_poll.management_form }}
{% for form in eligible_voters_poll.forms %}
{% if forloop.first %}
<thead>
<tr>
{% for field in form.visible_fields %}
<th>{{ field.label|capfirst }}</th>
{% endfor %}
</tr>
</thead>
{% endif %}
<tr class="{% cycle row1 row2 %} formset_row2">
{% for field in form.visible_fields %}
<td>
{% if forloop.first %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% endif %}
{{ field.errors.as_ul }}
{{ field }}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
<input type="submit" value="Save"/> <a href="{% url 'voting:index' %}">back to the list</a>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="{% static 'voting/js/jquery.formset.js' %}"></script>
<script type="text/javascript">
$('.formset_row1').formset({
addText: 'add poll choice',
deleteText: 'remove',
prefix: 'Choice_set'
});
$('.formset_row2').formset({
addText: 'add eligible voter',
deleteText: 'remove',
prefix: 'EligibleVoters_set'
});
</script>
{% endblock %}
If I don't include the `EligibleVotersFormSetUser` the code works but the `user_id` in the `EligibleVoters` table remains null. If I include the `EligibleVotersFormSetUser` the
with transaction.atomic():
self.object = form.save()
if choices.is_valid():
choices.instance = self.object
choices.save()
if eligible_voters_poll.is_valid() and eligible_voters_user.is_valid():
eligible_voters_poll.instance = self.object
eligible_voters_poll.save()
eligible_voters_user.instance = self.object
eligible_voters_user.save()
return super().form_valid(form)
And my html file:
{% extends 'base.html' %}
{% block content %}
{% load static %}
<h2>Poll Creation</h2>
<div class="col-md-4">
<form action='' method="post">
{% csrf_token %}
{{ form.as_p }}
<table class="table">
{{ choices.management_form }}
{% for form in choices.forms %}
{% if forloop.first %}
<thead>
<tr>
{% for field in form.visible_fields %}
<th>{{ field.label|capfirst }}</th>
{% endfor %}
</tr>
</thead>
{% endif %}
<tr class="{% cycle row1 row2 %} formset_row1">
{% for field in form.visible_fields %}
<td>
{% if forloop.first %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% endif %}
{{ field.errors.as_ul }}
{{ field }}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
<table class="table">
{{ eligible_voters_poll.management_form }}
{% for form in eligible_voters_poll.forms %}
{% if forloop.first %}
<thead>
<tr>
{% for field in form.visible_fields %}
<th>{{ field.label|capfirst }}</th>
{% endfor %}
</tr>
</thead>
{% endif %}
<tr class="{% cycle row1 row2 %} formset_row2">
{% for field in form.visible_fields %}
<td>
{% if forloop.first %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% endif %}
{{ field.errors.as_ul }}
{{ field }}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
<input type="submit" value="Save"/> <a href="{% url 'voting:index' %}">back to the list</a>
</form>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="{% static 'voting/js/jquery.formset.js' %}"></script>
<script type="text/javascript">
$('.formset_row1').formset({
addText: 'add poll choice',
deleteText: 'remove',
prefix: 'Choice_set'
});
$('.formset_row2').formset({
addText: 'add eligible voter',
deleteText: 'remove',
prefix: 'EligibleVoters_set'
});
</script>
{% endblock %}
If I don't include the `EligibleVotersFormSetUser` the code works but the `user_id` in the `EligibleVoters` table remains null. If I include the `EligibleVotersFormSetUser` the
code gives me a `"EligibleVoters.user" must be a "User" instance.`
error. Somehow I need to associate each entry with the corresponding user\_id. What is the best way to do that?I got to where I am now by following [this tutorial](https://medium.com/@adandan01/django-inline-formsets-example-mybook-420cc4b6225d). Also I would like to add validation to the email field of the form in order for the user to be able to invite only registered users.
/r/django
https://redd.it/8n18li
error. Somehow I need to associate each entry with the corresponding user\_id. What is the best way to do that?I got to where I am now by following [this tutorial](https://medium.com/@adandan01/django-inline-formsets-example-mybook-420cc4b6225d). Also I would like to add validation to the email field of the form in order for the user to be able to invite only registered users.
/r/django
https://redd.it/8n18li
Medium
Django Inline formsets example: mybook
Recently I needed to use django formset for a work project. Django formset allows you to edit a collection of the same forms on the same…
Server side caching using django cache framework
I am trying to cache my API response for a particular url using django cache framework and storing the cache in database. I am trying to cache the response for all the users who visit the particular page. I want it to be client independent. I have written a middleware to remove cookie from the request header because django cache uses url \+ cookie \+ other details to create cache key.
The cache is working on the user basis i.e. when a user hits the url it caches the response for that particular user only.
How can I use the same cache for all the users?
P.S: I have already set no\-cache for the client.
/r/django
https://redd.it/8my935
I am trying to cache my API response for a particular url using django cache framework and storing the cache in database. I am trying to cache the response for all the users who visit the particular page. I want it to be client independent. I have written a middleware to remove cookie from the request header because django cache uses url \+ cookie \+ other details to create cache key.
The cache is working on the user basis i.e. when a user hits the url it caches the response for that particular user only.
How can I use the same cache for all the users?
P.S: I have already set no\-cache for the client.
/r/django
https://redd.it/8my935
reddit
r/django - Server side caching using django cache framework
6 votes and 2 so far on reddit
Calling an api from a different blueprint
I currently have two blueprints. I was wondering if there was a simple way to call an api from the second blueprint in the first blueprint aside from just explicitly calling it (if that's the answer, that's great too... I just want to make sure I am doing things the *correct* way).
bp1.py
@bp.route('/foo', methods=('GET',))
def foo():
do_something()
post_to_bar()
bp2.py
@bp.route('/bar', methods=('GET', 'POST'))
def bar():
if request.method() == 'POST':
do_something_else()
/r/flask
https://redd.it/8n2epo
I currently have two blueprints. I was wondering if there was a simple way to call an api from the second blueprint in the first blueprint aside from just explicitly calling it (if that's the answer, that's great too... I just want to make sure I am doing things the *correct* way).
bp1.py
@bp.route('/foo', methods=('GET',))
def foo():
do_something()
post_to_bar()
bp2.py
@bp.route('/bar', methods=('GET', 'POST'))
def bar():
if request.method() == 'POST':
do_something_else()
/r/flask
https://redd.it/8n2epo
reddit
Calling an api from a different blueprint • r/flask
I currently have two blueprints. I was wondering if there was a simple way to call an api from the second blueprint in the first blueprint aside...
Using custom model managers
I have been learning Django for over 1 year now, although most of my time is spent with html and css.
I am using Django 1.11.
I have read about custom model managers before but I considered them a little advanced for that time.
Recently, I have started reading about them.
In my current case I think that they would help me with filtering.
So, what's your use case for custom model managers ?
Do they make the code cleaner and/or improve performance ?
/r/django
https://redd.it/8n4txc
I have been learning Django for over 1 year now, although most of my time is spent with html and css.
I am using Django 1.11.
I have read about custom model managers before but I considered them a little advanced for that time.
Recently, I have started reading about them.
In my current case I think that they would help me with filtering.
So, what's your use case for custom model managers ?
Do they make the code cleaner and/or improve performance ?
/r/django
https://redd.it/8n4txc
reddit
r/django - Using custom model managers
3 votes and 6 so far on reddit
Question about jwt
I just started using `djangorestframework-jwt` and I have a few questions about it. Does a jwt get automatically created on signup/login? \(Do I need to otherwise?\). Or do my users have to manually input their credentials on a specific url to get theirs created?
/r/django
https://redd.it/8n7qsd
I just started using `djangorestframework-jwt` and I have a few questions about it. Does a jwt get automatically created on signup/login? \(Do I need to otherwise?\). Or do my users have to manually input their credentials on a specific url to get theirs created?
/r/django
https://redd.it/8n7qsd
reddit
r/django - Question about jwt
0 votes and 0 so far on reddit
What are the best courses on Udemy for learning Python and Django right now?
/r/djangolearning
https://redd.it/8n81nz
/r/djangolearning
https://redd.it/8n81nz
reddit
r/djangolearning - What are the best courses on Udemy for learning Python and Django right now?
1 votes and 1 so far on reddit
Questions about deploying django project to PythonAnywhere
Hi, my first time deploying to pythonanywhere (or anywhere in general) and have a few questions.
I used pipenv to create my virtual environment on my local machine and used gitlab to upload my django project and in my gitignore file, I have the sqlite database and a .env file.
I am also using python decouple to grab the environment variables and dj-database-url for my sqlite3 connection.
I just want to know if I am on the right path when deploying to pythonanywhere.
When I open their bash console, I will
* git clone <myproject url>
* pip install pipenv and activate 'pipenv shell'
* pipenv install python=3.6
* pipenv install django
* pipenv "all the different modules I imported"
* create a .env file and add my environment variables
* run python manage.py makemigrations and then migrate the database
Are there any steps I am missing? Sorry if this is such a weird question. I just want to make sure I am deploying correctly.
/r/djangolearning
https://redd.it/8n4gwn
Hi, my first time deploying to pythonanywhere (or anywhere in general) and have a few questions.
I used pipenv to create my virtual environment on my local machine and used gitlab to upload my django project and in my gitignore file, I have the sqlite database and a .env file.
I am also using python decouple to grab the environment variables and dj-database-url for my sqlite3 connection.
I just want to know if I am on the right path when deploying to pythonanywhere.
When I open their bash console, I will
* git clone <myproject url>
* pip install pipenv and activate 'pipenv shell'
* pipenv install python=3.6
* pipenv install django
* pipenv "all the different modules I imported"
* create a .env file and add my environment variables
* run python manage.py makemigrations and then migrate the database
Are there any steps I am missing? Sorry if this is such a weird question. I just want to make sure I am deploying correctly.
/r/djangolearning
https://redd.it/8n4gwn
reddit
Questions about deploying django project to... • r/djangolearning
Hi, my first time deploying to pythonanywhere (or anywhere in general) and have a few questions. I used pipenv to create my virtual environment...
flask/sqlalchemy without using flask_sqlalchemy
Good evening, I'm trying to figure out how to specify my database file using a flask config variable that I can alter during testing. I'm aware that I can use flask\_sqlalchemy and use the standard SQLALCHEMY\_DATABASE\_URI config, but for the sake of this conversation, I want to remove that dependency.
The piece that is failing is [https://gist.github.com/paxtontech/c2788092b31076aa6f8f22e7eb55b0a7#file\-database\-py\-L5](https://gist.github.com/paxtontech/c2788092b31076aa6f8f22e7eb55b0a7#file-database-py-L5) due to the fact that app isn't available in that context. I think I need to create an application factory, but I'm not sure how to go about setting that up while allowing the test to call init\_db with the right context as well.
Thoughts?
/r/flask
https://redd.it/8n65hy
Good evening, I'm trying to figure out how to specify my database file using a flask config variable that I can alter during testing. I'm aware that I can use flask\_sqlalchemy and use the standard SQLALCHEMY\_DATABASE\_URI config, but for the sake of this conversation, I want to remove that dependency.
The piece that is failing is [https://gist.github.com/paxtontech/c2788092b31076aa6f8f22e7eb55b0a7#file\-database\-py\-L5](https://gist.github.com/paxtontech/c2788092b31076aa6f8f22e7eb55b0a7#file-database-py-L5) due to the fact that app isn't available in that context. I think I need to create an application factory, but I'm not sure how to go about setting that up while allowing the test to call init\_db with the right context as well.
Thoughts?
/r/flask
https://redd.it/8n65hy
Gist
flask, sqlalchemy and declarative_base with app.config
Getting a freelancing Django job.
Ok so overall average when it comes to back end and front end. it has been six months and i already made couple of Contact/ About us to my friends and an acceptable eCommerce site.
I went and made an upwork account but every entry job listed there has a specific thing that you have to learn and i am feeling lost and have no idea what to do about that.
I mean applying for the job without the knowledge of that specific thing is unprofessional and in the meanwhile learning everything new would be a waste of time and i would never work in 3 years time so.. give me some advice my fellow djangoneers.
/r/django
https://redd.it/8n83au
Ok so overall average when it comes to back end and front end. it has been six months and i already made couple of Contact/ About us to my friends and an acceptable eCommerce site.
I went and made an upwork account but every entry job listed there has a specific thing that you have to learn and i am feeling lost and have no idea what to do about that.
I mean applying for the job without the knowledge of that specific thing is unprofessional and in the meanwhile learning everything new would be a waste of time and i would never work in 3 years time so.. give me some advice my fellow djangoneers.
/r/django
https://redd.it/8n83au
reddit
r/django - Getting a freelancing Django job.
9 votes and 7 so far on reddit
[AF] troubleshooting flask app on heroku
Hi all,
I'm a newbie to web development and recently my friend and I have been trying to create a webapp that shows the count of various tweets using the TwitterAPI. We were able to create a working prototype that runs on my local machine, using flask integrated with socket\-io. Basically the point of the site is to update the count of tweets live. We tried to deploy this to Heroku but we faced some issues that we didn't exactly understand.
Basically our code has a separate script that runs the TwitterAPI stuff and the counts for various cases are saved into a SQLite database. From there, the main.py for the flask app would read the information every second and would update the site accordingly. However, when we tried to deploy this to Heroku, the database started to get overwritten: we figured out that when we used gunicorn, each HTTP request basically created a new thread and would basically run the database\-writing script multiple times, which caused problems. Currently, we don't know how to run this script once, independent from all the HTTP requests. We tried modifying the Procfile and tried different dynos but we then encountered some other bugs. Any help would be much appreciated!!
Thanks!
/r/flask
https://redd.it/8n50ot
Hi all,
I'm a newbie to web development and recently my friend and I have been trying to create a webapp that shows the count of various tweets using the TwitterAPI. We were able to create a working prototype that runs on my local machine, using flask integrated with socket\-io. Basically the point of the site is to update the count of tweets live. We tried to deploy this to Heroku but we faced some issues that we didn't exactly understand.
Basically our code has a separate script that runs the TwitterAPI stuff and the counts for various cases are saved into a SQLite database. From there, the main.py for the flask app would read the information every second and would update the site accordingly. However, when we tried to deploy this to Heroku, the database started to get overwritten: we figured out that when we used gunicorn, each HTTP request basically created a new thread and would basically run the database\-writing script multiple times, which caused problems. Currently, we don't know how to run this script once, independent from all the HTTP requests. We tried modifying the Procfile and tried different dynos but we then encountered some other bugs. Any help would be much appreciated!!
Thanks!
/r/flask
https://redd.it/8n50ot
reddit
[AF] troubleshooting flask app on heroku • r/flask
Hi all, I'm a newbie to web development and recently my friend and I have been trying to create a webapp that shows the count of various tweets...
How To Write Tests For Python
[https://able.bio/SamDev14/how\-to\-write\-tests\-for\-python\-\-22m3q1n](https://able.bio/SamDev14/how-to-write-tests-for-python--22m3q1n)
/r/Python
https://redd.it/8n7uay
[https://able.bio/SamDev14/how\-to\-write\-tests\-for\-python\-\-22m3q1n](https://able.bio/SamDev14/how-to-write-tests-for-python--22m3q1n)
/r/Python
https://redd.it/8n7uay
How to exclude database password when pushing to github?
Hiho, today I setup a Djangoproject, and for the first time I`m using PostgreSQL instead of SQLite. Everything is great and setting it up, unexpectedly, was no problem.
But now I would like to know if there is a way to exclude the databasepassword from the settings.py file when I push the project to github. I know how to exclude the whole settings.py file with .gitignore, but thats not really what I would like to do.
Thats the part for the database.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'me',
'PASSWORD': 'passwort',
'HOST': 'localhost',
'PORT': '',
}
}
/r/django
https://redd.it/8n8oj0
Hiho, today I setup a Djangoproject, and for the first time I`m using PostgreSQL instead of SQLite. Everything is great and setting it up, unexpectedly, was no problem.
But now I would like to know if there is a way to exclude the databasepassword from the settings.py file when I push the project to github. I know how to exclude the whole settings.py file with .gitignore, but thats not really what I would like to do.
Thats the part for the database.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'me',
'PASSWORD': 'passwort',
'HOST': 'localhost',
'PORT': '',
}
}
/r/django
https://redd.it/8n8oj0
reddit
How to exclude database password when pushing to github? • r/django
Hiho, today I setup a Djangoproject, and for the first time I`m using PostgreSQL instead of SQLite. Everything is great and setting it up,...
Using python manage.py shell effectively
When using django shell, i have to enter all the imports manually, and also rewrite the views for testing. This is so much of work and also a pain in a\*\*. Is their any way where i have to type less and test more. Like any tip on how to use django shell effectively.
/r/django
https://redd.it/8n8x3w
When using django shell, i have to enter all the imports manually, and also rewrite the views for testing. This is so much of work and also a pain in a\*\*. Is their any way where i have to type less and test more. Like any tip on how to use django shell effectively.
/r/django
https://redd.it/8n8x3w
reddit
r/django - Using python manage.py shell effectively
0 votes and 7 so far on reddit
Alternative for php's include/require function in Django
[SOLVED]
Hi, I am new to django, I used to use php but now I have to work on a quite big project I have decided to use django. In php I used to reuse code using include function. eg. if there is a navbar that needs to be displayed on top of every page in the website, instead of writing html for navbar on every page I used to write it in a seperate file called `navbar.php` and the use
include('/navbar.php');
on appropriate places in every webpage.
How do I implement this in django. I looked into creating a base.html and extending it but its not quite the same.
/r/django
https://redd.it/8n6mob
[SOLVED]
Hi, I am new to django, I used to use php but now I have to work on a quite big project I have decided to use django. In php I used to reuse code using include function. eg. if there is a navbar that needs to be displayed on top of every page in the website, instead of writing html for navbar on every page I used to write it in a seperate file called `navbar.php` and the use
include('/navbar.php');
on appropriate places in every webpage.
How do I implement this in django. I looked into creating a base.html and extending it but its not quite the same.
/r/django
https://redd.it/8n6mob
reddit
Alternative for php's include/require function in Django • r/django
[SOLVED] Hi, I am new to django, I used to use php but now I have to work on a quite big project I have decided to use django. In php I used to...