python - ValueError: Could not find function url in draco.apps.home.models -


I'm just expanding my user model, adding fields like user, photo, phone, email. My problem occurs when I am the entire message that I migrate to the console with the command "./manage.py makemigrations":

  ValueError: function url in dracoin.apps.home.models could get. Please note that due to limitations of Python 2, you can not sort unbound method functions (for example a method is declared and used in the same class). To use the migration, move the function to the main module body.   

Here are my "models.py" (I believe this is the root of .py mistake):

  from django.db import model From Django.contrib.auth.models import user class userProfile (models.Model): def url (self, file name): ruta = "multimedia data / user /% s /% s"% (self.user.username, filename ) Retire Rita User = models.OneToOneField (user) Photo = Model. ImageField (upload_to = url) phone = model.Churchfield (max_long = 30) email = model.mail field (max_language = 75) def __unicode __ (self): return self. User User   

I am apologizeme in advance, in the new python and if I ignore something.

Thank you!

The error message actually tells you what the problem is - this url In the definition of , the field is a bound method, which can not be sorted - and it also gives you a solution, which is to transfer the method outside the class into the main function. It means:

  def url (obj, filename): ruta = "multimedia data / user /% s /% s"% (obj.user.username, filename) retired class user profile (Models.Model): user = models.OneToOneField (user) photo = models.ImageField (upload_to = url)    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -