Python Forum
module object has no attribute after using different version of Python
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
module object has no attribute after using different version of Python
#1
I have both versions python 2.7 and 3.4 installed. I am using some code which is developed under 2.7 but I am using under 3.4. So after compiling using the following command

python manage.py runserver
I get the following error -

File "C:\pyprojects\focus\site\general\forms.py", line 26, in Meta
model = models.UserProfile
AttributeError: 'module' object has no attribute 'UserProfile'

As models.py and forms.py is under same directory(general) so I have imported the model in forms.py in this way
from .models import models
Now in models.py I have defined the class

class UserProfile(models.Model, HashedPk):
        user = models.OneToOneField(User, unique=True)
        is_pro = models.BooleanField(default=False, blank=True)
        ......................................................
In forms.py the code is

class UserProfileForm(forms.ModelForm):
    class Meta:
        model = models.UserProfile
        .....................
Is there any special way to call the model in python 3.4.

Any help is highly appreciated.
Reply


Messages In This Thread
module object has no attribute after using different version of Python - by prithvi - Aug-05-2017, 07:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  run part of a script with a different version of Python jdog 2 494 Jan-09-2024, 08:49 PM
Last Post: jdog
  How to find out from outside Python (in Windows) the current version of Python? pstein 4 792 Oct-04-2023, 10:01 AM
Last Post: snippsat
  getpass.getpass() results in AttributeError: module 'os' has no attribute 'O_NOCTTY' EarthAndMoon 4 828 Oct-03-2023, 02:00 PM
Last Post: deanhystad
  AttributeError: '_tkinter.tkapp' object has no attribute 'username' Konstantin23 4 1,839 Aug-04-2023, 12:41 PM
Last Post: Konstantin23
  Python: AttributeError: 'PageObject' object has no attribute 'extract_images' Melcu54 2 4,057 Jun-18-2023, 07:47 PM
Last Post: Melcu54
  Object attribute behavior different in 2 scripts db042190 1 786 Jun-14-2023, 12:37 PM
Last Post: deanhystad
  How to resolve version conflicts in Python? taeefnajib 0 956 Apr-27-2023, 08:37 PM
Last Post: taeefnajib
  cx_oracle Error - AttributeError: 'function' object has no attribute 'cursor' birajdarmm 1 2,485 Apr-15-2023, 05:17 PM
Last Post: deanhystad
  working with TLV module Object Jennifer_Jone 3 1,198 Mar-14-2023, 07:54 PM
Last Post: Jennifer_Jone
  Python venv and PIP version issue JanOlvegg 2 1,320 Feb-22-2023, 02:22 AM
Last Post: JanOlvegg

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020