Most of the time, it help to provide the full stack trace that come
with the error. The one in the console where you started django should
be easier to copy and paste.

In your case, it look like a typo. In forms.py, it should be `class
Meta` and you wrote `class meta`.


An alternative is to use class based views. I wrote a few examples
covering the most useful case on stackoverflow [1]. For your code, it
boild down to replace the view with that:

    from django.core.urlresolvers import reverse_lazy
    from django.views.generic.edit import CreateView
    from .models import Registerform

    class RegisterView(CreateView):
        template_name = "register.html"
        model = Registerform
        fields = ["FirstName", "LastName", "Myprofile", "Myresume",
"Bio", "State", "Country"]
        success_url = reverse_lazy("app:views")

Then in your urls.py file, you use RegisterView.as_view() instead of
register. The RegisterView will take care of creating a form based on
the models, validating the data, saving the object in database,
handling get and post request.


[1] http://stackoverflow.com/documentation/django/1220/class-based-views

2016-10-10 11:16 GMT+02:00 prashant joshi <prashante...@gmail.com>:
> i created model form
>
>
>
>
> model.py
> from django.db import models
> from django.utils.encoding import python_2_unicode_compatible
> from django import forms
> from django.forms import ModelForm
>
>
>
> CATEGORIES = (
>     ('mh', 'Maharashtra'),
>     ('pb', 'Punjab'),
>     ('gj', 'Gujarat'),
>
> )
> Country = (
>     ('ind', 'India'),
>     ('uk', 'United Kingdom'),
>     ('sa', 'South Africa'),
>
> )
>
>
> class holidaytime(models.Model):
>     MYdob= models.DateField()
>     Time= models.DateTimeField()
> def __str__(self):
>      return self.name
> class Registerform(models.Model):
>     FirstName = models.CharField(max_length=200)
>     LastName = models.CharField(max_length=200)
>     Myprofile = models.FileField(upload_to='uploads/')
>     Myresume = models.FileField(upload_to='uploads/')
>     Bio = models.TextField()
>     State= models.CharField(max_length=3, choices=CATEGORIES)
>     Country= models.CharField(max_length=3, choices=Country)
>
>
> def __str__(self):
>
>
>
>
>
>
>
>
> forms,py
>
> from django import forms
> from .models import Registerform
> from django.forms import ModelForm
>
> class Regform(forms.ModelForm):
>     class meta:
>         model=Registerform
>
> fields=["FirstName","LastName","Myprofile","Myresume","Bio","State","Country"]
>      return self.name
>
>
>
> views.py
>
>
> from django.shortcuts import render
> from .forms import Regform
> # Create your views here.
> def register(request):
>     s=Regform(request.POST)
>     return render(request, 'webpage/register.html',{"s":s})
>
>
>
> register.html
> <!DOCTYPE html>
> <html>
> <head>
>     <title>Registration Form</title>
> </head>
> <body>
> <h1>Registration Form</h1>
> <form>{% csrf_token %}
>     {{form.as_p}}
> </form>
>
> </body>
> </html>
>
>
>
>
> it is not worked..it show
>
> ValueError at /task/
>
> ModelForm has no model class specified. this error
>
>
>
>
>
> --
> 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/6d5714b1-c526-4851-a6c9-4700498fc579%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTaJHFQSi8pmm9mKMBEr_89KK4T%2B%3DJJpQbH_oqjSjScx%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to