Question: Let users sort model by input
Hey everyone, I'm having trouble finding this answer online so I thought I'd come here and ask. Thanks in advance.
I have a Django model based on real-world locations and addresses. I'd like the user to be able to input their zip-code, and have the model's objects be sorted by the closest available.
It seems like I could use a simple form to collect the user's zip code, but I'm not sure what to do next. Do I need to reload the html or is there a way to sort without changing the page?
Any advice would be appreciated. I don't feel like this should be too difficult, but I'm pretty new to the web-dev world.
/r/django
https://redd.it/6yp5ll
Hey everyone, I'm having trouble finding this answer online so I thought I'd come here and ask. Thanks in advance.
I have a Django model based on real-world locations and addresses. I'd like the user to be able to input their zip-code, and have the model's objects be sorted by the closest available.
It seems like I could use a simple form to collect the user's zip code, but I'm not sure what to do next. Do I need to reload the html or is there a way to sort without changing the page?
Any advice would be appreciated. I don't feel like this should be too difficult, but I'm pretty new to the web-dev world.
/r/django
https://redd.it/6yp5ll
reddit
Question: Let users sort model by input • r/django
Hey everyone, I'm having trouble finding this answer online so I thought I'd come here and ask. Thanks in advance. I have a Django model based on...
A way to auto generate more forms? Or is there another way?
Basically I want a user to be able to fill out an Invoice, and you can enter in Labor or a Product with a quantity and how much labor costs. There will be multiple products and labor codes.
Ie.
Quantity: 2 - Product Description - Unit Cost: $5/ea - Total: $10
Quantity: 10 - Product Description - Unit Cost: $.02/ea - Total: $0.20
Quantity: 1.5 - Labor Description - Per Hour: $35/hour - Total: $52.50
Should I have a row form generate after each one is filled out, or is there a better way to just enter all the data together in one form while being broken out for customer and business to see?
/r/django
https://redd.it/6ypzwq
Basically I want a user to be able to fill out an Invoice, and you can enter in Labor or a Product with a quantity and how much labor costs. There will be multiple products and labor codes.
Ie.
Quantity: 2 - Product Description - Unit Cost: $5/ea - Total: $10
Quantity: 10 - Product Description - Unit Cost: $.02/ea - Total: $0.20
Quantity: 1.5 - Labor Description - Per Hour: $35/hour - Total: $52.50
Should I have a row form generate after each one is filled out, or is there a better way to just enter all the data together in one form while being broken out for customer and business to see?
/r/django
https://redd.it/6ypzwq
reddit
A way to auto generate more forms? Or is there another way? • r/django
Basically I want a user to be able to fill out an Invoice, and you can enter in Labor or a Product with a quantity and how much labor costs. There...
[N] Microsoft and Facebook create open ecosystem for AI model interoperability
https://www.microsoft.com/en-us/cognitive-toolkit/blog/2017/09/microsoft-facebook-create-open-ecosystem-ai-model-interoperability/
/r/MachineLearning
https://redd.it/6yosis
https://www.microsoft.com/en-us/cognitive-toolkit/blog/2017/09/microsoft-facebook-create-open-ecosystem-ai-model-interoperability/
/r/MachineLearning
https://redd.it/6yosis
Microsoft Cognitive Toolkit
Microsoft and Facebook create open ecosystem for AI model interoperability - Microsoft Cognitive Toolkit
At Microsoft our commitment is to make AI more accessible and valuable for everyone. We offer a variety of platforms and tools to facilitate this, including our Cognitive Toolkit, an open source framework for building deep neural networks. We also work with…
Google Search unofficial API for Python with no external dependencies
https://github.com/aviaryan/python-gsearch
/r/Python
https://redd.it/6yom38
https://github.com/aviaryan/python-gsearch
/r/Python
https://redd.it/6yom38
GitHub
GitHub - aviaryan/python-gsearch: 🔍 Google Search unofficial API for Python with no external dependencies
🔍 Google Search unofficial API for Python with no external dependencies - aviaryan/python-gsearch
[Python-Dev] PEP 552: deterministic pycs
https://mail.python.org/pipermail/python-dev/2017-September/149313.html
/r/Python
https://redd.it/6yq7t2
https://mail.python.org/pipermail/python-dev/2017-September/149313.html
/r/Python
https://redd.it/6yq7t2
DRF serialization not working on many to many with through models
I have models with many-to-many relationships with a through model. I am trying to set up a DRF serializer to display this data, but I am getting an error message whenever I try to render the API.
# models.py - simplified
class Person(models.Model):
first_name = models.CharField(max_length=250)
last_name = models.CharField(max_length=250)
status = models.IntegerField(choices=STATUS_CHOICES)
village = models.ForeignKey(Village)
gender = models.IntegerField(choices=GENDER_CHOICES)
class Case(models.Model):
summary = models.TextField()
session = models.ForeignKey(Session, on_delete=models.CASCADE)
case_type = models.ForeignKey(CaseType)
court_type = models.IntegerField(choices=COURT_TYPES)
verdict = models.ForeignKey(Verdict)
litigants = models.ManyToManyField(Person, through='Litigant', related_name='litigants')
class Litigant(models.Model):
person = models.ForeignKey(Person, on_delete=models.CASCADE)
case = models.ForeignKey(Case, on_delete=models.CASCADE)
role = models.ForeignKey(Role)
fine = models.ForeignKey(Money, null=True, related_name='fine')
notes = models.TextField()
My serializers.py looks as such:
# serializers.py - simplified
class LitigantSerializer(serializers.ModelSerializer):
class Meta:
model = Litigant
fields = ('id', 'person', 'case', 'role', 'fine', 'notes')
class CaseSerializer(serializers.ModelSerializer):
litigants = LitigantSerializer(many=True, read_only=True)
class Meta:
model = Case
fields = ('id', 'summary', 'session', 'case_type', 'court_type', 'verdict', 'litigants')
class PersonSerializer(serializers.ModelSerializer):
class Meta:
model = Person
fields = ('id','first_name', 'last_name', 'village', 'status', 'gender')
My views.py is:
# views.py - simplified.
class PersonViewSet(viewsets.ModelViewSet):
queryset = Person.objects.all().order_by('village__name', 'last_name', 'first_name')
serializer_class = PersonSerializer
class CaseViewSet(viewsets.ModelViewSet):
queryset = Case.objects.all().order_by('session__village__name', 'session__date', 'court_type')
serializer_class = CaseSerializer
class LitigantViewSet(viewsets.ModelViewSet):
queryset = Litigant.objects.all().order_by('case__session__village__name', 'case__session__date', 'person__last_name',
'person__first_name')
serializer_class = LitigantSerializer
However, when I navigate to api/cases/ I receive the following error:
'RelatedManager' object has no attribute 'pk'
What is more annoying, is that when I only include id and notes in LitigantSerializer, only the id shows up... The notes are nowhere to be found.
Thank you for any help!
/r/django
https://redd.it/6yrh9k
I have models with many-to-many relationships with a through model. I am trying to set up a DRF serializer to display this data, but I am getting an error message whenever I try to render the API.
# models.py - simplified
class Person(models.Model):
first_name = models.CharField(max_length=250)
last_name = models.CharField(max_length=250)
status = models.IntegerField(choices=STATUS_CHOICES)
village = models.ForeignKey(Village)
gender = models.IntegerField(choices=GENDER_CHOICES)
class Case(models.Model):
summary = models.TextField()
session = models.ForeignKey(Session, on_delete=models.CASCADE)
case_type = models.ForeignKey(CaseType)
court_type = models.IntegerField(choices=COURT_TYPES)
verdict = models.ForeignKey(Verdict)
litigants = models.ManyToManyField(Person, through='Litigant', related_name='litigants')
class Litigant(models.Model):
person = models.ForeignKey(Person, on_delete=models.CASCADE)
case = models.ForeignKey(Case, on_delete=models.CASCADE)
role = models.ForeignKey(Role)
fine = models.ForeignKey(Money, null=True, related_name='fine')
notes = models.TextField()
My serializers.py looks as such:
# serializers.py - simplified
class LitigantSerializer(serializers.ModelSerializer):
class Meta:
model = Litigant
fields = ('id', 'person', 'case', 'role', 'fine', 'notes')
class CaseSerializer(serializers.ModelSerializer):
litigants = LitigantSerializer(many=True, read_only=True)
class Meta:
model = Case
fields = ('id', 'summary', 'session', 'case_type', 'court_type', 'verdict', 'litigants')
class PersonSerializer(serializers.ModelSerializer):
class Meta:
model = Person
fields = ('id','first_name', 'last_name', 'village', 'status', 'gender')
My views.py is:
# views.py - simplified.
class PersonViewSet(viewsets.ModelViewSet):
queryset = Person.objects.all().order_by('village__name', 'last_name', 'first_name')
serializer_class = PersonSerializer
class CaseViewSet(viewsets.ModelViewSet):
queryset = Case.objects.all().order_by('session__village__name', 'session__date', 'court_type')
serializer_class = CaseSerializer
class LitigantViewSet(viewsets.ModelViewSet):
queryset = Litigant.objects.all().order_by('case__session__village__name', 'case__session__date', 'person__last_name',
'person__first_name')
serializer_class = LitigantSerializer
However, when I navigate to api/cases/ I receive the following error:
'RelatedManager' object has no attribute 'pk'
What is more annoying, is that when I only include id and notes in LitigantSerializer, only the id shows up... The notes are nowhere to be found.
Thank you for any help!
/r/django
https://redd.it/6yrh9k
reddit
DRF serialization not working on many to many with... • r/django
I have models with many-to-many relationships with a through model. I am trying to set up a DRF serializer to display this data, but I am getting...
PEP 554 -- Multiple Interpreters in the Stdlib
https://www.python.org/dev/peps/pep-0554/
/r/Python
https://redd.it/6yp7kv
https://www.python.org/dev/peps/pep-0554/
/r/Python
https://redd.it/6yp7kv
Python REST API with Flask
https://sourcedexter.com/python-rest-api-flask/
/r/Python
https://redd.it/6ytpcd
https://sourcedexter.com/python-rest-api-flask/
/r/Python
https://redd.it/6ytpcd
Source Dexter
Python REST API with Flask - Source Dexter
This article introduces beginners to creating Python REST API with the Flask framework. It is a simple to use framework to exposing app services on the web
Functional linked lists in Python
https://dbader.org/blog/functional-linked-lists-in-python
/r/Python
https://redd.it/6ytmey
https://dbader.org/blog/functional-linked-lists-in-python
/r/Python
https://redd.it/6ytmey
dbader.org
Functional linked lists in Python – dbader.org
Linked lists are fundamental data structures that every programmer should know. This article explains how to implement a simple linked list data type in Python using a functional programming style.
[AF] How to display a Tree-data structure.
The Title already says almost everything.
I got this simple Tree Data structure where there are nodes and edges and want to display them. I don t know if it s possible to do this with jinja2 or some Flask Framework, could not find anything with google.
Any help, even knowing that it s not possible with Flask to do that, is appreciated
/r/flask
https://redd.it/6ytp97
The Title already says almost everything.
I got this simple Tree Data structure where there are nodes and edges and want to display them. I don t know if it s possible to do this with jinja2 or some Flask Framework, could not find anything with google.
Any help, even knowing that it s not possible with Flask to do that, is appreciated
/r/flask
https://redd.it/6ytp97
reddit
[AF] How to display a Tree-data structure. • r/flask
The Title already says almost everything. I got this simple Tree Data structure where there are nodes and edges and want to display them. I don...
A utility for organizing your downloads directory
https://github.com/chriscz/pysorter
/r/Python
https://redd.it/6yttvj
https://github.com/chriscz/pysorter
/r/Python
https://redd.it/6yttvj
GitHub
chriscz/pysorter
pysorter - A command line utility for organizing files and directories according to regex patterns.
Python Namesilo module
Hello,
I'm developing Python module (api wrapper) for [Namesilo service](https://www.namesilo.com/api_reference.php). It's open source and it's my first module in Python. I'm looking for some advice what to improve, what am I doing wrong or right. You can find module on my github [python-namesilo](https://github.com/goranvrbaski/python-namesilo)
Thanks!
/r/Python
https://redd.it/6yuiai
Hello,
I'm developing Python module (api wrapper) for [Namesilo service](https://www.namesilo.com/api_reference.php). It's open source and it's my first module in Python. I'm looking for some advice what to improve, what am I doing wrong or right. You can find module on my github [python-namesilo](https://github.com/goranvrbaski/python-namesilo)
Thanks!
/r/Python
https://redd.it/6yuiai
NameSilo
Search, Register & Manage Domains programmatically with our Domain API | NameSilo
Manage, search, and register domains effortlessly with NameSilo’s Domain API. Simplify your domain tasks programmatically.
The gamification package Django has been missing
https://github.com/mattjegan/django-gamification
/r/django
https://redd.it/6yu953
https://github.com/mattjegan/django-gamification
/r/django
https://redd.it/6yu953
GitHub
GitHub - mattjegan/django-gamification: The missing Django Gamification Package
The missing Django Gamification Package. Contribute to mattjegan/django-gamification development by creating an account on GitHub.
PyNomaly: outlier / anomaly detection using Local Outlier Probabilities (LoOP)
Hi all! I've been lurking on this sub for a little while now and thought I'd post a side project I have been working on. It's called PyNomaly, which uses Local Outlier Probabilities (LoOP) to score individual data points on the probability that they are an outlier. You can check it out [here](https://github.com/vc1492a/PyNomaly).
I'm looking for some feedback and folks that could try it out, do some testing and open some issues if there are any. Would appreciate some feedback from the community so I can improve the package! I hope some of you find it useful.
/r/pystats
https://redd.it/6yvu6m
Hi all! I've been lurking on this sub for a little while now and thought I'd post a side project I have been working on. It's called PyNomaly, which uses Local Outlier Probabilities (LoOP) to score individual data points on the probability that they are an outlier. You can check it out [here](https://github.com/vc1492a/PyNomaly).
I'm looking for some feedback and folks that could try it out, do some testing and open some issues if there are any. Would appreciate some feedback from the community so I can improve the package! I hope some of you find it useful.
/r/pystats
https://redd.it/6yvu6m
GitHub
GitHub - vc1492a/PyNomaly: Anomaly detection using LoOP: Local Outlier Probabilities, a local density based outlier detection method…
Anomaly detection using LoOP: Local Outlier Probabilities, a local density based outlier detection method providing an outlier score in the range of [0,1]. - vc1492a/PyNomaly
PEP 556 -- Threaded garbage collection
https://www.python.org/dev/peps/pep-0556/
/r/Python
https://redd.it/6yvea0
https://www.python.org/dev/peps/pep-0556/
/r/Python
https://redd.it/6yvea0
Python.org
PEP 556 -- Threaded garbage collection
The official home of the Python Programming Language
Paco - a coroutine-based library for concurrent programming based on asyncio with a clean api
I just wanted to give a shout-out to what I think is an excellent library that deserves more attention.
Utilizing the stdlib's asyncio module but providing a clean, functional api on top of it is a dream.
I highly recommend people take a look
https://github.com/h2non/paco
/r/Python
https://redd.it/6yx16r
I just wanted to give a shout-out to what I think is an excellent library that deserves more attention.
Utilizing the stdlib's asyncio module but providing a clean, functional api on top of it is a dream.
I highly recommend people take a look
https://github.com/h2non/paco
/r/Python
https://redd.it/6yx16r
GitHub
GitHub - h2non/paco: Small utility library for coroutine-driven asynchronous generic programming in Python
Small utility library for coroutine-driven asynchronous generic programming in Python - h2non/paco
Show r/python: wav2vec, a script/package for converting wave files to vector graphics
https://github.com/cristoper/wav2vec
/r/Python
https://redd.it/6yy2iq
https://github.com/cristoper/wav2vec
/r/Python
https://redd.it/6yy2iq
GitHub
GitHub - cristoper/wav2vec: Python package and cli tool to convert wave files (WAV or AIFF) to vector graphics (SVG, PostScript…
Python package and cli tool to convert wave files (WAV or AIFF) to vector graphics (SVG, PostScript, CVS) - cristoper/wav2vec
How to Generate FiveThirtyEight Graphs in Python
https://www.dataquest.io/blog/making-538-plots/
/r/Python
https://redd.it/6yxw95
https://www.dataquest.io/blog/making-538-plots/
/r/Python
https://redd.it/6yxw95
Dataquest
How to Generate FiveThirtyEight Graphs in Python – Dataquest
Impressed by the graphs on popular site FiveThirtyEight? This quick tutorial gets you started making your own eye-catching visualizations.