Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to add queryset to ManyToMany relationship?
I have following models: class EnMovielist(models.Model): content_ID = models.CharField(max_length=30) release_date = models.CharField(max_length=30) running_time = models.CharField(max_length=10) actress = models.CharField(max_length=300) series = models.CharField(max_length=30) studio = models.CharField(max_length=30, null=True) director = models.CharField(max_length=30) def __str__(self): return self.content_ID class EnActress(models.Model): name = models.CharField(max_length=100, null=True) movielist = models.ManyToManyField(EnMovielist, related_name='movies') def __str__(self): return self.name I got error when I try to this in Django shell, b = EnActress.objects.values_list('name', flat=True) a = EnMovielist.objects.filter(actress__contains=b).values_list('content_ID') b.movielist.add(a) AttributeError: 'QuerySet' object has no attribute 'movielist' How can I django queryset add into many-to-many field? I have no idea why this is happening.. Any help appreciated! :) -
Multiple in memory instances of same model
Lets say I have a process that fixes the username and email of a User model. def fix_model(user_id): user = User.objects.get(user_id) fix_username(user) # lets say for arguments' sake that we can't pass the user to fix_email (call it legacy) fix_email(user_id) user.save() def fix_username(user): user.username = 'correct_username' def fix_email(user_id): user = User.objects.get(user_id) user.email = 'correct_email' user.save() # <-- necessary because it is a standalone task Of course what will happen is that the user will first be saved inside the fix email call and then the in memory object is saved with the correct username. When we check the database afterwards we don't have the correct email address anymore. Of course this is a contrived example. There are many easy ways to fix it here, e.g. moving the user.save() up one line or return the instance of user in fix_email etc. In my real use case i have no direct control over when the models will be saved or the signature of the methods. My question is the following: Is there a way in Django to have all instances that are retrieved from the database pass through a manager of sorts, that will return pointers to the same in memory objects … -
How to recursively query in django efficiently?
I have a model, which looks like: class StaffMember(models.Model): id = models.OneToOneField(to=User, unique=True, primary_key=True, related_name='staff_member') supervisor = models.ForeignKey(to='self', null=True, blank=True, related_name='team_members') My current hierarchy of team is designed in such a way that there is let's say an Admin (who is at the top most point of hierarchy). Now, let's say 3 people (A, B, C) report to Admin and each one of A, B and C have their own team reporting to them and so on. I want to find all the team members (boiling down to the bottom most level of hierarchy), for any employee. My current method to get all the team members of a person is like: def get_team(self): team = [self] for c in self.team_members.all(): team += list(c.get_team()) if len(team) > 2000: break return team But obviously, this leads to a lot of db calls and my API eventually times out. What could be more efficient way to fetch all the members of a team? -
How to run celery with sqs without using celery command in backend in django
When we have used locally celery command celery -A proj worker -l info it's working fine. celery -A proj worker -l info when run this command showing like below as locally But, how we can use in backend celery with sqs. -------------- celery@ v3.1.18 (Cipater) ---- **** ----- --- * *** * -- Windows-8-6.2.9200 -- * - **** --- - ** ---------- [config] - ** ---------- .> app: workflow:0x3ba3610 - ** ---------- .> transport: sqs://**@localhost// - ** ---------- .> results: djcelery.backends.database:DatabaseBackend - *** --- * --- .> concurrency: 4 (prefork) -- ******* ---- --- ***** ----- [queues] -------------- .> celery exchange=celery(direct) key=celery [tasks] . job_processing.celery.debug_task . process_workflow [2016-09-15 18:30:14,864: INFO/MainProcess] Connected to sqs://**@localhost// [2016-09-15 18:30:17,524: WARNING/MainProcess] celery@ ready. -
Django field Error
I am a Django beginner working on Django==1.9 version and trying to learn and replicate DjangoGirl tutorial. I have stuck at "Dynamic data in templates " and "Django templates ". from django.shortcuts import render from .models import Post from django.utils import timezone # Create your views here. def post_list(request): posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date') return render(request, 'blog/post_list.html', {'posts':posts}) the given "view.py" showing error Exception Value: Cannot resolve keyword 'published_date' into field. Choices are: author, author_id, creat_date, id, publish_Data, text, title I have tried each and every thing possible but its not working..kindly help. -
duplicate key value violates unique constraint when saving object
using django with postgres, I was trying to save an object after modifying it like so: > em.orgemployee.org = org > em.orgemployee.save() then I got an error saying: *** IntegrityError: duplicate key value violates unique constraint "pkem_employee_og_org" DETAIL: Key (em_id_employee)=(fea5be1e-54d2-4d02-a436-8d504bb8a295) already exists. after looking the error on stackoverflow I ended up here IntegrityError duplicate key value violates unique constraint - django/postgres and I get that pkem_employee_og_org is an index and not a table, so I cant resync my db's primary ids (I'm not sure if am doing it right tho, I don't know postgresql) project=# select * from public.pkem_employee_og_org; ERROR: "pkem_employee_og_org" is an index LINE 1: select * from public.pkem_employee_og_org; project=# \d pkem_employee_og_org Index "public.pkem_employee_og_org" Column | Type | Definition ----------------+------+---------------- em_id_employee | uuid | em_id_employee primary key, btree, for table "public._em_employee_og_org", clustered I even tried force saving like so: > em.orgemployee.save(force_update=True) *** TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block. didn't work, so how can I do this? -
Django : Make an ordered list of objects each having reference to previous
I am making a portal who serves for interview procedures for job interviews. I want to make a model for each interview round. First round will be started for every job. Then the applicants who pass it, will be considered in the next round for that job. I want to know how to make models for that? Which way would be better ? Here are basic models definations and some of the ways which I have come up with. Any suggestion or new way is welcomed. models.py class Applicant(models.Model): #applicant details class Job(models.Model): #job details class Round(models.Model): #round detail Ways for linking job, rounds, applicants : Make a one to many relationship from round to job (each job has several rounds but each round is associated with only one job). Make many to many from round to applicants (each applicant may be included in several jobs' rounds and each round has several qualified applicants.) Here problem is that how to keep reference of previous round of any round ? (Though it is not strictly needed.) In job models, keep a dynamic(if possible) list of round objects. While creating new round, we can append to this list. Here reference to previous … -
Django combine different tables in separate django table's column
I have 2 tables and wanted to combine 1st and 2nd table and show it in 3rd table class Date(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return self.name class Month(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return self.name I have my 3rd table which is combination of 1st and 2nd table I tried to use models.ForeignKey(Date,Month) in my 3rd table but only Month table data was shown in admin panel Date table data was not populated My 3rd table looks like this class Group(models.Model): name = models.ForeignKey(Month,Date) def __unicode__(self): return self.name I there any alternate way of populating data from different tables? Any help is populating data of different tables in one table is very helpfull Thanks in advance -
Django project template loader setup
It is possible setup django project template loading priority so that first of all it loos to app "template" folder and after to project "tempalte". If template exist in app folder, then use it. If not exit in app folderm, then try load from project folder. Or it is not normal way to load templates? I ask because see in exception, where Django try load first of all global templates: Template-loader postmortem Django tried loading these templates, in this order: Using engine django: django.template.loaders.filesystem.Loader: D:\myprojects\my-website\src\templates\home.html (Source does not exist) django.template.loaders.app_directories.Loader: C:\User\Python27\lib\site-packages\django\contrib\admin\templates\home.html (Source does not exist) django.template.loaders.app_directories.Loader: C:\User\Python27\lib\site-packages\django\contrib\auth\templates\home.html (Source does not exist) django.template.loaders.app_directories.Loader: D:\myprojects\my-website\src\website\templates\home.html (Source does not exist) -
Django Auth user date_joined field datetime to string
When i am fetching the stored datetime value from auth user in django the value comes as below is there a way to convert this into normal date time format may be like "dd:mm:yyyy hh:mm:ss" date_joined = request.user.date_joined #date_joined value is #datetime.datetime(2016, 9, 11, 16, 6, 22, 314637, tzinfo=<UTC>) -
Python django internationalization
I am working on a python django web app in which I want to implement internationalization and auto translate the whole app into french or chinese. I took reference from this site https://www.metod.io/en/blog/2015/05/05/django-i18n-part-1/ But whenever I try to run the app it shows this error: 500: ValueError at /en/get_dashboard_data/ The view dashboard.views.getDashboardData didn't return an HttpResponse object. It returned None instead. And url get_dashboard_data is fetching data through ajax. js file for fetching data through ajax: function getSaleChart(){ $.ajax({ url : "/get_dashboard_data/", type : "POST", data : {action:'sale_chart_data'}, success : function(response) { channel_list = response.channel_list; data_list = response.data_list; c3.generate({ bindto: '#sale-chart-30-days', data:{ x: 'dates', xFormat: '%b %d', columns: data_list, colors:{ Flipkart: '#1AB394', Paytm: '#BABABA' }, type: 'bar', groups: [ channel_list ] }, axis: { x: { type: 'timeseries' } } }); }, error : function(xhr,errmsg,err) { toastr["error"]("Something Broke.", "Oops !!!."); console.log(xhr.status + ": " + xhr.responseText); } }); } ** settings.py** from django.utils.translation import ugettext_lazy as _ MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates') TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [TEMPLATE_PATH], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.core.context_processors.i18n', ], }, }, ] LANGUAGE_CODE = 'en-us' … -
Django not creating database table after deleting migrations files and migration table
I have created two tables profile and details through django model and mistakenly i have deleted both these tables. Further when i tried to create table using python2.7 manage.py makemigrations and python2.7 manage.py migrate then it was not creating the tables so i deleted migration files and truncated the django_migration table. Now when i am running command python2.7 manage.py runserver Its giving me error You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them. And if i run python manage.py migrate command error is Operations to perform: Apply all migrations: home, contenttypes, auth, sessions Running migrations: Rendering model states... DONE Applying contenttypes.0001_initial...Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 350, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 342, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 200, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 92, in migrate self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 198, in apply_migration state = migration.apply(state, schema_editor) File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", … -
Translating text with a variable in a Django template
I have the following code in a Python Django HTML template {% blocktrans %} You have {{ messages }} unread messages{% blocktrans %} And the following translation in the .po file: msgid "You have %d unread messages" But it doesn't work. How should be each be formatted? -
Cassandra get more than 10k rows
I am getting stuck with Cassandra all() query. I am using django platform.My query is to get all rows from Cassandra table. but,CQL has some limit to 10k rows at a time. before,I have less than 10k rows in Cassandra table.But,now the count get increase up-to 12k. How I get all() query to get all 12k rows! Thanks! -
Managing Django handler's thread
Is it a webserver spawning/controlling a thread(process) which calls request handler? Or is there any asynchronous/multithreaded architecture in Django itself? The problem is that when an (ajax) request is being processed for a long time, and during this client re-sends it again, the previous handler gets terminated. I would like to have some control over this: e.g. perform some cleanup actions. Or terminate the handler manually in some cases. -
django uploading blob to server
I am recording voice using Recorder.js, it returns a blob object. I want this blob to be sent to the back-end and stored on file-system (localhost) with its URL saved in Database (or any other way you find feasible). How is this done in Django? This is a similar question but isn't answered. thanks for help..I am stuck on this from long. -
Angular posts whole data to Django view as key in QueryDict
I am using Angular 1.4.4 and Django 1.8. When i post data from Angular to Django view it comes in the form of whole data as key in the QueryDict. So in view in debug mode when i evaluate request.POST it returns this <QueryDict: {u'{"messagetitle":"","value":"","valueam":"","wrong_response":"","stop":"","messagekind":"1","undefined":"","messagetype":"3","state":"","language_id":1}': [u'']}> Notice posted data is inside u'' as key and its value is [u''] Angular code is this function createDraft(data) { return $http({ url: view_url + 'create_draft/', method: 'POST', data: data, headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' } }) } Here data is javascript dictionary object Let me know what i am doing wrong here. I have tried some answers on stackoverflow but could not find any question/answer which addresses my specific problem. PS: I know i can do json.loads(request.body) but i need to post data in django's request.POST -
GenericForeignKey and on_delete=models.PROTECT
Django 1.10 Say, I have an instance of Frame and two comments for it. Key moment: on_delete=models.PROTECT in the Comment model. In the shell: Comment.objects.all() <QuerySet [<Comment: Some comment.>, <Comment: Second comment.>] Then I delete frame instance (call FrameDelete). And: Comment.objects.all() <QuerySet []> Empty. Deleted all comments. And models.PROTECT didn't help. Well, I can't make it catch IntegrityError. Could you tell me if it is possible and how to do? class FrameDelete(IntegrityErrorMixin, DeleteView): model = Frame class IntegrityErrorMixin(): def delete(self, request, *args, **kwargs): self.object = self.get_object() success_url = self.get_success_url() try: self.object.delete() except IntegrityError as err: raise PermissionDenied return HttpResponseRedirect(success_url) class Frame(models.Model): ..... comments = GenericRelation(Comment) class Comment(models.Model): date = models.DateTimeField(null=False, blank=False, auto_now_add=True) author = models.ForeignKey(User, on_delete=models.PROTECT) body = models.TextField(blank=False, null=False, default="", verbose_name = "",) # Empty. No need to show the verbose_name on the form. content_type = models.ForeignKey(ContentType, on_delete=models.PROTECT) object_id = models.PositiveIntegerField() content_object = GenericForeignKey('content_type', 'object_id') -
Django 1.10 full text search by UUIDField returns DataError
I have the following model: class Show(models.Model): cid = models.UUIDField( default=uuid.uuid4, editable=False, verbose_name="Content ID", help_text="Unique Identifier" ) title_short = models.CharField( max_length=60, blank=True, verbose_name="Short Title", help_text="Short title (60 chars)" ) I'm using the below snippet from django.contrib.postgres.search import SearchVector Entry.objects.annotate( search=SearchVector('cid'), ).filter(search='wateva') Returns: DataError at /meta/shows/ invalid input syntax for uuid: "" LINE 1: ...unt", to_tsvector(COALESCE("entities_show"."cid", '')) AS "s... I tried with PostgreSQL 9.3.14 and PostgreSQL 9.5.3, Python 3.4.3 Has anyone encountered this issue ? -
django.db.utils.InternalError always shown when connect mysql with "migrate"
one of the errors: pymysql.err.InternalError: (1364, "Field 'name' doesn't have a default value") django.db.utils.InternalError: (1364, "Field 'name' doesn't have a default value") The environment: django 1.10.1 mysql 5.7.15 python 3.5.2 Because MySQLdb don`t suport python3.5, I replaced MySQLdb with PyMySQL, and edit introspection.py&base.py in django.db.backends.mysql. -
Django and Mailgun : 552 sorry, your envelope sender domain must exist (#5.7.1)
I'm trying to send mail using Django and Mailgun through the Anymail package and with an OVH server. I'm currently receiving the 552 sorry, your envelope sender domain must exist (#5.7.1) error. In this question/answer, it is suggested that I would need a "from" header, but the response I'm getting seems to show that the header is already included : "headers": { "to": "evenements@mydomain-longversion.org", "message-id": "20160915065953.15168.46300.4ABD80EB@mailgun.mydomain.fr", "from": "covoiturage@mydomain.fr", "subject": "Mail test !" }, Here is the full response, for reference : { "severity": "permanent", "tags": [], "storage": { "url": "https://si.api.mailgun.net/v3/domains/mailgun.mydomain.fr/messages/eyJwIjpmYWxzZSwiayI6ImI5OGIyN2QzLTM2MmEtNGJjNi05ZWViLTRlMTA0NTVmYTIxMiIsInMiOiJlNmY5NzZhZTYwIiwiYyI6InNiaWFkIn0=", "key": "eyJwIjpmYWxzZSwiayI6ImI5OGIyN2QzLTM2MmEtNGJjNi05ZWViLTRlMTA0NTVmYTIxMiIsInMiOiJlNmY5NzZhZTYwIiwiYyI6InNiaWFkIn0=" }, "delivery-status": { "tls": false, "mx-host": "redirect.ovh.net", "attempt-no": 1, "description": null, "session-seconds": 0.9216420650482178, "code": 552, "message": "552 sorry, your envelope sender domain must exist (#5.7.1)", "certificate-verified": false }, "recipient-domain": "mydomain-longversion.org", "event": "failed", "campaigns": [], "reason": "generic", "user-variables": {}, "flags": { "is-routed": null, "is-authenticated": true, "is-system-test": false, "is-test-mode": false }, "log-level": "error", "timestamp": 1473922798.282194, "envelope": { "transport": "smtp", "sender": "postmaster@mailgun.mydomain.fr", "sending-ip": "209.61.151.224", "targets": "evenements@mydomain-longversion.org" }, "message": { "headers": { "to": "evenements@mydomain-longversion.org", "message-id": "20160915065953.15168.46300.4ABD80EB@mailgun.mydomain.fr", "from": "covoiturage@mydomain.fr", "subject": "Mail test !" }, "attachments": [], "recipients": [ "evenements@mydomain-longversion.org" ], "size": 643 }, "recipient": "evenements@mydomain-longversion.org", "id": "TfJKwpoZQq6bM-MW5sm6nA" } And here is my Django code : def SendTestEmail(request): if request.user.is_staff and settings.DEBUG == True … -
ImproperlyConfigured Error
I am trying to upload multiple files in django. I am getting ImproperlyConfigured Error . Please help me find out, what I am doing wrong here. Thanks in advance for your help.I am following this [Link] (https://www.youtube.com/watch?v=C9MDtQHwGYM) views.py from django.shortcuts import render from django.http import HttpResponse # Create your views here. def Form(request): return render(request, "index/form.html", {}) def Upload(request): for count, x in enumerate(request.FILES.getlist("files")): def process(f): with open('/Users/benq/djangogirls/upload/media/file_' + str(count), 'wb+') as destination: for chunk in f.chunks(): destination.write(chunk) process(x) return HttpResponse("File(s) uploaded!") form.html <form method="post" action="../upload/" entype="multipart/form-data"> {% csrf_token %} <input type="file" name="files" multiple /> <input type="submit" value="Upload" /> app/urls.py from django.conf.urls import url from index import views urlpatters = [ url(r'^form/$', views.Form), url(r'^upload/$', views.Upload) ] project/urls.py from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^index/', include('index.urls')) ] StackTrace Error: Traceback (most recent call last): File "C:\Python34\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "C:\Python34\lib\site-packages\django\core\management\commands\runserver. py", line 121, in inner_run self.check(display_num_errors=True) File "C:\Python34\lib\site-packages\django\core\management\base.py", line 385, in check include_deployment_checks=include_deployment_checks, File "C:\Python34\lib\site-packages\django\core\management\base.py", line 372, in _run_checks return checks.run_checks(**kwargs) File "C:\Python34\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "C:\Python34\lib\site-packages\django\core\checks\urls.py", line 14, in c heck_url_config return check_resolver(resolver) File "C:\Python34\lib\site-packages\django\core\checks\urls.py", line 28, in c heck_resolver warnings.extend(check_resolver(pattern)) File "C:\Python34\lib\site-packages\django\core\checks\urls.py", … -
Django - how to break down monolitic project into apps?
I'm new to Django and I have been working on a Django project for some time now, It's an event registration and management tool for conferences, Event organisers can create an Event, and an event registration page for attendees to RSVP. Currently all the functionality of the project is stored in one monolithic Django app, I want to separate this app into smaller apps. I'm having a difficult time understanding when to separate a Django project into apps, are there any hard and fast rules for this. This is how I am considering breaking down the monolithic app. Account app - for event organisers to create an account and manage their profile. Event app - which consists of the event details, agenda, photos, sponsors and speakers of the event) Attendee app - which is an app that manages attendees, whether they have registered etc. Communication app - creating custom emails and email templates to send to attendees. RSVP page app - this is an editable registration page that contains basic information about the event, attendees will rsvp on this page by entering their data in a form. Is this a logical way of breaking down my project into apps. Should … -
How do I use Docker on BitBucket pipelines to test a Django app that needs PostGIS?
I'm trying to build automated testing on Django app on a private BitBucket repo, using BitBucket pipelines. I have all the tests in place, and they can be run using ./manage.py test or using tox. This works fine locally, where the tests build a (temporary) PostGIS test database. PostGIS and stuff like gdal is necessary for all the requirementst.txt to properly install. I'm having problems finding a Docker image that gives me a full Python + PostGIS/gdal etc stack on Docker, and I lack the skills to build it myself. My failed attemps are documented on GitHub: https://github.com/zostera/docker-django-ci Can someone point me in the right direction (tutorial) or perhaps help me out with a working example? -
Django Rest Framework Ordering Filter, order by nested list length
I'm using OrderingFilter globally through settings.py and it works great. Now I would like to order on the size of a nested list from a ManyToManyField. Is that possible with the default OrderingFilter? If not, is there a way I can do it with a custom filter, while keeping the query param ordering in the url (http://example.com/recipes/?ordering=). For the sake of consistency. Oh and the ManyToManyField is a through table one. These are my models.py: class Recipe(models.Model): name = models.CharField(max_length=255) cook_time = models.FloatField() ingredients = models.ManyToManyField(IngredientTag, through=Ingredient) My serializers.py: class IngredientTagSerializer(serializers.ModelSerializer): class Meta: model = IngredientTag fields = ('id', 'label') class IngredientSerializer(serializers.ModelSerializer): class Meta: model = Ingredient fields = ('amount', 'unit', 'ingredient_tag') depth = 1 class RecipeSerializer(serializers.ModelSerializer): ingredients = IngredientSerializer(source='ingredient_set', many=True) class Meta: model = Recipe fields = ('id', 'url', 'name', 'ingredients', 'cook_time') read_only_fields = ('owner',) depth = 2 And my views.py: class RecipeViewSet(viewsets.ModelViewSet): """ API endpoint that allows recipes to be viewed or edited. """ queryset = Recipe.objects.all().order_by() serializer_class = RecipeSerializer permission_classes = (DRYPermissions,) ordering_fields = ('cook_time',) #Need ingredient count somewhere? Thanks!