[D] Elad: Deep learning's impact on image processing, mathematics and humanity
https://sinews.siam.org/Details-Page/tabid/900/ArtMID/2243/ArticleID/2689/Deep,-Deep-Trouble
/r/MachineLearning
https://redd.it/69ptb2
https://sinews.siam.org/Details-Page/tabid/900/ArtMID/2243/ArticleID/2689/Deep,-Deep-Trouble
/r/MachineLearning
https://redd.it/69ptb2
SIAM News
Deep, Deep Trouble
By Michael Elad
I am really confused. I keep changing my opinion on a daily basis, and I cannot seem to settle on one solid view of this puzzle. No, I am not talking about world politics or the current U.S. president, but rather something far more critical…
I am really confused. I keep changing my opinion on a daily basis, and I cannot seem to settle on one solid view of this puzzle. No, I am not talking about world politics or the current U.S. president, but rather something far more critical…
Language Detection Library (Language Layer Wrapper)
https://github.com/gwuah/ogma
/r/Python
https://redd.it/69quam
https://github.com/gwuah/ogma
/r/Python
https://redd.it/69quam
GitHub
gwuah/ogma
ogma - A language detection library for Pythonista's. --------------\n [ Language-Layer-Api ]
[D] Oxford deep nlp 2017 solutions
My solutions here: https://github.com/mleue/oxford-deep-nlp-2017-solutions
I've recently been going through the lectures of oxford's 2017 deep nlp course (https://github.com/oxford-cs-deepnlp-2017). The course was well presented and I've really deepened my understanding of modern NLP methods.
Naturally I am going through the practicals as well. I've linked to the repo with my current progress but I feel a bit stuck atm.
The main task revolves around a multi-class classification of ~2k transcripts of TED talks. However, the dataset is heavily skewed with one class covering ~50% and some classes only around 3-5% of the data.
Practical 2 wants you to try a basic averaging over word-vectors approach and then pumping that through a single-hidden-layer NN. I've been trying to tweak a lot with preprocessing and tokenization but I can't come beyond ~66% accuracy on the test set.
In Practical 3 you are then supposed to try the same task with a RNN approach. I thought this might get better but I am basically stuck at around the same test set accuracy of ~66%.
Maybe not much more is possible, especially given the fact that there is very little data for some of the classes. Basically I am wondering if anyone else has gone through the course (or even attended the real deal at oxford) so we can get a discussion going.
Thanks in advance! //Michael
/r/MachineLearning
https://redd.it/69pzdg
My solutions here: https://github.com/mleue/oxford-deep-nlp-2017-solutions
I've recently been going through the lectures of oxford's 2017 deep nlp course (https://github.com/oxford-cs-deepnlp-2017). The course was well presented and I've really deepened my understanding of modern NLP methods.
Naturally I am going through the practicals as well. I've linked to the repo with my current progress but I feel a bit stuck atm.
The main task revolves around a multi-class classification of ~2k transcripts of TED talks. However, the dataset is heavily skewed with one class covering ~50% and some classes only around 3-5% of the data.
Practical 2 wants you to try a basic averaging over word-vectors approach and then pumping that through a single-hidden-layer NN. I've been trying to tweak a lot with preprocessing and tokenization but I can't come beyond ~66% accuracy on the test set.
In Practical 3 you are then supposed to try the same task with a RNN approach. I thought this might get better but I am basically stuck at around the same test set accuracy of ~66%.
Maybe not much more is possible, especially given the fact that there is very little data for some of the classes. Basically I am wondering if anyone else has gone through the course (or even attended the real deal at oxford) so we can get a discussion going.
Thanks in advance! //Michael
/r/MachineLearning
https://redd.it/69pzdg
GitHub
mleue/oxford-deep-nlp-2017-solutions
my solutions for oxford's "deep nlp 2017" practical assignments - mleue/oxford-deep-nlp-2017-solutions
[AF] FLASK_DEBUG=1 won't start my flask application?
Hello, so I just found out on Windows that I can't run my flask app when I set the debug to true.
I may have done something wrong with config files? Or is it the fault of cmder where I try to tun this app? Or ... I don't have a clue. Pretty new to this.
Log:
D:\Programovani\github\beta-issues (master)
λ set FLASK_APP=flaskr
D:\Programovani\github\beta-issues (master)
λ set FLASK_DEBUG=1
D:\Programovani\github\beta-issues (master)
λ flask run
* Serving Flask app "flaskr"
* Forcing debug mode on
* Restarting with stat
File "C:\Python36\Scripts\flask.exe", line 1
SyntaxError: Non-UTF-8 code starting with '\x90' in file C:\Python36\Scripts\flask.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
D:\Programovani\github\beta-issues (master)
λ set FLASK_DEBUG=0
D:\Programovani\github\beta-issues (master)
λ flask run
* Serving Flask app "flaskr"
* Forcing debug mode off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Without debug the app starts normally.
Edit: The app is modified *Official Flask Tutorial* Flaskr app. [GitHub repo](http://www.github.com/SonGokussj4/beta-issues)
/r/flask
https://redd.it/69kjlg
Hello, so I just found out on Windows that I can't run my flask app when I set the debug to true.
I may have done something wrong with config files? Or is it the fault of cmder where I try to tun this app? Or ... I don't have a clue. Pretty new to this.
Log:
D:\Programovani\github\beta-issues (master)
λ set FLASK_APP=flaskr
D:\Programovani\github\beta-issues (master)
λ set FLASK_DEBUG=1
D:\Programovani\github\beta-issues (master)
λ flask run
* Serving Flask app "flaskr"
* Forcing debug mode on
* Restarting with stat
File "C:\Python36\Scripts\flask.exe", line 1
SyntaxError: Non-UTF-8 code starting with '\x90' in file C:\Python36\Scripts\flask.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
D:\Programovani\github\beta-issues (master)
λ set FLASK_DEBUG=0
D:\Programovani\github\beta-issues (master)
λ flask run
* Serving Flask app "flaskr"
* Forcing debug mode off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Without debug the app starts normally.
Edit: The app is modified *Official Flask Tutorial* Flaskr app. [GitHub repo](http://www.github.com/SonGokussj4/beta-issues)
/r/flask
https://redd.it/69kjlg
Python Enhancement Proposals (PEPs)
PEP 263 – Defining Python Source Code Encodings | peps.python.org
This PEP proposes to introduce a syntax to declare the encoding of a Python source file. The encoding information is then used by the Python parser to interpret the file using the given encoding. Most notably this enhances the interpretation of Unicode ...
Hack for the Sea 2017 :: Come to Gloucester, MA and participate in our maritime hackathon!
http://hackforthesea.com
/r/IPython
https://redd.it/69rrdf
http://hackforthesea.com
/r/IPython
https://redd.it/69rrdf
hackforthesea.tech
Hack for the Sea 2017
Come to Gloucester, MA to use your hacking skills for longevity and sustainability in these volatile times
What CMS would you recommend for a basic brochure website?
Hi all,
I have been designing a "brochure" travel agency website with lots of content pages. I am at the stage where I need to start thinking about the backend. This will pretty much be my first web project / deployment.
The people who will be maintaining the site aren't very technical so I was looking for a nice and simple CMS (I think the standard Django admin won't cut it) so I was looking at a few different options like Django-CMS, Mezzanine, etc... Although some of these seem a bit overkill?
The features we are looking for are pretty much just keeping content updated on pages, adding/removing pages and maintaining a blog.
Reddit, what would you recommend? Thanks!
/r/django
https://redd.it/69r4hp
Hi all,
I have been designing a "brochure" travel agency website with lots of content pages. I am at the stage where I need to start thinking about the backend. This will pretty much be my first web project / deployment.
The people who will be maintaining the site aren't very technical so I was looking for a nice and simple CMS (I think the standard Django admin won't cut it) so I was looking at a few different options like Django-CMS, Mezzanine, etc... Although some of these seem a bit overkill?
The features we are looking for are pretty much just keeping content updated on pages, adding/removing pages and maintaining a blog.
Reddit, what would you recommend? Thanks!
/r/django
https://redd.it/69r4hp
reddit
What CMS would you recommend for a basic brochure website? • r/django
Hi all, I have been designing a "brochure" travel agency website with lots of content pages. I am at the stage where I need to start thinking...
How do you push updates to your Django website? Please help, prepare for the impending cringe.
I have a Django website on DigitalOcean. I used the one-click app for Django, and through many frustrations I ended up just overwriting the default app with my own app's code (I sshed in, pulled my git repo into a separate folder, and merged the folders with the existing one-click app default code).
When it comes to updates to my website code, I am currently forced to either A: ssh in and manually edit files with Vim or B: ssh in, pull my repo into a separate folder, and manually mv the new files into the correct Django project folders.
I understand if you're cringing really bad right now. Do you have tips on how I can improve my workflow?
* Should I put the entire project inside a Docker image?
* I have experience running databases inside Docker, but not entire projects. Would my PostgreSQL database go into a *separate* Docker image??
* Is there any way for me to set my repo up so that I can simply push to the `master` branch and that code gets written to my production server?
* It doesn't bother me to dish out more $$ for convenience in regards to hosting. This being said, do you have any suggestions as to which host I should be using?
/r/django
https://redd.it/69vomt
I have a Django website on DigitalOcean. I used the one-click app for Django, and through many frustrations I ended up just overwriting the default app with my own app's code (I sshed in, pulled my git repo into a separate folder, and merged the folders with the existing one-click app default code).
When it comes to updates to my website code, I am currently forced to either A: ssh in and manually edit files with Vim or B: ssh in, pull my repo into a separate folder, and manually mv the new files into the correct Django project folders.
I understand if you're cringing really bad right now. Do you have tips on how I can improve my workflow?
* Should I put the entire project inside a Docker image?
* I have experience running databases inside Docker, but not entire projects. Would my PostgreSQL database go into a *separate* Docker image??
* Is there any way for me to set my repo up so that I can simply push to the `master` branch and that code gets written to my production server?
* It doesn't bother me to dish out more $$ for convenience in regards to hosting. This being said, do you have any suggestions as to which host I should be using?
/r/django
https://redd.it/69vomt
reddit
How do you push updates to your Django website? Please... • r/django
I have a Django website on DigitalOcean. I used the one-click app for Django, and through many frustrations I ended up just overwriting the...
I need some help embedding a graph
I need some help getting a graph displaying on my site. For reference, I'm using matplotlib and mpld3 to do this. The graph itself seems to be working, but when i convert it to a JSON string to embed it in the HTML, I get a blank page. Then, the second time I try to load the page, there will be a runtime error: "main thread is not in main loop." I've been stuck on this for days lol, any help is appreciated.
/r/django
https://redd.it/69u34y
I need some help getting a graph displaying on my site. For reference, I'm using matplotlib and mpld3 to do this. The graph itself seems to be working, but when i convert it to a JSON string to embed it in the HTML, I get a blank page. Then, the second time I try to load the page, there will be a runtime error: "main thread is not in main loop." I've been stuck on this for days lol, any help is appreciated.
/r/django
https://redd.it/69u34y
reddit
I need some help embedding a graph • r/django
I need some help getting a graph displaying on my site. For reference, I'm using matplotlib and mpld3 to do this. The graph itself seems to be...
How can I do this?
I am trying to overlay a heat map (or conditional formatting, as Excel calls it) over a dataframe displayed within the notebook in Jupyter. Is there a way to do this?
/r/IPython
https://redd.it/69wddo
I am trying to overlay a heat map (or conditional formatting, as Excel calls it) over a dataframe displayed within the notebook in Jupyter. Is there a way to do this?
/r/IPython
https://redd.it/69wddo
reddit
How can I do this? • r/IPython
I am trying to overlay a heat map (or conditional formatting, as Excel calls it) over a dataframe displayed within the notebook in Jupyter. Is...
I'm struggling with implementing dataTables into my django app. StackOverflow tells me that jquery must be loaded first before the datatable.min.js. Did that already and it still doesn't work. HELP!!!
[Solved!](https://www.reddit.com/r/javascript/comments/69wcum/im_struggling_with_implementing_datatables_into/)
Here's the format of one of my html file
{% extends 'base.html' %}
{% block main_content %}
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
DataTables Advanced Tables
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Rendering engine</th>
<th>Browser</th>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<td>Trident</td>
<td>Internet Explorer 4.0</td>
<td>Win 95+</td>
<td class="center">4</td>
<td class="center">X</td>
</tr>
<tr class="even gradeC">
<td>Trident</td>
<td>Internet Explorer 5.0</td>
<td>Win 95+</td>
<td class="center">5</td>
<td class="center">C</td>
</tr>d
</tbody>
</table>
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
{% endblock %}
{% block javascript %}
<!-- Datatable JS -->
<script type="{% static 'js/jquery.dataTables.min.js' %}"></script>
<script type="{% static 'js/dataTables.bootstrap.min.js' %}"></script>
<script type="{% static 'js/dataTables.responsive.js' %}"></script>
<script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true
});
});
</script>
{% endblock %}
Here's the javascript segment of my Base.html
<!-- jQuery -->
<script src="{% static 'jquery/jquery.min.js' %}"></script>
<!-- Bootstrap Core JavaScript -->
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="{% static 'js/metisMenu.min.js' %}"></script>
<!-- Custom Theme JavaScript -->
<script src="{% static 'js/sb-admin-2.js' %}"></script>
{% block javascript %}
{% endblock %}
I'm just trying on replicating the datatable I found from a bootstrap theme into a django format. I'm desperate!
Here's the error that I get.
Uncaught TypeError: $(...).DataTable is not a function
Edit: Removed what was a redundant code
/r/django
https://redd.it/69wbj7
[Solved!](https://www.reddit.com/r/javascript/comments/69wcum/im_struggling_with_implementing_datatables_into/)
Here's the format of one of my html file
{% extends 'base.html' %}
{% block main_content %}
<!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
DataTables Advanced Tables
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Rendering engine</th>
<th>Browser</th>
<th>Platform(s)</th>
<th>Engine version</th>
<th>CSS grade</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<td>Trident</td>
<td>Internet Explorer 4.0</td>
<td>Win 95+</td>
<td class="center">4</td>
<td class="center">X</td>
</tr>
<tr class="even gradeC">
<td>Trident</td>
<td>Internet Explorer 5.0</td>
<td>Win 95+</td>
<td class="center">5</td>
<td class="center">C</td>
</tr>d
</tbody>
</table>
</div>
<!-- /.panel-body -->
</div>
<!-- /.panel -->
</div>
<!-- /.col-lg-12 -->
</div>
{% endblock %}
{% block javascript %}
<!-- Datatable JS -->
<script type="{% static 'js/jquery.dataTables.min.js' %}"></script>
<script type="{% static 'js/dataTables.bootstrap.min.js' %}"></script>
<script type="{% static 'js/dataTables.responsive.js' %}"></script>
<script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true
});
});
</script>
{% endblock %}
Here's the javascript segment of my Base.html
<!-- jQuery -->
<script src="{% static 'jquery/jquery.min.js' %}"></script>
<!-- Bootstrap Core JavaScript -->
<script src="{% static 'js/bootstrap.min.js' %}"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="{% static 'js/metisMenu.min.js' %}"></script>
<!-- Custom Theme JavaScript -->
<script src="{% static 'js/sb-admin-2.js' %}"></script>
{% block javascript %}
{% endblock %}
I'm just trying on replicating the datatable I found from a bootstrap theme into a django format. I'm desperate!
Here's the error that I get.
Uncaught TypeError: $(...).DataTable is not a function
Edit: Removed what was a redundant code
/r/django
https://redd.it/69wbj7
reddit
I'm struggling with implementing dataTables into my... • r/javascript
Here's the format of one of my html file {% extends 'base.html' %} {% block main_content %} <div...
Announcing Hack for the Sea 2017 :: Come to Gloucester, MA in September and participate in our maritime hackathon!
http://hackforthesea.com
/r/pystats
https://redd.it/69w3w7
http://hackforthesea.com
/r/pystats
https://redd.it/69w3w7
hackforthesea.tech
Hack for the Sea 2017
Come to Gloucester, MA to use your hacking skills for longevity and sustainability in these volatile times
Stable django deployments (without downtime)
https://kuttler.eu/en/post/django-deployments-without-downtime/
/r/django
https://redd.it/69wx5n
https://kuttler.eu/en/post/django-deployments-without-downtime/
/r/django
https://redd.it/69wx5n
kuttler.eu
Stable Django deployments without downtime
This post describes a deployment and maintenance method for Django projects that was designed with scalability in mind. The goal is to push new releases into production at any moment with minimal or no downtime. Upgrades can be performed with unprivileged…
10 awesome features of Python that you can't use because you refuse to upgrade to Python 3
http://www.asmeurer.com/python3-presentation/slides.html#1
/r/Python
https://redd.it/69ws4c
http://www.asmeurer.com/python3-presentation/slides.html#1
/r/Python
https://redd.it/69ws4c
reddit
10 awesome features of Python that you can't use... • r/Python
195 points and 43 comments so far on reddit
Extending the User Model
Hey guys,
I'm new to Python and Django so I apologize if this is a dumb question, but I'm looking for some guidance/help from your more experienced folks regarding extending the User model.
I want to be able to create users, but add one simple custom field for the user for "region". When a user registers (via a 'sign up' view/html form) I just want to them choose from regions I've specified and it be a value attached to that user.
I thought User.objects.create_user() would have a way to pass a custom field for a user but it seems not? Any help would be great, thanks!
/r/django
https://redd.it/69p7bt
Hey guys,
I'm new to Python and Django so I apologize if this is a dumb question, but I'm looking for some guidance/help from your more experienced folks regarding extending the User model.
I want to be able to create users, but add one simple custom field for the user for "region". When a user registers (via a 'sign up' view/html form) I just want to them choose from regions I've specified and it be a value attached to that user.
I thought User.objects.create_user() would have a way to pass a custom field for a user but it seems not? Any help would be great, thanks!
/r/django
https://redd.it/69p7bt
reddit
Extending the User Model • r/django
Hey guys, I'm new to Python and Django so I apologize if this is a dumb question, but I'm looking for some guidance/help from your more...
How can I use a form to populate empty fields in a model class' pre-existing instances?
[This is a snapshot of the django site I'm creating.](http://imgur.com/a/LmJen) Each of the content boxes (Corvette, Nathalie Emmanuel, etc.) is produced by iterating through instances of a model called "Noun."
There's one exception... the "Rating score" form field. That's pointed to a separate model called "NounScore." I can't figure out how to get each "Rating score" field to correlate with each "Noun" that surrounds it.
Every time a new Noun object is created, a corresponding NounScore object is created along with it (using a one to one field and django signals). I linked them together with a one to one field instead of a foreign key because each item is supposed to be rated only once... by a single user. Nouns only appear on the homepage of the user they were created for.
My goal is to increment the primary key of each NounScore object every time the template's for loop prints a new "Rating score" field to the screen.
I'm sorry if this is explained poorly, but I don't really have a clue what I'm doing. [Hopefully the example code helps](https://pastebin.com/mKHWGtBx). Thank you for any help! I'll be sure to pass it on in time.
/r/django
https://redd.it/69nm3a
[This is a snapshot of the django site I'm creating.](http://imgur.com/a/LmJen) Each of the content boxes (Corvette, Nathalie Emmanuel, etc.) is produced by iterating through instances of a model called "Noun."
There's one exception... the "Rating score" form field. That's pointed to a separate model called "NounScore." I can't figure out how to get each "Rating score" field to correlate with each "Noun" that surrounds it.
Every time a new Noun object is created, a corresponding NounScore object is created along with it (using a one to one field and django signals). I linked them together with a one to one field instead of a foreign key because each item is supposed to be rated only once... by a single user. Nouns only appear on the homepage of the user they were created for.
My goal is to increment the primary key of each NounScore object every time the template's for loop prints a new "Rating score" field to the screen.
I'm sorry if this is explained poorly, but I don't really have a clue what I'm doing. [Hopefully the example code helps](https://pastebin.com/mKHWGtBx). Thank you for any help! I'll be sure to pass it on in time.
/r/django
https://redd.it/69nm3a
Imgur
Imgur: The most awesome images on the Internet
Imgur: The most awesome images on the Internet.
What's the preferred approach to defining these relations (models and Django Rest Framework serializers)
I've read that circular imports is a 'code smell' and is fundamentally a bad design choice. I have an app that has models, User, Deck, Hand. I want the User to be able to create a Hand without needing to create a Deck, but also give the User the choice to put the Hand in the Deck if wanted. So I end up with something like this:
models.py:
class User(AbstractUser):
pass
class Deck(models.Model):
created = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=100, unique=True,
blank=False, null=False)
user = models.ForeignKey('users.User', related_name='decks',
on_delete=models.CASCADE, null=False)
class Hand(models.Model):
created = models.DateTimeField(auto_now_add=True)
deck = models.ForeignKey('goals.Deck', related_name='hands', on_delete=models.CASCADE, null=True)
name = models.CharField(max_length=100, blank=False, null=False)
user = models.ForeignKey('users.User', related_name='hands', on_delete=models.CASCADE, null=False)
serializers.py:
class HandSerializer(serializers.HyperlinkedModelSerializer):
user = serializers.ReadOnlyField(source='user.username')
deck = serializers.CharField(required=False, source='deck.name')
class Meta:
model = Hand
fields = ('url', 'id', 'created',
'deck', 'name', 'user')
extra_kwargs = {
'url': {
'view_name': 'goals:hand-detail',
}
}
class DeckSerializer(serializers.HyperlinkedModelSerializer):
user = serializers.ReadOnlyField(source='user.username')
hands = HandSerializer(many=True, read_only=True)
class Meta:
model = Deck
fields = ('url', 'id', 'created', 'name', 'user')
extra_kwargs = {
'url': {
'view_name': 'goals:deck-detail',
}
}
class UserSerializer(serializers.HyperlinkedModelSerializer):
decks = DeckSerializer(many=True)
hands = HandSerializer(many=True)
...
Is this the correct approach API-design-wise in order to achieve what I want app-design-wise? If not, how should I go about doing this? And if so, how do I get around the circular import errors when I change user from a ReadOnlyField to a UserSerializer() field?
/r/django
https://redd.it/69zh7q
I've read that circular imports is a 'code smell' and is fundamentally a bad design choice. I have an app that has models, User, Deck, Hand. I want the User to be able to create a Hand without needing to create a Deck, but also give the User the choice to put the Hand in the Deck if wanted. So I end up with something like this:
models.py:
class User(AbstractUser):
pass
class Deck(models.Model):
created = models.DateTimeField(auto_now_add=True)
name = models.CharField(max_length=100, unique=True,
blank=False, null=False)
user = models.ForeignKey('users.User', related_name='decks',
on_delete=models.CASCADE, null=False)
class Hand(models.Model):
created = models.DateTimeField(auto_now_add=True)
deck = models.ForeignKey('goals.Deck', related_name='hands', on_delete=models.CASCADE, null=True)
name = models.CharField(max_length=100, blank=False, null=False)
user = models.ForeignKey('users.User', related_name='hands', on_delete=models.CASCADE, null=False)
serializers.py:
class HandSerializer(serializers.HyperlinkedModelSerializer):
user = serializers.ReadOnlyField(source='user.username')
deck = serializers.CharField(required=False, source='deck.name')
class Meta:
model = Hand
fields = ('url', 'id', 'created',
'deck', 'name', 'user')
extra_kwargs = {
'url': {
'view_name': 'goals:hand-detail',
}
}
class DeckSerializer(serializers.HyperlinkedModelSerializer):
user = serializers.ReadOnlyField(source='user.username')
hands = HandSerializer(many=True, read_only=True)
class Meta:
model = Deck
fields = ('url', 'id', 'created', 'name', 'user')
extra_kwargs = {
'url': {
'view_name': 'goals:deck-detail',
}
}
class UserSerializer(serializers.HyperlinkedModelSerializer):
decks = DeckSerializer(many=True)
hands = HandSerializer(many=True)
...
Is this the correct approach API-design-wise in order to achieve what I want app-design-wise? If not, how should I go about doing this? And if so, how do I get around the circular import errors when I change user from a ReadOnlyField to a UserSerializer() field?
/r/django
https://redd.it/69zh7q
reddit
What's the preferred approach to defining these... • r/django
I've read that circular imports is a 'code smell' and is fundamentally a bad design choice. I have an app that has models, User, Deck, Hand. I...
Best way to test Django REST API with Authentication?
I've successfully built a Django REST API with a few preliminary endpoints. They work fine and I can test them in a browser or with 'curl' in Terminal.
However, now I'd like to implement Authentication. Once Authentication is in place, is using something like Postman the only way to test the endpoints?
Currently reading this: http://www.django-rest-framework.org/api-guide/authentication/ Which Authentication approach have you used for your REST APIs? Session? Token? Something else?
Robert
/r/django
https://redd.it/69ztz0
I've successfully built a Django REST API with a few preliminary endpoints. They work fine and I can test them in a browser or with 'curl' in Terminal.
However, now I'd like to implement Authentication. Once Authentication is in place, is using something like Postman the only way to test the endpoints?
Currently reading this: http://www.django-rest-framework.org/api-guide/authentication/ Which Authentication approach have you used for your REST APIs? Session? Token? Something else?
Robert
/r/django
https://redd.it/69ztz0
www.django-rest-framework.org
Authentication - Django REST framework
Django, API, REST, Authentication
Not understanding field__icontains?
I'm having a problem implementing a database query using a string.
I've tried many different methods with all of the same results, and am nowhere closer to the goal.
#urls.py
url(r'^api/v1/item/nomen/contains/(?P<nomen>[\w\-]+)/$', views.ItemListContainsNomen.as_view(), name='item_lookup_contains_nomen'),
#views.py
class ItemListContainsNomen(generics.ListAPIView):
serializer_class = ItemSerializer
def get_queryset(self):
nomen = self.kwargs['nomen']
return Item.objects.filter(nomenclature__icontains=nomen)
class Item(models.Model):
id = models.IntegerField(primary_key=True)
nomenclature = models.CharField(max_length=35)
This nets me a warning such as
> "/.virtualenvs/realDjango/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py:110: Warning: Truncated incorrect DOUBLE value: 'nomen/contains/CLOSER'
>
> return self.cursor.execute(query, args)
>
> Not Found: /api/v1/item/nomen/contains/CLOSER/"
I can successfully run this query using the MYSQL console and raw MYSQL with LIKE, and I can successfully query another database's TextField using the same syntax in Django.....but this column just doesn't seem to work no matter what. There has to be something I'm missing. I should also note, replacing icontains=nomen with say, icontains="CLOSER" also yields the same errors.
Checking datatype in console shows
> +-----------+
> | DATA_TYPE |
> +-----------+
> | varchar |
> +-----------+
> 1 row in set (1.39 sec)
/r/django
https://redd.it/6a0tz9
I'm having a problem implementing a database query using a string.
I've tried many different methods with all of the same results, and am nowhere closer to the goal.
#urls.py
url(r'^api/v1/item/nomen/contains/(?P<nomen>[\w\-]+)/$', views.ItemListContainsNomen.as_view(), name='item_lookup_contains_nomen'),
#views.py
class ItemListContainsNomen(generics.ListAPIView):
serializer_class = ItemSerializer
def get_queryset(self):
nomen = self.kwargs['nomen']
return Item.objects.filter(nomenclature__icontains=nomen)
class Item(models.Model):
id = models.IntegerField(primary_key=True)
nomenclature = models.CharField(max_length=35)
This nets me a warning such as
> "/.virtualenvs/realDjango/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py:110: Warning: Truncated incorrect DOUBLE value: 'nomen/contains/CLOSER'
>
> return self.cursor.execute(query, args)
>
> Not Found: /api/v1/item/nomen/contains/CLOSER/"
I can successfully run this query using the MYSQL console and raw MYSQL with LIKE, and I can successfully query another database's TextField using the same syntax in Django.....but this column just doesn't seem to work no matter what. There has to be something I'm missing. I should also note, replacing icontains=nomen with say, icontains="CLOSER" also yields the same errors.
Checking datatype in console shows
> +-----------+
> | DATA_TYPE |
> +-----------+
> | varchar |
> +-----------+
> 1 row in set (1.39 sec)
/r/django
https://redd.it/6a0tz9
reddit
Not understanding field__icontains? • r/django
I'm having a problem implementing a database query using a string. I've tried many different methods with all of the same results, and am nowhere...
Anyone familiar with Django deployment with AWS?
I am able to deploy my django app to AWS with no issues with Nginx and Gunicorn. My site functions properly at the public IP. Now I'm trying to point my domain name to the AWS instance.
I followed the instructions [here](https://u.osu.edu/walujo.1/2016/07/07/associate-namecheap-domain-to-amazon-ec2-instance/) and I can't even access the elastic IP (Bad Request 400 error). AWS is configured properly to allow incoming HTTP/S requests.
I'm willing to pay for someone to help me get this resolved, if anyone was so inclined. I'm brand new to deployment and can't wrap my head around what's going wrong.
/r/djangolearning
https://redd.it/69sk3x
I am able to deploy my django app to AWS with no issues with Nginx and Gunicorn. My site functions properly at the public IP. Now I'm trying to point my domain name to the AWS instance.
I followed the instructions [here](https://u.osu.edu/walujo.1/2016/07/07/associate-namecheap-domain-to-amazon-ec2-instance/) and I can't even access the elastic IP (Bad Request 400 error). AWS is configured properly to allow incoming HTTP/S requests.
I'm willing to pay for someone to help me get this resolved, if anyone was so inclined. I'm brand new to deployment and can't wrap my head around what's going wrong.
/r/djangolearning
https://redd.it/69sk3x