0

I want to write an inventory manager. i written a django app before and in the first app everything works fine, but now i got a problem. when i try to render the template i get the error:

  • ModelForm has no model class specified -

i looked up some forums and here in stack overflow was a guy with the same error, but he did only a typo. i checked my code threetimes, everything should be correct...

my model:

class Device (models.Model):

inventory_number = models.IntegerField()
device_name = models.CharField(max_length=64)
is_used = models.BooleanField()
user = models.ForeignKey(User, blank=True)
manufacturer = models.ForeignKey(Manufacturer, blank=True)
vendor = models.ForeignKey(Vendor, blank=True)
note = models.TextField(blank=True)
purchase_date = models.DateField(blank=True)


def __unicode__(self):
    return self.id

my modelform :

class DeviceForm(ModelForm):
    class Metal:
        model = Device

my view:

def create_device(request):

if request.method == 'POST':
    device_form = DeviceForm(request.POST)
    if device_form.is_valid():
        device_form.save()

    return HttpResponseRedirect ('/Inventory/')
device_form = DeviceForm()

c = RequestContext (request,{
    'device_form' : device_form
})
return render_to_response('create_device.html', c)

my template:

Inventar erfassen

the imports are correct... i rly don't know where i can find the fault thank u for help

1 Answer 1

3

It could just be a typo, but class Metal in the ModelForm should be class Meta:

class DeviceForm(ModelForm):
    class Meta:
        model = Device
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.