How to Build a Discussion Forum in Django: Designing Data Model
https://hashedin.com/2017/04/21/django-models-designing-data-model-for-discussion-forum-charcha/
/r/django
https://redd.it/6bh6j7
https://hashedin.com/2017/04/21/django-models-designing-data-model-for-discussion-forum-charcha/
/r/django
https://redd.it/6bh6j7
HashedIn
Django Models - Designing Data Model for Discussion Forum (Charcha)
Discusses the requirements and the process of designing the django models for the requirements in an efficent manner.
Haystack Rich Content Extraction Example
In the [example](https://django-haystack.readthedocs.io/en/v2.6.0/rich_content_extraction.html) there is a line:
{{ extracted.contents|striptags|safe }}
But in the Django docs, there is a note on the striptags template filter that says
> Note that striptags doesn’t give any guarantee about its output being HTML safe, particularly with non valid HTML input. So NEVER apply the safe filter to a striptags output. If you are looking for something more robust, you can use the bleach Python library, notably its clean method.
How to reconcile this?
/r/djangolearning
https://redd.it/6aw0v3
In the [example](https://django-haystack.readthedocs.io/en/v2.6.0/rich_content_extraction.html) there is a line:
{{ extracted.contents|striptags|safe }}
But in the Django docs, there is a note on the striptags template filter that says
> Note that striptags doesn’t give any guarantee about its output being HTML safe, particularly with non valid HTML input. So NEVER apply the safe filter to a striptags output. If you are looking for something more robust, you can use the bleach Python library, notably its clean method.
How to reconcile this?
/r/djangolearning
https://redd.it/6aw0v3
Optimal project structure when combing Django with front end such as npm and materialize.css?
The Project structure I've got looks now like this:
- /Root
- - /proj_env
- - /main_app
- - /website_app
- - - /templates
- db.sqlite3
- manage.py
I'm not showing every single file here as you see but just a rough example of my project structure. And I'm wondering where to initialize npm and can I just put a **static** directory in the root directory or does it need to be in one of the app directories?
I just know that node modules should at least not be in a static directory.
/r/djangolearning
https://redd.it/6aef6t
The Project structure I've got looks now like this:
- /Root
- - /proj_env
- - /main_app
- - /website_app
- - - /templates
- db.sqlite3
- manage.py
I'm not showing every single file here as you see but just a rough example of my project structure. And I'm wondering where to initialize npm and can I just put a **static** directory in the root directory or does it need to be in one of the app directories?
I just know that node modules should at least not be in a static directory.
/r/djangolearning
https://redd.it/6aef6t
reddit
Optimal project structure when combing Django... • r/djangolearning
The Project structure I've got looks now like this: - /Root - - /proj_env - - /main_app - - /website_app - - - /templates ...
Django Developer Panel - Chrome Devtools Extension
Hello /r/django! Today I released a tool I've been working on called Django Developer Panel, which surfaces useful debug information from Django projects to Chrome's developer tools.
[I did a little writeup on our company blog today](http://hirelofty.com/blog/open-source-project-django-developer-panel/) to explain the rationale and lay out a small roadmap for future development, but the gist is it's simple to set up (grab the chrome extension and then add one middleware class to your project settings) and is focused heavily on application state, particularly when using Class Based Views.
**Python source:** https://github.com/loftylabs/django-developer-panel
**Chrome source:** https://github.com/loftylabs/djdevpanel-devtools
**PyPI package:** https://pypi.python.org/pypi/django-developer-panel/0.1.1
**Chrome Extension:** https://chrome.google.com/webstore/detail/django-developer-panel/joeiapdjinonjadfbdabogjimfffpfph?hl=en-US
Looking for contributors and users to test against their applications!
/r/django
https://redd.it/6bhtec
Hello /r/django! Today I released a tool I've been working on called Django Developer Panel, which surfaces useful debug information from Django projects to Chrome's developer tools.
[I did a little writeup on our company blog today](http://hirelofty.com/blog/open-source-project-django-developer-panel/) to explain the rationale and lay out a small roadmap for future development, but the gist is it's simple to set up (grab the chrome extension and then add one middleware class to your project settings) and is focused heavily on application state, particularly when using Class Based Views.
**Python source:** https://github.com/loftylabs/django-developer-panel
**Chrome source:** https://github.com/loftylabs/djdevpanel-devtools
**PyPI package:** https://pypi.python.org/pypi/django-developer-panel/0.1.1
**Chrome Extension:** https://chrome.google.com/webstore/detail/django-developer-panel/joeiapdjinonjadfbdabogjimfffpfph?hl=en-US
Looking for contributors and users to test against their applications!
/r/django
https://redd.it/6bhtec
Hirelofty
Open Source Project: Django Developer Panel
We like personal projects here at Lofty Labs. As developer consultants, it's a good way to clear our heads when we get stuck on a tough ...
Django project with live updating data
Hello,
This sub has always been very helpful, so I wanted to ask around if anyone has built a project similar to mine and whether they could share some insights:
I have a fully functional django project that has all of the base components, but I would like to merge some of its functionalities with an existing MySQL tick database (adds a row every second for financial data). For instance, the tick database's values would change a client (in the django project db) 's account value and such.
How could I merge the functionality of these two databases (django user db + MySQL tick database) in order to dynamically generate live HTML updates to values which are contingent on both systems, as well as changing some of the existing values in the django user db? What kind of architecture should I aim for? I'm unfortunately very much not sure where to start.
Thanks in advance
/r/django
https://redd.it/6bizbn
Hello,
This sub has always been very helpful, so I wanted to ask around if anyone has built a project similar to mine and whether they could share some insights:
I have a fully functional django project that has all of the base components, but I would like to merge some of its functionalities with an existing MySQL tick database (adds a row every second for financial data). For instance, the tick database's values would change a client (in the django project db) 's account value and such.
How could I merge the functionality of these two databases (django user db + MySQL tick database) in order to dynamically generate live HTML updates to values which are contingent on both systems, as well as changing some of the existing values in the django user db? What kind of architecture should I aim for? I'm unfortunately very much not sure where to start.
Thanks in advance
/r/django
https://redd.it/6bizbn
reddit
Django project with live updating data • r/django
Hello, This sub has always been very helpful, so I wanted to ask around if anyone has built a project similar to mine and whether they could...
How to solve a zero division error in an opencv function in django views?
I'm trying to find the center of contours using an opencv function and then take those points and plot them. My main problem is that the opencv function keeps giving me a zero division error. The code is as follows:
def Contours(request):
filename="C:/Users/ishraq/Downloads/traffic2.mp4"
cv2.ocl.setUseOpenCL(False) #get rid of error:(-215) The data should normally be NULL! in function
NumpyAllocator::allocate
vidcap = cv2.VideoCapture(filename)
fgbg = cv2.createBackgroundSubtractorMOG2()
while(vidcap.isOpened()):
success, frame = vidcap.read()
fgray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
fgmask = fgbg.apply(fgray)
ret,fgmaskthresh = cv2.threshold(fgmask,127,255,0)
_, contours, hierarchy = cv2.findContours(fgmaskthresh.copy(),1,2)
mask = np.zeros(fgray.shape, np.uint8)
count=0;
for contour in contours:
count=count+1
cnt=contours[0]
M=cv2.moments(cnt)
cX = float(M['m10'] / M['m00'])
cY = float(M['m01'] / M['m00'])
cv2.drawContours(mask,contours,-1,(255,100,100),1)
cv2.imshow('frame',fmaskthresh)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
vidcap.release()
cv2.destroyAllWindows()
return render_to_response("app/VideoPlayer.html",{'Cx':cX,'Cy':cY})
I looked at the stack trace and found that the cX and cY values are always 0. I can't figure as to what is going wrong that my code is defaulting the two variables to zero. How do I solve this so that my cX and cY variables don't default to 0?
/r/django
https://redd.it/6bjzx6
I'm trying to find the center of contours using an opencv function and then take those points and plot them. My main problem is that the opencv function keeps giving me a zero division error. The code is as follows:
def Contours(request):
filename="C:/Users/ishraq/Downloads/traffic2.mp4"
cv2.ocl.setUseOpenCL(False) #get rid of error:(-215) The data should normally be NULL! in function
NumpyAllocator::allocate
vidcap = cv2.VideoCapture(filename)
fgbg = cv2.createBackgroundSubtractorMOG2()
while(vidcap.isOpened()):
success, frame = vidcap.read()
fgray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
fgmask = fgbg.apply(fgray)
ret,fgmaskthresh = cv2.threshold(fgmask,127,255,0)
_, contours, hierarchy = cv2.findContours(fgmaskthresh.copy(),1,2)
mask = np.zeros(fgray.shape, np.uint8)
count=0;
for contour in contours:
count=count+1
cnt=contours[0]
M=cv2.moments(cnt)
cX = float(M['m10'] / M['m00'])
cY = float(M['m01'] / M['m00'])
cv2.drawContours(mask,contours,-1,(255,100,100),1)
cv2.imshow('frame',fmaskthresh)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
vidcap.release()
cv2.destroyAllWindows()
return render_to_response("app/VideoPlayer.html",{'Cx':cX,'Cy':cY})
I looked at the stack trace and found that the cX and cY values are always 0. I can't figure as to what is going wrong that my code is defaulting the two variables to zero. How do I solve this so that my cX and cY variables don't default to 0?
/r/django
https://redd.it/6bjzx6
reddit
How to solve a zero division error in an opencv... • r/django
I'm trying to find the center of contours using an opencv function and then take those points and plot them. My main problem is that the opencv...
Searching a database for what matches most of my searching criteria
I am using Flask-SQLAlchemy and MySQL. But if there is no propper solution for this task using this setup I am still interested in other setup's solutions.
What I want to do is searching the database for multiple criteria and getting a list sorted by what is matching most criteria. For example I look for
color=red
size=large
type=fruit
Then I would get a list beginning with objects that meet all criteria, then objects meeting just 2 criteria,...
An unefficient way to do this would be querying for each criteria on its own and comparing each result. But this would be stupid for larger databases or many filters I think. Is there a more efficient way? Should I prefer having those criteria as database table as well i.e. many-to-many relationships? Or should I create rows for the criteria in the original table?
As I said I would prefer solutions using my setup but if there is no propper way to do it I would have to think about another setup since those kind of searches are essential for my project.
/r/flask
https://redd.it/6bj0yj
I am using Flask-SQLAlchemy and MySQL. But if there is no propper solution for this task using this setup I am still interested in other setup's solutions.
What I want to do is searching the database for multiple criteria and getting a list sorted by what is matching most criteria. For example I look for
color=red
size=large
type=fruit
Then I would get a list beginning with objects that meet all criteria, then objects meeting just 2 criteria,...
An unefficient way to do this would be querying for each criteria on its own and comparing each result. But this would be stupid for larger databases or many filters I think. Is there a more efficient way? Should I prefer having those criteria as database table as well i.e. many-to-many relationships? Or should I create rows for the criteria in the original table?
As I said I would prefer solutions using my setup but if there is no propper way to do it I would have to think about another setup since those kind of searches are essential for my project.
/r/flask
https://redd.it/6bj0yj
reddit
Searching a database for what matches most of my... • r/flask
I am using Flask-SQLAlchemy and MySQL. But if there is no propper solution for this task using this setup I am still interested in other setup's...
What's everyone working on this week?
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/6bhnzq
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.
/r/Python
https://redd.it/6bhnzq
reddit
What's everyone working on this week? • r/Python
Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your...
What are the most repetitive pieces of code that you keep having to write?
Just wondering, as I often find myself writing similar code throughout my projects
/r/Python
https://redd.it/6bjgkt
Just wondering, as I often find myself writing similar code throughout my projects
/r/Python
https://redd.it/6bjgkt
reddit
What are the most repetitive pieces of code that you... • r/Python
Just wondering, as I often find myself writing similar code throughout my projects
Using Python to find the longest word spellable with symbols from the periodic table.
https://www.amin.space/blog/2017/5/elemental_speller/
/r/Python
https://redd.it/6bgvq1
https://www.amin.space/blog/2017/5/elemental_speller/
/r/Python
https://redd.it/6bgvq1
reddit
Using Python to find the longest word spellable with... • r/Python
160 points and 23 comments so far on reddit
Help fixing flask endpoints
Hello everyone, I had a friend code review a simple to do app that I made with flask. He said that my end points were atypical of a RESTful API and I didn't understand exactly what he meant. He specified by saying that each endpoint should return the specific object that they are manipulating. Could anyone give me some more clarification on this? He doesn't work with python and works with ruby so I had some specific syntax questions. Here's my views.py
https://github.com/snovosel/RESTful_to_do/blob/master/python_todo/views.py
Each view function returns all of the information needed for the front end each time. So i'm not exactly sure what the problem with that is. Hopefully someone can shed some light on this.
Thank you!
/r/flask
https://redd.it/6bn9o1
Hello everyone, I had a friend code review a simple to do app that I made with flask. He said that my end points were atypical of a RESTful API and I didn't understand exactly what he meant. He specified by saying that each endpoint should return the specific object that they are manipulating. Could anyone give me some more clarification on this? He doesn't work with python and works with ruby so I had some specific syntax questions. Here's my views.py
https://github.com/snovosel/RESTful_to_do/blob/master/python_todo/views.py
Each view function returns all of the information needed for the front end each time. So i'm not exactly sure what the problem with that is. Hopefully someone can shed some light on this.
Thank you!
/r/flask
https://redd.it/6bn9o1
GitHub
snovosel/RESTful_to_do
RESTful_to_do - to do list application running on RESTful process with Flask
Good Tutorials on modifying/extending Django Admin site?
Could you folks suggest some good tutorials on modifying/extending Django Admin site?
It would be awesome if they touch on using ajax inside Django Admin. Thank you!
/r/django
https://redd.it/6bknyx
Could you folks suggest some good tutorials on modifying/extending Django Admin site?
It would be awesome if they touch on using ajax inside Django Admin. Thank you!
/r/django
https://redd.it/6bknyx
reddit
Good Tutorials on modifying/extending Django Admin site? • r/django
Could you folks suggest some good tutorials on modifying/extending Django Admin site? It would be awesome if they touch on using ajax inside...
Well documented python ransomeware
https://github.com/VedantGawade/Uzi/blob/master/Uzi.py
/r/Python
https://redd.it/6bn7vl
https://github.com/VedantGawade/Uzi/blob/master/Uzi.py
/r/Python
https://redd.it/6bn7vl
GitHub
VedantGawade/Uzi
Uzi - A Distinctive Ransomeware.
Linux terminal Guake rewritten for Windows, titled WinGuake.
https://github.com/chand1012/WinGuake
/r/Python
https://redd.it/6bofwy
https://github.com/chand1012/WinGuake
/r/Python
https://redd.it/6bofwy
GitHub
GitHub - chand1012/WinGuake: A Windows-oriented version of the popular Guake Terminal for Linux.
A Windows-oriented version of the popular Guake Terminal for Linux. - GitHub - chand1012/WinGuake: A Windows-oriented version of the popular Guake Terminal for Linux.
Group By and Sum Query
Can anyone help me construct a query that looks like https://dpaste.de/fxAf in a view? I've attempted https://dpaste.de/cCar but get an AttributeError.
I'm using django-graphos to pass this into a chart.
/r/django
https://redd.it/6botq2
Can anyone help me construct a query that looks like https://dpaste.de/fxAf in a view? I've attempted https://dpaste.de/cCar but get an AttributeError.
I'm using django-graphos to pass this into a chart.
/r/django
https://redd.it/6botq2
Failed to save my images in the modelformset_factory using CBV
Hello everyone, I have a challenge. my modelformset_factory does not save the images, although it saves the other form information
http://stackoverflow.com/questions/44018020/my-modelformset-factory-is-not-saving-the-images-i-used-the-class-based-views
/r/django
https://redd.it/6bpfse
Hello everyone, I have a challenge. my modelformset_factory does not save the images, although it saves the other form information
http://stackoverflow.com/questions/44018020/my-modelformset-factory-is-not-saving-the-images-i-used-the-class-based-views
/r/django
https://redd.it/6bpfse
Stackoverflow
My modelformset_factory is not saving the images ( I used the Class based views), but saving it, when using the Admin side
I have a challenge of not saving the image when creating a new product. The form is rendered well and the image is uploaded but never saved until I use the Admin to upload and save it, thats when it
Tips for Building High-Quality Django Apps at Scale
https://blog.doordash.com/tips-for-building-high-quality-django-apps-at-scale-a5a25917b2b5
/r/django
https://redd.it/6brut7
https://blog.doordash.com/tips-for-building-high-quality-django-apps-at-scale-a5a25917b2b5
/r/django
https://redd.it/6brut7
Medium
Tips for Building High-Quality Django Apps at Scale
By Alvin Chow and Bernard Liang, Software Engineers
I made a library that pretty-prints tracebacks and shows you the variables in each frame.
https://github.com/skorokithakis/tbvaccine/
/r/Python
https://redd.it/6bstcu
https://github.com/skorokithakis/tbvaccine/
/r/Python
https://redd.it/6bstcu
GitHub
GitHub - skorokithakis/tbvaccine: A small utility to pretty-print Python tracebacks. ⛺
A small utility to pretty-print Python tracebacks. ⛺ - skorokithakis/tbvaccine
PyCon Sale of Python Books / Online Courses
Educative and I are doing a sale of Python books and courses. I am putting all my books and courses on sale at 50% off for PyCon. Educative does online interactive courses and when you purchase a course, you get **lifetime access**.
Let's start with the Educative courses. To get them for 50% off, you just need to use the following coupons:
* For [Python 101](https://www.educative.io/collection/5663684521099264/5707702298738688) – **au-pycon-reddit-101**
* For [Python 201: Intermediate Python](https://www.educative.io/collection/5663684521099264/5693417237512192) – **au-pycon-reddit-201**
Educative is also putting their [Python 3: An interactive deep dive](https://www.educative.io/collection/10370001/5705097937944576) course on sale for 50% off if you use this coupon: **au-pycon-reddit-deepdive**
Finally they also gave me a coupon for one of other courses: [Coderust 2.0: Faster Coding Interview Preparation using Interactive Visualizations](https://www.educative.io/collection/5642554087309312/5679846214598656) - **au-pycon-reddit-coderust** (Note that this coupon is only 17% off though.
For the eBook (PDF, mobi, epub) versions of my books, I am also doing a 50% off sale on Leanpub:
* [Python 101](http://leanpub.com/python_101/) is free or pay what you want
* [Python 201: Intermediate Python](http://leanpub.com/python201/c/50percent)
* [wxPython Cookbook](http://leanpub.com/wxpythoncookbook/c/50percent)
/r/Python
https://redd.it/6bomkd
Educative and I are doing a sale of Python books and courses. I am putting all my books and courses on sale at 50% off for PyCon. Educative does online interactive courses and when you purchase a course, you get **lifetime access**.
Let's start with the Educative courses. To get them for 50% off, you just need to use the following coupons:
* For [Python 101](https://www.educative.io/collection/5663684521099264/5707702298738688) – **au-pycon-reddit-101**
* For [Python 201: Intermediate Python](https://www.educative.io/collection/5663684521099264/5693417237512192) – **au-pycon-reddit-201**
Educative is also putting their [Python 3: An interactive deep dive](https://www.educative.io/collection/10370001/5705097937944576) course on sale for 50% off if you use this coupon: **au-pycon-reddit-deepdive**
Finally they also gave me a coupon for one of other courses: [Coderust 2.0: Faster Coding Interview Preparation using Interactive Visualizations](https://www.educative.io/collection/5642554087309312/5679846214598656) - **au-pycon-reddit-coderust** (Note that this coupon is only 17% off though.
For the eBook (PDF, mobi, epub) versions of my books, I am also doing a 50% off sale on Leanpub:
* [Python 101](http://leanpub.com/python_101/) is free or pay what you want
* [Python 201: Intermediate Python](http://leanpub.com/python201/c/50percent)
* [wxPython Cookbook](http://leanpub.com/wxpythoncookbook/c/50percent)
/r/Python
https://redd.it/6bomkd
Educative: Interactive Courses for Software Developers
Python 101: Interactively learn how to program with Python 3
Welcome to Python 101! I created this course to help you learn Python 3. My objective is to get you acquainted with the building blocks of Python so that you can write something useful yourself. With interactive playgrounds to help you learn right away, I…
Python, Unicode, utf-16, utf-32.
https://groups.google.com/forum/#!topic/comp.lang.python/-58lTkBBZU4
/r/Python
https://redd.it/6bvc7e
https://groups.google.com/forum/#!topic/comp.lang.python/-58lTkBBZU4
/r/Python
https://redd.it/6bvc7e
Programmatically create a user with python-social-auth
I'm using python-social-auth so that users can log in with their google accounts. However, rather than allowing users to register, I want to programmatically create users given an email associated with their google account. How can I do this?
Thanks!
/r/django
https://redd.it/6btkfo
I'm using python-social-auth so that users can log in with their google accounts. However, rather than allowing users to register, I want to programmatically create users given an email associated with their google account. How can I do this?
Thanks!
/r/django
https://redd.it/6btkfo
reddit
Programmatically create a user with python-social-auth • r/django
I'm using python-social-auth so that users can log in with their google accounts. However, rather than allowing users to register, I want to...