Thank you SO much to Bill Blanchard for helping me figure this out!

The main issue was that {{ formset.management_form }} was in the div being 
used by the javascrip to add/delete forms. So, it was causing the error. We 
moved it out of the div, just before the closing </form> tag and it worked 
great!

On Tuesday, March 31, 2015 at 12:11:42 AM UTC-4, Stephanie Socias wrote:
>
> Hello Again,
>
> I don't mean to take advantage of your kindness and generosity in helping 
> me- I'm so appreciative....I'm just still stuck on the ValidationError 
>
> [u'ManagementForm data is missing or has been tampered with']
>
> Error during template rendering
>
> In template 
> /Users/stephani/git/data/data/databank_fr/templates/data/register_dataset.html,
>  
> error at line *6*
> ManagementForm data is missing or has been tampered with1{% load 
> crispy_forms_tags %} 2 3<script type="text/javascript"> 4 $(function() { 5 
> $('.authorFormset').formset({ 6 prefix: '{{ formset.prefix }}', 7 
> addText: 'Add Author', 8 deleteText: 'Remove Author', 9 }) 10 }) 11</script> 
> 12 13<form action="{% url 'databank:register' %}" method="post" 
> enctype="multipart/form-data"> 14 15 16 <div class="container"> 
> Traceback Switch to copy-and-paste view <http://localhost:8000/register/#>
>
>    - 
>    
> /Users/stephaniesocias/.virtualenvs/databank2/lib/python2.7/site-packages/django/core/handlers/base.py
>     in get_response
>    1. 
>       
>                           response = wrapped_callback(request, 
> *callback_args, **callback_kwargs)
>       
>       ...
>    ▶ Local vars <http://localhost:8000/register/#>
>    - /Users/stephan/git/data/databank_fr/databa/apps/databank/views.py in 
>    register
>    1. 
>       
>               'formset': author_formset, 'author_formset_helper': 
> author_formset_helper, 'contact_form': contact_form, 'terms_form': 
> terms_form})
>       
>       ...
>    ▶ Local vars <http://localhost:8000/register/#>
>    - 
>    
> /Users/stephan/.virtualenvs/data/lib/python2.7/site-packages/django/shortcuts.py
>     in render
>    1. 
>       
>           return HttpResponse(loader.render_to_string(*args, **kwargs),
>       
>       ...
>    ▶ Local vars <http://localhost:8000/register/#>
>    - 
>    
> /Users/stephan/.virtualenvs/data/lib/python2.7/site-packages/django/template/loader.py
>     in render_to_string
>    1. 
>       
>               return t.render(context_instance)
>       
>       ...
>    ▶ Local vars <http://localhost:8000/register/#>
>    
>
>
>
>
> I read that it might be an issue with having a form and a formset next to 
> each other? If I don't use the "add" or "remove" links, I can submit my page 
> (which contains other forms in addition to my formset) with just one form of 
> the formset. But, when I do 'add' or 'delete' to add another form to the 
> formset, I get the error. The post data, though, does seem to register the 
> additional form... 
>
> views.py
>
> def register(request):
>
>     dataset_form = DatasetForm()
>     facility_form = FacilityForm()
>     contact_form = FacilityContactForm()
>     terms_form = TermsForm()
>
>     author_formset = AuthorFormset(prefix='author')
>     author_formset_helper = AuthorFormsetHelper()
>
>     if request.method == 'POST':
>         dataset_form = DatasetForm(request.POST, request.FILES)
>         facility_form = FacilityForm(request.POST)
>         author_formset = AuthorFormset(data=request.POST, prefix='author')
>
>
>         contact_form = FacilityContactForm(request.POST)
>
>     return render(request, 'databank/register.html', {'dataset_form': 
> dataset_form, 'facility_form': facility_form, 
>         'formset': author_formset, 'author_formset_helper': 
> author_formset_helper, 'contact_form': contact_form, 'terms_form': 
> terms_form})
>
>
>
>
>
> On Mon, Mar 30, 2015 at 10:57 PM, Lachlan Musicman <data...@gmail.com> 
> wrote:
>
> likewise. likewise.
> ------
>  It is through this shadowy emptiness (of negative space) that we
> walk, talk, see, and live; negative space is the impossible cellophane
> layer that drapes the known world and is invisible to all but to the
> most perceptive minds.
>
> It is possible to learn to see negative space though, in both the
> visual and imagined worlds. The first step is developing the ability
> to see, and the second is learning — as romantic poet John Keats put
> it — to be “capable of being in uncertainties, mysteries, doubts,
> without any irritable reaching after fact & reason.”
> ----
> Seeking Genius in Negative Space, Chris Messina
>
> https://medium.com/genius-week/seeking-genius-in-negative-space-4e7c755f641f
>
>
> On 31 March 2015 at 13:50, Bill Blanchard <bill.blanch...@gmail.com> 
> wrote:
> > I fought with formsets for a week when I started. Glad I could pay it
> > forward a bit.
> >
> > On Mar 30, 2015 10:46 PM, "Stephanie Socias" <stephsoc...@gmail.com> 
> wrote:
> >>
> >> Aaaaah finally!
> >> I had jquery.formset.js in my base.html header. I moved it to my     {%
> >> block footer_js %}  and it worked!! Not sure why that's the 
> case....anyways,
> >> now on to the next issue ([u'ManagementForm data is missing or has been
> >> tampered with']) but I think I can hopefully fix that one!
> >>
> >> Thank you SOOOOOOO much!!
> >>
> >> On Mon, Mar 30, 2015 at 10:29 PM, Lachlan Musicman <data...@gmail.com>
> >> wrote:
> >>>
> >>> Just checking you have
> >>>
> >>> {% load staticfiles %} in your templates - you will need in both iirc?
> >>> ------
> >>>  It is through this shadowy emptiness (of negative space) that we
> >>> walk, talk, see, and live; negative space is the impossible cellophane
> >>> layer that drapes the known world and is invisible to all but to the
> >>> most perceptive minds.
> >>>
> >>> It is possible to learn to see negative space though, in both the
> >>> visual and imagined worlds. The first step is developing the ability
> >>> to see, and the second is learning — as romantic poet John Keats put
> >>> it — to be “capable of being in uncertainties, mysteries, doubts,
> >>> without any irritable reaching after fact & reason.”
> >>> ----
> >>> Seeking Genius in Negative Space, Chris Messina
> >>>
> >>> 
> https://medium.com/genius-week/seeking-genius-in-negative-space-4e7c755f641f
> >>>
> >>>
> >>> On 31 March 2015 at 13:19, Bill Blanchard <bill.blanch...@gmail.com>
> >>> wrote:
> >>> > Sounds like a stupid question, but are you 100% sure that this is
> >>> > resolving
> >>> > correctly?
> >>> >
> >>> > <script src="{{ STATIC_URL }}js/jquery.formset.js"
> >>> > type="text/javascript"></script>
> >>> >
> >>> > You can check by monitoring the network tab when you go to inspect
> >>> > element
> >>> > in a chrome browser (or whatever the firefox equivalent is). When you
> >>> > refresh the page, it will tell you if that file is found or not.
> >>> >
> >>> > If it's found, then I might be stumped, or it might be some kind of
> >>> > import
> >>> > issue with the base jquery file or a conflict.
> >>> >
> >>> > If it's not found, you'll have to troubleshoot the issue related to
> >>> > pointing
> >>> > to the correct source location.
> >>> >
> >>> > Bill
> >>> >
> >>> >
> >>> >
> >>> > On Mon, Mar 30, 2015 at 9:54 PM, Stephanie Socias
> >>> > <stephsoc...@gmail.com>
> >>> > wrote:
> >>> >>
> >>> >> Sorry to ask here again but I still can't get the imports right for
> >>> >> some
> >>> >> reason. I get the error:
> >>> >>
> >>> >> TypeError: $(...).formset is not a function
> >>> >>
> >>> >> $('.authorFormset').formset({
> >>> >>
> >>> >>
> >>> >>
> >>> >> I have this in the head of my base.html:
> >>> >>
> >>> >>     <script
> >>> >>
> >>> >> src="
> https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
> "></script>
> >>> >>     <script src="{{ STATIC_URL }}js/jquery.formset.js"
> >>> >> type="text/javascript"></script>
> >>> >>
> >>> >>
> >>> >>
> >>> >> And then my homepage.html:
> >>> >>
> >>> >> {% load crispy_forms_tags %}
> >>> >>
> >>> >> <script type="text/javascript">
> >>> >>     $(function() {
> >>> >>         $('.authorFormset').formset({
> >>> >>             prefix: '{{ formset.prefix }}',
> >>> >>             addText: 'Add Author',
> >>> >>             deleteText: 'Remove Author',
> >>> >>         })
> >>> >>     })
> >>> >> </script>
> >>> >>
> >>> >> <form action="{% url 'data:register' %}" method="post"
> >>> >> enctype="multipart/form-data">
> >>> >>
> >>> >>
> >>> >>   <div class="container">
> >>> >>     <div class="row" style="margin-top: 30px">
> >>> >>       <div class="col-md-10 col-md-offset-1">
> >>> >>         {{ dataset_form.media }}
> >>> >>         {% crispy dataset_form %}
> >>> >>         {% crispy facility_form %}
> >>> >>         {% crispy contact_form %}
> >>> >>
> >>> >>         <div class="authorFormset">
> >>> >>         {% for form in formset.forms %}
> >>> >>             <div class="formset">
> >>> >>                 <div id="{{ form.prefix }}-row">
> >>> >>                     <div class="col-md-2">
> >>> >>                         <div class="row">
> >>> >>                             {{ form.first_name }}
> >>> >>                         </div>
> >>> >>                         <div class="row">
> >>> >>                             {{ form.last_name }}
> >>> >>                         </div>
> >>> >>                     </div>
> >>> >>                     <div class="col-md-4 col-md-offset-1">
> >>> >>                         <div class="row">
> >>> >>                             {{ form.email }}
> >>> >>                         </div>
> >>> >>                         <div class="row">
> >>> >>                             {{ form.role }}
> >>> >>                         </div>
> >>> >>                     </div>
> >>> >>                 </div>
> >>> >>             </div>
> >>> >>         {% endfor %}
> >>> >>         {{ formset.management_form }}
> >>> >>         <br><br>
> >>> >>     </div>
> >>> >>
> >>> >>       </div>
> >>> >>     </div>
> >>> >>   </div>
> >>> >>
> >>> >>   <div class="container">
> >>> >>     <div class="row">
> >>> >>       <div class="col-md-10 col-md-offset-1">
> >>> >>         <a role="button" class="btn btn-lg btn-default" href="{% url
> >>> >> 'data:data_home' %}">Cancel</a>
> >>> >>         <input type="submit" class="btn btn-lg btn-success 
> pull-right"
> >>> >> value="Proceed to Data Upload">
> >>> >>       </div>
> >>> >>     </div>
> >>> >>   </div>
> >>> >> </form>
> >>> >>
> >>> >>
> >>> >>
> >>> >> On Mon, Mar 30, 2015 at 8:38 PM, Bill Blanchard
> >>> >> <bill.blanch...@gmail.com>
> >>> >> wrote:
> >>> >>>
> >>> >>> You could have an import error somewhere/somehow with the
> >>> >>> jquery.formset.js file.  Also, you might need to import the jquery
> >>> >>> library
> >>> >>> in your application (I import mine in my base template, so that 
> might
> >>> >>> be why
> >>> >>> I forgot about it).
> >>> >>>
> >>> >>> On Mon, Mar 30, 2015 at 8:33 PM, Stephanie Socias
> >>> >>> <stephsoc...@gmail.com>
> >>> >>> wrote:
> >>> >>>>
> >>> >>>> Thank you, Bill! I'm getting a TypeError that $(...).formset is 
> not
> >>> >>>> a
> >>> >>>> function
> >>> >>>> I'll see what's up!
> >>> >>>>
> >>> >>>> On Mon, Mar 30, 2015 at 8:29 PM, Bill Blanchard
> >>> >>>> <bill.blanch...@gmail.com> wrote:
> >>> >>>>>
> >>> >>>>> Hi Stephanie,
> >>> >>>>> You have two jQuery selectors in your formset function and I'm 
> not
> >>> >>>>> sure
> >>> >>>>> if that will cause an issue or not.  Also, I don't think you need
> >>> >>>>> to use an
> >>> >>>>> id in the div tag (that was probably left over from when I was
> >>> >>>>> bashing my
> >>> >>>>> head against this).  Try naming the outer div class something not
> >>> >>>>> "formset"
> >>> >>>>> since you'll get two selections based on the classes you're 
> using.
> >>> >>>>> Try
> >>> >>>>> this:
> >>> >>>>> ...
> >>> >>>>> $(function() {
> >>> >>>>>         $('.authorFormset').formset({
> >>> >>>>> ....
> >>> >>>>> <div class="authorFormset">
> >>> >>>>>         {% for form in formset.forms %}
> >>> >>>>>             <div class="formset">
> >>> >>>>>                 <div id="{{ form.prefix }}-row">
> >>> >>>>>                     <div class="col-md-2">
> >>> >>>>> ...
> >>> >>>>>
> >>> >>>>> Also, try looking at the javascript console in your browser to 
> see
> >>> >>>>> if
> >>> >>>>> you get any error messages.  Hope this helps!
> >>> >>>>>
> >>> >>>>> Bill
> >>> >>>>>
> >>> >>>>> On Mon, Mar 30, 2015 at 8:19 PM, Stephanie Socias
> >>> >>>>> <stephsoc...@gmail.com> wrote:
> >>> >>>>>>
> >>> >>>>>> Thank you, Bill. That was silly of me. I'm just confused on
> >>> >>>>>> where/how
> >>> >>>>>> those actual links are displayed. I can't get them to show...
> >>> >>>>>>
> >>> >>>>>>
> >>> >>>>>> {% load crispy_forms_tags %}
> >>> >>>>>> <script src="{{ STATIC_URL }}js/addAuthor.js"
> >>> >>>>>> type="text/javascript"></script>
> >>> >>>>>> <script src="{{ STATIC_URL }}js/jquery.formset.js"></script>
> >>> >>>>>> <script type="text/javascript">
> >>> >>>>>>     $(function() {
> >>> >>>>>>         $('#authorFormset .formset').formset({
> >>> >>>>>>             prefix: '{{ formset.prefix }}',
> >>> >>>>>>             addText: 'Add Author',
> >>> >>>>>>             deleteText: 'Remove Author',
> >>> >>>>>>         })
> >>> >>>>>>     })
> >>> >>>>>> </script>
> >>> >>>>>>
> >>> >>>>>> <form action="{% url 'data:register' %}" method="post"
> >>> >>>>>> enctype="multipart/form-data">
> >>> >>>>>>
> >>> >>>>>>
> >>> >>>>>>   <div class="container">
> >>> >>>>>>     <div class="row" style="margin-top: 30px">
> >>> >>>>>>       <div class="col-md-10 col-md-offset-1">
> >>> >>>>>>         {{ dataset_form.media }}
> >>> >>>>>>         {% crispy dataset_form %}
> >>> >>>>>>         {% crispy facility_form %}
> >>> >>>>>>         {% crispy contact_form %}
> >>> >>>>>>
> >>> >>>>>>         <div id="authorFormset" class="formset">
> >>> >>>>>>         {% for form in formset.forms %}
> >>> >>>>>>             <div class="formset">
> >>> >>>>>>                 <div id="{{ form.prefix }}-row">
> >>> >>>>>>                     <div class="col-md-2">
> >>> >>>>>>                         <div class="row">
> >>> >>>>>>                             {{ form.first_name }}
> >>> >>>>>>                         </div>
> >>> >>>>>>                         <div class="row">
> >>> >>>>>>                             {{ form.last_name }}
> >>> >>>>>>                         </div>
> >>> >>>>>>                     </div>
> >>> >>>>>>                     <div class="col-md-4 col-md-offset-1">
> >>> >>>>>>                         <div class="row">
> >>> >>>>>>                             {{ form.email }}
> >>> >>>>>>                         </div>
> >>> >>>>>>                         <div class="row">
> >>> >>>>>>                             {{ form.role }}
> >>> >>>>>>                         </div>
> >>> >>>>>>                     </div>
> >>> >>>>>>                 </div>
> >>> >>>>>>             </div>
> >>> >>>>>>         {% endfor %}
> >>> >>>>>>         {{ formset.management_form }}
> >>> >>>>>>         <br><br>
> >>> >>>>>>     </div>
> >>> >>>>>>
> >>> >>>>>>       </div>
> >>> >>>>>>     </div>
> >>> >>>>>>   </div>
> >>> >>>>>>
> >>> >>>>>>   <div class="container">
> >>> >>>>>>     <div class="row">
> >>> >>>>>>       <div class="col-md-10 col-md-offset-1">
> >>> >>>>>>         <a role="button" class="btn btn-lg btn-default" href="{%
> >>> >>>>>> url
> >>> >>>>>> 'data:data_home' %}">Cancel</a>
> >>> >>>>>>         <input type="submit" class="btn btn-lg btn-success
> >>> >>>>>> pull-right"
> >>> >>>>>> value="Proceed to Data Upload">
> >>> >>>>>>       </div>
> >>> >>>>>>     </div>
> >>> >>>>>>   </div>
> >>> >>>>>> </form>
> >>> >>>>>>
> >>> >>>>>> On Mon, Mar 30, 2015 at 6:31 PM, Bill Blanchard
> >>> >>>>>> <bill.blanch...@gmail.com> wrote:
> >>> >>>>>>>
> >>> >>>>>>> Hi Stephanie,
> >>> >>>>>>> The addText and deleteText variables are the hyperlink text 
> that
> >>> >>>>>>> is
> >>> >>>>>>> displayed on the page.
> >>> >>>>>>>
> >>> >>>>>>> You can remove them or modify accordingly. I believe the 
> default
> >>> >>>>>>> values are Add Form and Remove Form if you do not explicitly
> >>> >>>>>>> declare them in
> >>> >>>>>>> the javascript function.
> >>> >>>>>>>
> >>> >>>>>>> On Mar 30, 2015 6:03 PM, "Stephanie Socias"
> >>> >>>>>>> <stephsoc...@gmail.com>
> >>> >>>>>>> wrote:
> >>> >>>>>>>>
> >>> >>>>>>>> Thank you all SO much for your advice. Even just hearing that
> >>> >>>>>>>> this
> >>> >>>>>>>> is a complicated problem and that it's not just me, really
> >>> >>>>>>>> helps.
> >>> >>>>>>>>
> >>> >>>>>>>> I will post my code shortly. I'm now trying to incorporate 
> some
> >>> >>>>>>>> of
> >>> >>>>>>>> your feedback.
> >>> >>>>>>>>
> >>> >>>>>>>> Bill,
> >>> >>>>>>>> How do I set/use the 'addText' and 'deleteText' variables from
> >>> >>>>>>>> the
> >>> >>>>>>>> script in the template? That is probably a really dumb 
> question
> >>> >>>>>>>> but I have
> >>> >>>>>>>> just about zero experience with javascript/jquery.
> >>> >>>>>>>>
> >>> >>>>>>>> Thank you!
> >>> >>>>>>>> Stephanie
> >>> >>>>>>>>
> >>> >>>>>>>> On Mon, Mar 30, 2015 at 5:18 PM, Carl Meyer <c...@oddbird.net
> >
> >>> >>>>>>>> wrote:
> >>> >>>>>>>>>
> >>> >>>>>>>>> Hi Stephanie,
> >>> >>>>>>>>>
> >>> >>>>>>>>> On 03/30/2015 02:37 PM, Stephanie Socias wrote:
> >>> >>>>>>>>> > I'm having trouble creating a formset where I can 
> dynamically
> >>> >>>>>>>>> > add
> >>> >>>>>>>>> > and
> >>> >>>>>>>>> > delete items. I've tried many different approaches and 
> can't
> >>> >>>>>>>>> > get
> >>> >>>>>>>>>
>
> ...

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/900845f2-05b2-42eb-a597-c27c93321a32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to