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

  • SEARCH
  • Home
  • 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 7787485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:41:17+00:00 2026-06-01T20:41:17+00:00

In Django I’m trying to write a ModelForm for a ContactForm and when I

  • 0

In Django I’m trying to write a ModelForm for a ContactForm and when I try to load the page containing the form it says that it doesn’t exist. Then when I try to render the other form I had previously written it says that

Caught AttributeError while rendering: 'CashtextsForm' object has no attribute 'subject'

‘Subject’ is a field in the form that I was trying to render in ContactForm. So is there some certain order I have to list them in models.py? Here’s that code:

# Create your models here.
from django.db import models
from django.forms import ModelForm

class Cashtexts(models.Model):
    cashTexts = models.CharField(max_length=100, blank=True) #change me to a website filter
    superPoints = models.CharField(max_length=100, blank=True)#chance to "superPoints _Username"
    varolo = models.CharField(max_length=100, blank=True)
    swagbucks = models.CharField(max_length=100, blank=True)
    neobux = models.CharField(max_length=100, blank=True)
    topline = models.CharField(max_length=100, blank=True)
    Paidviewpoint = models.CharField(max_length=100, blank=True)
    cashcrate = models.CharField(max_length=100, blank=True)


    def __unicode__(self):
        return self.cashcode

class Contact(models.Model):
    sender = models.EmailField()
    subject = models.CharField(max_length=25)
    message = models.TextField()

class CashtextsForm(ModelForm):
    class Meta:
        model = Cashtexts

    def __unicode__(self):
        return self.subject


class ContactForm(ModelForm):
    class Meta:
        model = Contact

I previously had them arranged as Model-Modelform, Model-Modelform but hereit shows them as the way I now currently have them.

Also Is there any advantages to write just forms? Right now I’m more comfortable writing model forms over forms(I dont imagine they are much differnt) but if I only wrote model forms would I be missing out on features? So is there anything I missed on how t write multiple forms in models.py or did I have them written worng? or can i not create them via the command syncdb?

  • 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-06-01T20:41:18+00:00Added an answer on June 1, 2026 at 8:41 pm

    The __unicode__(self) method should be part of your Contact class

    class Contact(models.Model):
        sender = models.EmailField()
        subject = models.CharField(max_length=25)
        message = models.TextField()
    
        def __unicode__(self):
            return self.subject
    

    It doens’t make sense inside CashtextsForm as that does not “know” a subject attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Django newbie question.... I'm trying to write a search form and maintain the state
sing django and jQuery I am trying to implement a button that, using the
Django has a number of open source projects that tackle one of the framework's
Django creates a search box on the list display page when the field search_fields
Django advanced beginner here. I'm banging my head against the wall trying to figure
Django seems to be falsely claiming that I have an error in my SQL
Django (1.2 beta) will reset the database(s) between every test that runs, meaning each
Django 1.2 allows usernames to take the form of an email address. Changed in
django forms seem to be oriented for rerdirecting the user to a different page
Django has a DATE_FORMAT and a DATE_TIME_FORMAT options that allow us to choose which

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.