Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added manager classes and serialize functions #37

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

piyushsprasad
Copy link
Collaborator

Added manager classes with serialize functions to the models that did not have them

@@ -2,6 +2,15 @@
from django.db import models

# Create your models here.
class ArticleManager(models.Manager):
def serialize(self, account, filter=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol don't copy paste code my man! This isn't an account object we are receiving, so why call it account? We also don't use the filter object so why pass it in? Half of the reason you write code is so someone can read it and understand what is going on.!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at my code in account.py carefully, you will notice that the data is being retrieved from the variable being passed into the function. Not the model objects.
image

if i were to do:
data = { "email": Account.email }
the code would break because the Account object has no attribute called email, only the account variable that we pass into the function which is an instance of an Account object and not the class itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants