Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango custom method won't show up
    text
    copied!<p>I have two custom methods for a model manager in Django. One of them works. I recently added another and Django (and python) act like it doesn't exist. Here's the relevant part of the model:</p> <pre><code>class FigureServerManager(models.Manager): #This method takes as input a user and grabs a figure that is not marked complete for which that user has not already submitted a result def serve_to_user(self,user): not_complete=super(FigureServerManager, self).get_query_set().filter(complete=0) for Figure in not_complete: checkifresult=User.objects.get(pk=user).result_set.all().filter(figure=Figure.id) if not checkifresult: return Figure #This is a copy of the above method that I want to change to do something else, but I can't even get it to show up yet def serve_training_task(self, user): with_correct_ans=super(FigureServerManager, self).get_query_set().filter(complete=0) for Figure in with_correct_ans: checkifresult=User.objects.get(pk=user).result_set.all().filter(figure=Figure.id) if not checkifresult: return Figure class Figure(models.Model): doi=models.CharField(max_length=20) url=models.CharField(max_length=200) image=models.ImageField(upload_to='classify') complete=models.BooleanField() #include the default manager objects=models.Manager() #add the extra one for serving figures serve_objects=FigureServerManager() </code></pre> <p>I get an error on the website (running the Django development server) like this:</p> <pre><code>'FigureServerManager' object has no attribute 'serve_training_task' </code></pre> <p>and if I run dir(FigureServerManager) in python the serve_training_task method does not appear but the serve_to_user method does appear. Why doesn't serve_training_task work?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload