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

Solution #529

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

Solution #529

wants to merge 3 commits into from

Conversation

katyakoziar
Copy link

No description provided.

db/models.py Outdated
Comment on lines 67 to 82
class Order(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(User, on_delete=models.CASCADE)

class Meta:
ordering = ["-created_at"]

def __str__(self) -> str:
return f"{self.created_at}"


class Ticket(models.Model):
movie_session = models.ForeignKey(MovieSession, on_delete=models.CASCADE)
order = models.ForeignKey(Order, on_delete=models.CASCADE)
row = models.IntegerField()
seat = models.IntegerField()

Choose a reason for hiding this comment

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

add related names for this models too


def create_order(tickets: list, username: str, date: datetime = None) -> None:
with transaction.atomic():
user, _ = User.objects.get_or_create(username=username)

Choose a reason for hiding this comment

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

use get_user_model() aslo here

Copy link

@fsocie7y fsocie7y left a comment

Choose a reason for hiding this comment

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

GJ 👍

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