No matter what I do, I cannot get the favicon to display
It used to work, but just suddenly stopped. I tried changing the picture, to setting it up in the urlpatterns and even hardcode it into my Nginx to find my favicon but it just doesn't work.
When I inspect element in chrome the link to the favicon works fine.
Have anyone had this issue before??
Getting favicons to display right have never been an issue.
This is my website btw
https://southafricans.online/
/r/django
https://redd.it/88habp
It used to work, but just suddenly stopped. I tried changing the picture, to setting it up in the urlpatterns and even hardcode it into my Nginx to find my favicon but it just doesn't work.
When I inspect element in chrome the link to the favicon works fine.
Have anyone had this issue before??
Getting favicons to display right have never been an issue.
This is my website btw
https://southafricans.online/
/r/django
https://redd.it/88habp
reddit
No matter what I do, I cannot get the favicon to display • r/django
It used to work, but just suddenly stopped. I tried changing the picture, to setting it up in the urlpatterns and even hardcode it into my Nginx...
Advice on hosting a new project
I'm launching a new project, and as I look at Heroku & AWS, I'm wondering if there is a better/cheaper alternative out there that I haven't looked at.
With Heroku, I'd be using:
* Hobby Dyno to start
* Standard Postgres DB (will have millions of rows)
* Logging
* Caching on the front end
* Scheduler for running daily processes
As you add more features/"Add-ons" and traffic to your app grows, Heroku gets unnecessarily expensive.
Is AWS the best option?
/r/django
https://redd.it/88b89l
I'm launching a new project, and as I look at Heroku & AWS, I'm wondering if there is a better/cheaper alternative out there that I haven't looked at.
With Heroku, I'd be using:
* Hobby Dyno to start
* Standard Postgres DB (will have millions of rows)
* Logging
* Caching on the front end
* Scheduler for running daily processes
As you add more features/"Add-ons" and traffic to your app grows, Heroku gets unnecessarily expensive.
Is AWS the best option?
/r/django
https://redd.it/88b89l
reddit
Advice on hosting a new project • r/django
I'm launching a new project, and as I look at Heroku & AWS, I'm wondering if there is a better/cheaper alternative out there that I haven't looked...
Django Multi user type design layout?
So I have a Django app and I have Multiple users. I have a extension of the 'AbstractBaseUser' called User. When a user is created they either can choose 'Banker' or 'Individual'.
When searching for users on my app I wanted to be able to fetch the profile information from both classes. I'm going to be using 'Serializer relations' from the DRF.
How should I layout the models to allow easy fetching? Should I have a OneToOne Field in the user class to the corresponding user type? Or should I have a user field in the 'Banker' and 'Individual'?
I'm just very confused on the right way to layout the model in a professional matter.
/r/django
https://redd.it/88bl98
So I have a Django app and I have Multiple users. I have a extension of the 'AbstractBaseUser' called User. When a user is created they either can choose 'Banker' or 'Individual'.
When searching for users on my app I wanted to be able to fetch the profile information from both classes. I'm going to be using 'Serializer relations' from the DRF.
How should I layout the models to allow easy fetching? Should I have a OneToOne Field in the user class to the corresponding user type? Or should I have a user field in the 'Banker' and 'Individual'?
I'm just very confused on the right way to layout the model in a professional matter.
/r/django
https://redd.it/88bl98
reddit
Django Multi user type design layout? • r/django
So I have a Django app and I have Multiple users. I have a extension of the 'AbstractBaseUser' called User. When a user is created they either can...
Moved secret_key location on fresh install and now homepage is 404
I have just been playing around in Django2 and setup a new install on Ubuntu EC2 instance, I then realized the secret key was still in the settings file so I moved it to a text file in /etc and then the standard Django homepage became a 404 but even after restoring the secret key it didnt change back. Whats also strange is that the basic /blog I had made works fine still as does /admin. I have made no other changes to the urls or other structure and the homepage was fine after making the /blog until I moved the secret key....
/r/django
https://redd.it/88aphe
I have just been playing around in Django2 and setup a new install on Ubuntu EC2 instance, I then realized the secret key was still in the settings file so I moved it to a text file in /etc and then the standard Django homepage became a 404 but even after restoring the secret key it didnt change back. Whats also strange is that the basic /blog I had made works fine still as does /admin. I have made no other changes to the urls or other structure and the homepage was fine after making the /blog until I moved the secret key....
/r/django
https://redd.it/88aphe
reddit
Moved secret_key location on fresh install and now... • r/django
I have just been playing around in Django2 and setup a new install on Ubuntu EC2 instance, I then realized the secret key was still in the...
Flask data from mysql fails to send data occasionally.
When I add data to the current_user model (lets say I add api keys to the user model), and the user updates these. When I try to retrieve that new data flask fails to send the new data about 50% of the requests.
Why would updating the user model while logged in cause the new data to not be returned 50%? If I reboot the server all the data will return 100% of the time .
Hints: This does not appear to happen when not using SSL and connecting directly to gunicorn.
/r/flask
https://redd.it/87v2a2
When I add data to the current_user model (lets say I add api keys to the user model), and the user updates these. When I try to retrieve that new data flask fails to send the new data about 50% of the requests.
Why would updating the user model while logged in cause the new data to not be returned 50%? If I reboot the server all the data will return 100% of the time .
Hints: This does not appear to happen when not using SSL and connecting directly to gunicorn.
/r/flask
https://redd.it/87v2a2
reddit
Flask data from mysql fails to send data occasionally. • r/flask
When I add data to the current_user model (lets say I add api keys to the user model), and the user updates these. When I try to retrieve that new...
Tutorial for GUI in Python 3 tkinter Registration form
https://youtu.be/Md__lI9H7g8
/r/Python
https://redd.it/88grwq
https://youtu.be/Md__lI9H7g8
/r/Python
https://redd.it/88grwq
YouTube
Registration Form Using Tkinter Python 3 - #Part 1 GUI Only
Registration Form Using Tkinter Python 3 - #Part 1 GUI Only
In this video we'll be seeing about how to create a GUI Registration Form using Python's standard GUI library Tkinter.
Code link:https://github.com/abhishek305/Registration-Form-using-Python-GUI…
In this video we'll be seeing about how to create a GUI Registration Form using Python's standard GUI library Tkinter.
Code link:https://github.com/abhishek305/Registration-Form-using-Python-GUI…
Beta of the next pip version has been released
https://blog.python.org/2018/03/beta-release-of-pip-version-10.html
/r/Python
https://redd.it/88jfwl
https://blog.python.org/2018/03/beta-release-of-pip-version-10.html
/r/Python
https://redd.it/88jfwl
reddit
Beta of the next pip version has been released • r/Python
4 points and 0 comments so far on reddit
100 free Jupyter notebooks on interactive computing and data science
https://groups.google.com/forum/#!topic/jupyter/JHv0FhaggGc
/r/IPython
https://redd.it/88iqfe
https://groups.google.com/forum/#!topic/jupyter/JHv0FhaggGc
/r/IPython
https://redd.it/88iqfe
Is ALLOWED_HOSTS cross referenced with request.get_host()?
I'm slightly confused when it comes to how django is using the tuple in ALLOWED_HOSTS to validate host. Does django run request.get_host() and compare the host to the list within ALLOWED_HOSTS?
The django documentation indicates the following with regards to ALLOWED_HOSTS:
>This validation only applies via get_host(); if your code accesses the Host header directly from request.META you are bypassing this security protection.
>https://docs.djangoproject.com/en/2.0/ref/settings/
If I create middleware that uses get_host() to get the host and compare it to a list of approved host names and pass the user 404 if the domain isn't in the list, I assume this would essentially be replicating the ALLOWED_HOSTS functionality?
I ask this question because I do, in fact, need to write middleware to replace ALLOWED_HOSTS. The list of approved hosts grows over time as more users sign up. As a result, I the tuple that I'm validating against is dynamic and thus, I can't use the default ALLOWED_HOSTS config in django.
Thanks!
/r/django
https://redd.it/87yzer
I'm slightly confused when it comes to how django is using the tuple in ALLOWED_HOSTS to validate host. Does django run request.get_host() and compare the host to the list within ALLOWED_HOSTS?
The django documentation indicates the following with regards to ALLOWED_HOSTS:
>This validation only applies via get_host(); if your code accesses the Host header directly from request.META you are bypassing this security protection.
>https://docs.djangoproject.com/en/2.0/ref/settings/
If I create middleware that uses get_host() to get the host and compare it to a list of approved host names and pass the user 404 if the domain isn't in the list, I assume this would essentially be replicating the ALLOWED_HOSTS functionality?
I ask this question because I do, in fact, need to write middleware to replace ALLOWED_HOSTS. The list of approved hosts grows over time as more users sign up. As a result, I the tuple that I'm validating against is dynamic and thus, I can't use the default ALLOWED_HOSTS config in django.
Thanks!
/r/django
https://redd.it/87yzer
reddit
Is ALLOWED_HOSTS cross referenced with request.get_host()? • r/django
I'm slightly confused when it comes to how django is using the tuple in ALLOWED_HOSTS to validate host. Does django run request.get_host() and...
[Ask Flask] Trying to query a single value from FlaskSQLAlchemy/SQLite database and validate it for auth
Hello,
I have a USER table in my SQLite database which has only 1 user record. The table simply consists of ID, USERNAME, PASSWORD.
I am trying to query USERNAME and PASSWORD by defining **un** and **pw** variables as queries, and then check in my HTTP authentication if username == un and password == pw.
However, I haven't been able to get the queries I'm using for **un** and **pw** to just return the USERNAME and PASSWORD string values to use for comparison.
Can someone show me how I can get this working?
Thank you!
Here's the code. Pretty straightforward:
@app.route('/adicionar')
def adicionar():
un = db.session.query(User.username)
pw = db.session.query(User.password)
if request.authorization and request.authorization.username == un and request.authorization.password == pw:
return render_template('adicionar.html')
else:
return make_response('User not authorized', 401, {'WWW-Authenticate' : 'Basic realm = "Login Required"'})
EDIT: Additionally for troubleshooting, the below statement returns an error:
*TypeError: 'BaseQuery' object is not callable*
@app.route('/adicionar')
def adicionar():
un = db.session.query(User.username)
pw = db.session.query(User.password)
return pw
/r/flask
https://redd.it/88j63r
Hello,
I have a USER table in my SQLite database which has only 1 user record. The table simply consists of ID, USERNAME, PASSWORD.
I am trying to query USERNAME and PASSWORD by defining **un** and **pw** variables as queries, and then check in my HTTP authentication if username == un and password == pw.
However, I haven't been able to get the queries I'm using for **un** and **pw** to just return the USERNAME and PASSWORD string values to use for comparison.
Can someone show me how I can get this working?
Thank you!
Here's the code. Pretty straightforward:
@app.route('/adicionar')
def adicionar():
un = db.session.query(User.username)
pw = db.session.query(User.password)
if request.authorization and request.authorization.username == un and request.authorization.password == pw:
return render_template('adicionar.html')
else:
return make_response('User not authorized', 401, {'WWW-Authenticate' : 'Basic realm = "Login Required"'})
EDIT: Additionally for troubleshooting, the below statement returns an error:
*TypeError: 'BaseQuery' object is not callable*
@app.route('/adicionar')
def adicionar():
un = db.session.query(User.username)
pw = db.session.query(User.password)
return pw
/r/flask
https://redd.it/88j63r
reddit
[Ask Flask] Trying to query a single value from... • r/flask
Hello, I have a USER table in my SQLite database which has only 1 user record. The table simply consists of ID, USERNAME, PASSWORD. I am trying...
Getting CROSS JOIN with intermediate table with Django ORM?
Hi,
I have these models:
class Region(models.Model):
region_name = models.CharField(max_length=64)
def __str__(self):
return self.region_name
class GameRegionRelease(models.Model):
region = models.ForeignKey(
Region,
on_delete=models.CASCADE,
verbose_name='region'
)
game = models.ForeignKey(
Game,
on_delete=models.CASCADE,
verbose_name='game'
)
release_date = models.DateField(
verbose_name='release date',
default=None
)
class Game(models.Model):
game_name = models.CharField(max_length=512)
release_dates = models.ManyToManyField(
Region,
related_name='game_release_dates',
through='GameRegionRelease'
)
What I'm looking to get is every region listed for every game, even if there is no region data for that game. So the results would be Game x Region, with the region data filled in by GameRegionRelease where available. I'd want something similar to what the following would produce:
SELECT *
FROM gameslist_region gr
CROSS JOIN gameslist_game gg
LEFT JOIN gameslist_gameregionrelease grr
ON gg.game_name = grr.game_id
AND gr.region_name = grr.region_id;
But I don't know how to express this in Django using native ORM constructs. Is this possible? I'm using Python 3.6.4 and Django 2.0.2.
/r/django
https://redd.it/87vli4
Hi,
I have these models:
class Region(models.Model):
region_name = models.CharField(max_length=64)
def __str__(self):
return self.region_name
class GameRegionRelease(models.Model):
region = models.ForeignKey(
Region,
on_delete=models.CASCADE,
verbose_name='region'
)
game = models.ForeignKey(
Game,
on_delete=models.CASCADE,
verbose_name='game'
)
release_date = models.DateField(
verbose_name='release date',
default=None
)
class Game(models.Model):
game_name = models.CharField(max_length=512)
release_dates = models.ManyToManyField(
Region,
related_name='game_release_dates',
through='GameRegionRelease'
)
What I'm looking to get is every region listed for every game, even if there is no region data for that game. So the results would be Game x Region, with the region data filled in by GameRegionRelease where available. I'd want something similar to what the following would produce:
SELECT *
FROM gameslist_region gr
CROSS JOIN gameslist_game gg
LEFT JOIN gameslist_gameregionrelease grr
ON gg.game_name = grr.game_id
AND gr.region_name = grr.region_id;
But I don't know how to express this in Django using native ORM constructs. Is this possible? I'm using Python 3.6.4 and Django 2.0.2.
/r/django
https://redd.it/87vli4
reddit
Getting CROSS JOIN with intermediate table with Django ORM? • r/django
Hi, I have these models: class Region(models.Model): region_name = models.CharField(max_length=64) def __str__(self): ...
[af] Getting started with flask unit testing, tutorials?
I'm getting started on with unit testing. Are there any good tutorials that I should be aware of? Most of the ones I found online were either old or too basic. Right now I'm just referencing projects on Github and it's going OK. A nice tutorial would be helpful though.
/r/flask
https://redd.it/88lynb
I'm getting started on with unit testing. Are there any good tutorials that I should be aware of? Most of the ones I found online were either old or too basic. Right now I'm just referencing projects on Github and it's going OK. A nice tutorial would be helpful though.
/r/flask
https://redd.it/88lynb
reddit
[af] Getting started with flask unit testing, tutorials? • r/flask
I'm getting started on with unit testing. Are there any good tutorials that I should be aware of? Most of the ones I found online were either old...
What are the best practices for logging IP addresses?
Should I and to what extent should I log the IP addresses that hit my Flask web app (PostgreSQL, Flask-Security, Flask-Sqlalchemy) that is hosted in Heroku? It is an event planning web app that allows user account creation and the ability to RSVP through email links. Should I, for example, log the IP addresses that create user accounts or possibly the IP addresses that hit the RSVP page links that get sent after creating an event? Thanks in advance for any advice!
/r/flask
https://redd.it/88n0e1
Should I and to what extent should I log the IP addresses that hit my Flask web app (PostgreSQL, Flask-Security, Flask-Sqlalchemy) that is hosted in Heroku? It is an event planning web app that allows user account creation and the ability to RSVP through email links. Should I, for example, log the IP addresses that create user accounts or possibly the IP addresses that hit the RSVP page links that get sent after creating an event? Thanks in advance for any advice!
/r/flask
https://redd.it/88n0e1
reddit
What are the best practices for logging IP addresses? • r/flask
Should I and to what extent should I log the IP addresses that hit my Flask web app (PostgreSQL, Flask-Security, Flask-Sqlalchemy) that is hosted...
issue with Forms i wasn't having before
I formatted my computer, installed linux on it (was windows 7) and reinstalled the libraries, and now i started to getting error messages about flask_wtf.forms (or whatever) being deprecated.
I made some changes on my forms.py and i'm getting this error.
does anybody know what's the issue here?
https://imgur.com/a/MSX6v
/r/flask
https://redd.it/87o68j
I formatted my computer, installed linux on it (was windows 7) and reinstalled the libraries, and now i started to getting error messages about flask_wtf.forms (or whatever) being deprecated.
I made some changes on my forms.py and i'm getting this error.
does anybody know what's the issue here?
https://imgur.com/a/MSX6v
/r/flask
https://redd.it/87o68j
[P] Deep Reinforcement Learning Free Course
Hello, I'm currently writing a series of free articles about Deep Reinforcement Learning, where we'll learn the main algorithms (from Q* learning to PPO), and how to implement them in Tensorflow.
**The Syllabus**: https://simoninithomas.github.io/Deep_reinforcement_learning_Course/
The first article is published, each week 2 articles will be published, but **if you want to be alerted about the next article, follow me on Medium and/or follow the github repo below**
I wrote these articles because I wanted to have articles that begin with the big picture (understand the concept in simpler terms), then the mathematical implementation and finally a Tensorflow implementation **explained step by step** (each part of the code is commented). And too much articles missed the implementation part or just give the code without any comments.
Let me see what you think! What architectures you want and any feedback.
**The first article**: https://medium.freecodecamp.org/an-introduction-to-reinforcement-learning-4339519de419
**The first notebook**: https://github.com/simoninithomas/Deep_reinforcement_learning_Course/blob/master/Q%20learning/Q%20Learning%20with%20FrozenLake.ipynb
Thanks!
/r/MachineLearning
https://redd.it/88h0g4
Hello, I'm currently writing a series of free articles about Deep Reinforcement Learning, where we'll learn the main algorithms (from Q* learning to PPO), and how to implement them in Tensorflow.
**The Syllabus**: https://simoninithomas.github.io/Deep_reinforcement_learning_Course/
The first article is published, each week 2 articles will be published, but **if you want to be alerted about the next article, follow me on Medium and/or follow the github repo below**
I wrote these articles because I wanted to have articles that begin with the big picture (understand the concept in simpler terms), then the mathematical implementation and finally a Tensorflow implementation **explained step by step** (each part of the code is commented). And too much articles missed the implementation part or just give the code without any comments.
Let me see what you think! What architectures you want and any feedback.
**The first article**: https://medium.freecodecamp.org/an-introduction-to-reinforcement-learning-4339519de419
**The first notebook**: https://github.com/simoninithomas/Deep_reinforcement_learning_Course/blob/master/Q%20learning/Q%20Learning%20with%20FrozenLake.ipynb
Thanks!
/r/MachineLearning
https://redd.it/88h0g4
How do I synchronously wait for an asyncio future?
I can't just use `loop.run_until_complete` because my code is being called from an asyncio loop. I can't just make my function async because the thing calling my code (neovim remote plugin host) doesn't work that way (because it supports pyuv so it can work on python 2).
I can't do `asyncio.new_event_loop().run_until_complete` because apparently you can't run a loop while another loop is running. (Why not???? I don't understand.)
I've thought of starting a new thread so I can run a new loop in that thread, but **there *must* be a better way**.
/r/Python
https://redd.it/88mxto
I can't just use `loop.run_until_complete` because my code is being called from an asyncio loop. I can't just make my function async because the thing calling my code (neovim remote plugin host) doesn't work that way (because it supports pyuv so it can work on python 2).
I can't do `asyncio.new_event_loop().run_until_complete` because apparently you can't run a loop while another loop is running. (Why not???? I don't understand.)
I've thought of starting a new thread so I can run a new loop in that thread, but **there *must* be a better way**.
/r/Python
https://redd.it/88mxto
reddit
How do I synchronously wait for an asyncio future? • r/Python
I can't just use `loop.run_until_complete` because my code is being called from an asyncio loop. I can't just make my function async because the...
Is there something weird I don't understand with callbacks?
Hello,
I am learning python and did this quick exercise to familiarize myself with tkinter, lambdas, and callbacks. But it's behaving very weirdly. Here's the sample code:
def callback(col, val):
print("Hello: i=" + str(col) + ",j=" + str(val))
for i in range(10):
col = tkinter.Frame(frame)
for j in range(i):
button = tkinter.Button(col, height = 3, width = 5, text = str(j+1), command = lambda: callback(i, j))
button.pack(side = tkinter.TOP)
col.pack(side = tkinter.LEFT, anchor = tkinter.N, expand = False)
frame.pack()
top.mainloop()
The buttons get laid out properly and display the right thing. But when you click each one, rather than printing out the specific (i, j), they all print the same i and j (9 and 8) - as if they were all getting the same callback - the last callback defined. This is really surprising behavior, am I missing something?
Thank you!
/r/Python
https://redd.it/88ox3y
Hello,
I am learning python and did this quick exercise to familiarize myself with tkinter, lambdas, and callbacks. But it's behaving very weirdly. Here's the sample code:
def callback(col, val):
print("Hello: i=" + str(col) + ",j=" + str(val))
for i in range(10):
col = tkinter.Frame(frame)
for j in range(i):
button = tkinter.Button(col, height = 3, width = 5, text = str(j+1), command = lambda: callback(i, j))
button.pack(side = tkinter.TOP)
col.pack(side = tkinter.LEFT, anchor = tkinter.N, expand = False)
frame.pack()
top.mainloop()
The buttons get laid out properly and display the right thing. But when you click each one, rather than printing out the specific (i, j), they all print the same i and j (9 and 8) - as if they were all getting the same callback - the last callback defined. This is really surprising behavior, am I missing something?
Thank you!
/r/Python
https://redd.it/88ox3y
reddit
Is there something weird I don't understand with callbacks? • r/Python
Hello, I am learning python and did this quick exercise to familiarize myself with tkinter, lambdas, and callbacks. But it's behaving very...
Play Tetris inside a Jupyter notebook today!
http://www.juliatetris.com
/r/IPython
https://redd.it/88p097
http://www.juliatetris.com
/r/IPython
https://redd.it/88p097
[N] Introducing TensorFlow Hub: A Library for Reusable Machine Learning Modules in TensorFlow
https://medium.com/tensorflow/introducing-tensorflow-hub-a-library-for-reusable-machine-learning-modules-in-tensorflow-cdee41fa18f9
/r/MachineLearning
https://redd.it/88o922
https://medium.com/tensorflow/introducing-tensorflow-hub-a-library-for-reusable-machine-learning-modules-in-tensorflow-cdee41fa18f9
/r/MachineLearning
https://redd.it/88o922
Medium
Introducing TensorFlow Hub: A Library for Reusable Machine Learning Modules in TensorFlow
Posted by Josh Gordon, Developer Advocate for TensorFlow