I would be careful how you pass the data on get, somewhere in your front
end code you are probably not passing the data through as you expected.
Instead of using .GET, use .GET.get to get your data. This will either
return the value you want, or none. I think you have made the error of not
passing your data to the get header as you didn't explicitly write this on
the form element. Check the URL and log the get object in Django to make
sure the data is actually appearing in both.

On Thu, Mar 7, 2019, 13:52 drone4four <drone4f...@gmail.com> wrote:

> Hello!
>
> I’m trying to run a basic Django app which redacts a 16 digit number
> entered by the user. I had a it running a few minutes ago. I’m not sure
> what I changed, but now I am getting a MultiValueDictKeyError. I’ve triple
> checked every variable. The only dictionary in my project is in views.py at
> line 7. As far as I can tell, it’s all accurate and positioned correctly. I
> don’t recall changing this dictionary or any other operator around this
> line. I’m stumped. What would you people suggest? Have a look at my setup.
>
>
> *Here is the error and traceback in full:* https://pastebin.com/QwSrmAJx
>
> Here is my urls.py:
> from django.conf.urls import  include, url
>
>
>
> from django.contrib import admin
>
> from django.urls import path
>
> from . import views
>
>
> urlpatterns = [
>
>    url(r'^admin/', admin.site.urls),
>
>    url(r'^$', views.home, name='home'),
>
>
>
> views.py:
> from django.http import HttpResponse
>
>
>
> from django.shortcuts import render
>
>
> def home(request):
>
>    number = request.GET['ccEntry']
>
>    redacted_num = 'xxxx xxxx xxxx {}'.format(number[-4:])
>
>    return render(request, 'home.html', {'number':number, 'redacted_num':
> redacted_num})
>
>
>
> home.html template:
> <style></style>
>
>
>
>
> <center>
>
> <form action="{% url 'home' %}">
>
>  <div>  <br>  <br>  <br>  <br>
>
>    <h3>Enter your fake Chuckee Cheese Neptune credit card number!</h3>
>
>    <input type="number" id="number" name="ccEntry" required placeholder="
> " pattern=".{16,16}"/>
>
>      <br>
>
>      <br>
>
>      <div class="requirements">
>
>        Must be a 16 digit number.
>
>      </div>
>
>      <br>
>
>    <input type="submit" value="Redact!!!"/>
>
>        </div>
>
>    </form>
>
>    <br>
>
>    <h3>Original Card Number:</h3>
>
>    <br>
>
>    {{ number }}
>
>    <br>
>
>    <h3>Redacted Card Number:</h3>
>
>    <br>
>
>    {{ redacted_num }}
>
>    <br>
>
>    <h3> Did this work?</h3>
>
>    <br>
>
> </center>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/49da3086-6f3d-415b-b451-7e4c6a6e542c%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/49da3086-6f3d-415b-b451-7e4c6a6e542c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHKA7fAzRPxGX29n374c7X9c-tqCL3MLAdq8F_bD_5_bdgZGhg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to