....Like the code for ArtworkForm

On 7/26/12, Babatunde Akinyanmi <tundeba...@gmail.com> wrote:
> Looks good to me. Are you sure have shown us all the relevant parts of
> your code?
>
> On 7/25/12, Deathweasel <deathwea...@gmail.com> wrote:
>> Hello, guys.
>> This is Django 1.4.
>>
>> I have this code from my view:
>>
>> my_art = ArtworkModel.objects.get(id=pk)
>> comments = CommentModel.objects.filter(artwork=pk)
>> artForm = ArtworkForm(instance=my_art)
>> ...
>>
>> These models:
>>
>> class ArtworkModel(models.Model):
>>     """
>>         This class contains the information necessary to describe a piece
>> of
>>         artwork uploaded to my website. Technically, the artist field is
>>         unnecessary, but I'm throwing it in because I'd like to be able
>>         to upload collaborations.
>>     """
>>     MEDIUMS = (('ink', 'ink'),
>>                ('graphite', 'graphite'),
>>                ('watercolor', 'watercolor'),
>>                ('oil', 'oil'),
>>                ('acrylic', 'acrylic'),
>>                ('digital', 'digital'),
>>                ('sculpture', 'sculpture'),
>>                ('other','other'))
>>
>>     title = models.CharField(max_length=200)
>>     medium = models.CharField(max_length=200, choices=MEDIUMS,
>> default='graphite')
>>     upload_date = models.DateTimeField(auto_now_add=True)
>>     artist = models.CharField(max_length=200)
>>     image = models.ImageField(upload_to=getFilePath)
>>     desc = models.TextField(verbose_name="Description", max_length=500)
>>
>>     class Meta:
>>         ordering = ['title']
>>
>>     def __unicode__(self):
>>         return '-'.join((self.title, self.artist, self.medium))
>>
>> class CommentModel(models.Model):
>>     """
>>         This class contains the information necessary to describe a
>> comment
>>         that someone's left about a piece of artwork.
>>     """
>>     commenteer = models.CharField(max_length=200, blank=False)
>>     comment_body = models.TextField(blank=False)
>>     artwork = models.ForeignKey(ArtworkModel)
>>     date = models.DateTimeField(auto_now_add=True)
>>
>>     class Meta:
>>         ordering = ['date']
>>
>>
>> And this traceback:
>> Traceback:
>> File
>> "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
>> in get_response
>>   111.                         response = callback(request,
>> *callback_args,
>>
>> **callback_kwargs)
>> File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py"
>> in
>>
>> _wrapped_view
>>   91.                     response = view_func(request, *args, **kwargs)
>> File "/home/deathweasel/shiny-website/deathweasel/artwork/views.py" in
>> modify_artwork
>>   94.         artForm = ArtworkForm(instance=my_art)
>> File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in
>> __init__
>>   238.             object_data = model_to_dict(instance, opts.fields,
>> opts.exclude)
>> File "/usr/local/lib/python2.7/dist-packages/django/forms/models.py" in
>> model_to_dict
>>   111.     opts = instance._meta
>>
>> Exception Type: AttributeError at /artwork/8/modify/
>> Exception Value: 'QuerySet' object has no attribute '_meta'
>>
>> The internet says I should be using a regular Model instance rather than
>> a
>> QuerySet to populate my form. The thing is that I think I AM using a
>> regular model. I'm not even using
>> those CommentModels yet. I don't understand why this is failing? Please
>> help?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/_eRwn1qmzr0J.
>> To post to this group, send email to django-users@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.
>>
>>
>
> --
> Sent from my mobile device
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.

Reply via email to