Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6473923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:31:27+00:00 2026-05-25T06:31:27+00:00

I have a very simple model form, but for some reason, the code fails

  • 0

I have a very simple model form, but for some reason, the code fails to syncdb and throws an error: AttributeError: ‘module’ object has no attribute ‘CharField’

the code is as follows (in my models.py):

from django.db import models
from django.forms import ModelForm, Textarea, forms
from django.forms.fields import DateField, ChoiceField, MultipleChoiceField

class SubmitJobDTP(models.Model):
    SERVICE_CHOICES = (
        ('blog', (
            ('DTP1', 'cccccccccccccccccc: GBP 65.00'),
            ('DTP2', 'vvvvvvvvvvvvvvvvvv: GBP 110.00'),
            ('DTP3', 'bbbbbbbbbbbbbbbbbb: GBP 175.00'))
        )
    )
    package = models.CharField(max_length=5, choices=SERVICE_CHOICES)
    firstname = models.CharField(max_length=25)
    lastname = models.CharField(max_length=25)
    contact_number = models.CharField(max_length=25)
    email_address = models.EmailField()    
    attachment_1 = models.FileField(upload_to='uploadir')
    attachment_2 = models.FileField(upload_to='uploadir')
    attachment_3 = models.FileField(upload_to='uploadir')
    attachment_4 = models.FileField(upload_to='uploadir')
    attachment_5 = models.FileField(upload_to='uploadir')
    comments = models.CharField(max_length=150)

class SubmitJobForm(ModelForm): 
    attachment_1 = forms.FileField(label='Attach file 1',required=False)
    attachment_2 = forms.FileField(label='Attach file 2',required=False)
    attachment_3 = forms.FileField(label='Attach file 3',required=False)
    attachment_4 = forms.FileField(label='Attach file 4',required=False)
    attachment_5 = forms.FileField(label='Attach file 5',required=False)
    package = forms.CharField(required=False)
    firstname = forms.CharField(required=False)
    lastname = forms.CharField(required=False)
    contact_number = forms.IntegerField(required=False)
    email_address = forms.EmailField(required=False)

    class Meta:
        model = SubmitJobDTP
        fields = ('package', 'first name', 'last name', 'contact_number',
            'email_address', 'comments', 'attachment_1', 'attachment_2',
            'attachment_3', 'attachment_4', 'attachment_5')

A dpasted code is on: http://dpaste.com/607823/

I wonder what the problem could be: The FileField in the modelform syncdb’s correctly, but the other fields: CharField, IntegerField and EmailField do not seem to work. I have read the django docs on model form and I cannot seem to find anything particularly related to this error.

Any suggestions would be much apperciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:31:28+00:00Added an answer on May 25, 2026 at 6:31 am

    You’re not actually importing the forms module.

    >>> from django.forms import forms
    >>> forms.CharField
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
    AttributeError: 'module' object has no attribute 'CharField'
    >>> from django import forms
    >>> forms.CharField
    <class 'django.forms.fields.CharField'>
    

    So, you want to change your imports to the following:

    from django import forms
    

    Then to reference a ModelForm:

    class SubmitJobForm(forms.ModelForm):
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have very simple problem. I need to create model, that represent element of
I have a very simple model that includes the auto-filled field much like 'created'.
Ok, I have a model that is very simple: ServiceType(id: integer, title: string, duration:
I have a VERY simple windows form that the user uses to manage Stores.
I have created a very simple model called Discussion and one of the columns
I have a very simple issue: User model: class User < ActiveRecord::Base devise :database_authenticatable,
I currently have a very simple model Coupon. I suddenly am interested to add
I have a very simple rails 3 program with 2 models: a user model
I am posting a very simple form using a method I have used frequently
I am trying to model a very simple system, but the Rails way of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.