Thank you for your reply. Helped a lot. When issuing the code, I get a error.
*error* UnboundLocalError at /cm/1/cv/ local variable 'cvdb' referenced before assignment Request Method: GET Request URL: http://lab.cpcstrans.com/cm/1/cv/ Exception Type: UnboundLocalError Exception Value: local variable 'cvdb' referenced before assignment Exception Location: /home/cpcs/portal/cm/views.py in cvdetails, line 585 Line 585 is : cvdb=get_object_or_404(cvdb, id=id) I read on django the best option is to change the name. cvdb changed to cv. so new line reads. cv=get_object_or_404(cvdb, id=id) but now it says type object: "cvdb" does not have attribute "id" :S my new written field is username=User.objects.get(pk=id) -->outputs "super user" cv=get_object_or_404(cvdb, user=username) --> queries as user being "super user" but i still get the error type object: "cvdb" does not have attribute "id" no idea why. must be the lines below it. any thoughts? thank you On Apr 16, 11:19 am, Tom Evans <tevans...@googlemail.com> wrote: > On Fri, Apr 16, 2010 at 4:01 PM, Daxal <daxal.someone...@gmail.com> wrote: > > hi anyone know how to populate the manytomany fields in models on the > > template? > > > *models* > > from django.db import models > > from django.forms import ModelForm > > > class cvdb(models.Model): > > user = models.ForeignKey(User) > > Language = models.ManyToManyField(Language, > > db_table='cm_cvdb_language', > > verbose_name="languages") > > ProfDesgn = models.ManyToManyField(ProfDesgn, > > db_table='cm_cvdb_profdesgn', > > verbose_name="professional > > designation", blank=True) > > Practice = models.ManyToManyField(Practice, > > db_table='cm_cvdb_practice', > > verbose_name="Practice", > > blank=True) > > Sector = models.ManyToManyField(Sector, db_table='cm_cvdb_sector', > > verbose_name="Sector", blank=True) > > Profession = models.ManyToManyField(Profession, > > db_table='cm_cvdb_profession', > > verbose_name="Profession", > > blank=True) > > Country = models.ManyToManyField(Country, > > db_table='cm_cvdb_country', > > verbose_name="Country", blank=True) > > > *modelform defined in models* > > class cvForm(ModelForm): > > class Meta: > > model = cvdb > > > *views so far - NEED some help here * thnkyou > > > def cvdetails(request, id): > > cvdb = get_object_or_404(cvdb, id=id) > if request.method == 'POST': > f = cvform(instance=cvdb, data=request.POST) > if f.is_valid(): > f.save() > else: > f = cvform(instance=cvdb) > return render_to_response('cm/cvdetails.html', > context_instance=RequestContext(request, {'form': f})) > > > f = cvForm(request.POST) > > return render('cm/cvdetails.html', request) > > > any ideas on how to make the view the right way? i cant seem to find > > many resources. > > > right now my template shows > > <form action="../cv/" method="post"> > > {{ form.Language }} > > {{ form.Country }} ...etc > > <input type="submit" value="submit"> > > </form> > > > thanks. any help would be much appreciated. <3 > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.