mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 09:57:53 +03:00 
			
		
		
		
	Docs: Update Cookbook tutorial
This commit is contained in:
		
							parent
							
								
									24706f50d4
								
							
						
					
					
						commit
						443b5eaafc
					
				| 
						 | 
				
			
			@ -68,7 +68,8 @@ Let's get started with these models:
 | 
			
		|||
    class Ingredient(models.Model):
 | 
			
		||||
        name = models.CharField(max_length=100)
 | 
			
		||||
        notes = models.TextField()
 | 
			
		||||
        category = models.ForeignKey(Category, related_name='ingredients')
 | 
			
		||||
        category = models.ForeignKey(
 | 
			
		||||
            Category, related_name='ingredients', on_delete=models.CASCADE)
 | 
			
		||||
 | 
			
		||||
        def __str__(self):
 | 
			
		||||
            return self.name
 | 
			
		||||
| 
						 | 
				
			
			@ -80,9 +81,21 @@ Add ingredients as INSTALLED_APPS:
 | 
			
		|||
    INSTALLED_APPS = [
 | 
			
		||||
        ...
 | 
			
		||||
        # Install the ingredients app
 | 
			
		||||
        'ingredients',
 | 
			
		||||
        'cookbook.ingredients',
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
Register models with admin panel:
 | 
			
		||||
 | 
			
		||||
.. code:: python
 | 
			
		||||
 | 
			
		||||
    # cookbook/ingredients/admin.py
 | 
			
		||||
    from django.contrib import admin
 | 
			
		||||
    from cookbook.ingredients.models import Category, Ingredient
 | 
			
		||||
 | 
			
		||||
    admin.site.register(Category)
 | 
			
		||||
    admin.site.register(Ingredient)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Don't forget to create & run migrations:
 | 
			
		||||
 | 
			
		||||
.. code:: bash
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user