it's a very strange way of import. if your forms and models are in the same 
python module, you can do
from . import models



On Saturday, August 5, 2017 at 11:01:01 PM UTC+3, Prithviraj Mitra wrote:
>
> 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.
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/a70b1f1e-14ca-4028-8706-cf03f3da5dfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to