Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions days/069-072-django-rest/demo/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

class QuoteSerializer(serializers.ModelSerializer):

# This is not included in the videos. Without this setting, it was possible
# to set the user value to something other than the currently logged-in
# user. This setting hides the user field from the form in the API frontend
# and sets the currently logged-in users as the field value by default.
# See also: https://stackoverflow.com/a/53193276
user = serializers.HiddenField(default=serializers.CurrentUserDefault())

class Meta:
model = Quote
fields = ('quote', 'author', 'source', 'cover', 'user')
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,40 @@ <h2>Sign up today!</h2>
<div class="mui-textfield">
{{ form.username.label }}
{{ form.username }}
<div class="mui--text-danger">
{% for error in form.username.errors %}
{{ error }}
{% endfor %}
</div>
</div>
<div class="mui-textfield">
{{ form.email.label }}
{{ form.email }}
<div class="mui--text-danger">
{% for error in form.email.errors %}
{{ error }}
{% endfor %}
</div>
</div>
<div class="mui-textfield">
{{ form.password1.label }}
{{ form.password1 }}
<div class="mui--text-danger">
{% for error in form.password1.errors %}
{{ error }}
{% endfor %}
</div>
</div>
<div class="mui-textfield">
{{ form.password2.label }}
{{ form.password2 }}
<div class="mui--text-danger">
{% for error in form.password2.errors %}
{{ error }}
{% endfor %}
</div>
</div>
<!-- {{ form.as_p }} -->

<input class="mui-btn mui-btn--primary" type="submit" value="{% trans 'Submit' %}" />
</form>
Expand Down
4 changes: 2 additions & 2 deletions days/069-072-django-rest/demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
django
django-registration
django==2.2
django-registration==3.0.1
djangorestframework
requests
django-rest-swagger
Binary file modified days/069-072-django-rest/starter_code.zip
Binary file not shown.