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

how i can do this #41

Closed
Sarthak77tiwari opened this issue Jun 18, 2020 · 2 comments
Closed

how i can do this #41

Sarthak77tiwari opened this issue Jun 18, 2020 · 2 comments

Comments

@Sarthak77tiwari
Copy link

No description provided.

@Sarthak77tiwari
Copy link
Author

Sarthak77tiwari commented Jun 18, 2020

I have model Shop, Product, Customer, Order. the relation of model
shop

         user = models.OneToOneField(User, null=True, related_name='shop', blank=True, 
          on_delete=models.CASCADE)

  name = models.CharField(max_length=70, null=True, default='shop', )

  address = models.CharField(max_length=70, null=True)`

customer
`
class Customer(models.Model):

          user = models.OneToOneField(User, null=True, on_delete=models.CASCADE)

         name = models.CharField(max_length=100, null=True, default='customer')

          Phone = models.PositiveIntegerField(blank=True, null=True)`

product
`
class Product(models.Model):

           shop = models.ForeignKey(Shop, models.CASCADE, null=True, blank=True)
                    
            name = models.CharField(max_length=100, blank=True)
                
            Brand = models.CharField(max_length=200, blank=True)
                   
          description = models.TextField(null=True, blank=True)`

order
`
class Order(models.Model):
STATUS = (
('Pending', 'Pending'),
('Out for delivery', 'Out for delivery'),
('Delivered', 'Delivered'),
)
shop = models.ForeignKey(Shop, models.CASCADE, null=True)

  customer = models.ForeignKey(Customer, models.CASCADE, null=True)
         
  product = models.ForeignKey(Product, models.CASCADE, null=True)
          
  quantity = models.CharField(max_length=30)
        
    date_created = models.DateTimeField(auto_now_add=True)

status = models.CharField(max_length=200, choices=STATUS, default='Pending')`
when customers login then the list of shops will print on the screen and a button on shop to show the products by the shop in the form card. On the product card, there is an order button that adds the product in order after submitting the selected product will print with the remaining filled of order
how I can create an order so that the customer in order is the instance and the shop in order is that shop which is selected to show the products, and products which are selected for the order, please explain me

@mattfreire
Copy link
Collaborator

Please consider posting questions like this on StackOverflow. Issues are to keep track of issues

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

No branches or pull requests

2 participants