What do you want to save?
Add Code snippet
New code examples
-
Python 2021-09-29 23:23:04
django migrate add new field to existing table
Initialize migrations for your existing models: ./manage.py makemigrations myapp Fake migrations for existing models: ./manage.py migrate --fake myapp Add the new field to myapp.models: from django.db import models class MyModel(models.Model): ...... Add solution -
Javascript 2021-09-07 01:45:02
django send and receive image data to react
class Product(models.Model): item_title= models.CharField(max_length=50) item_desc=models.TextField() item_price=models.IntegerField() item_image=models.ImageField(upload_to='post_images',default='default.png') item_image_url = models.TextField() Add solution -
Python 2021-09-05 17:46:02
Como definir modelos con django
from django.db import models from django.utils import timezone class Post(models.Model): author = models.ForeignKey('auth.User', on_delete=models.CASCADE) title = models.CharField(max_length=200) text = models.TextField() created_date = ... Add solution -
Python 2021-09-04 22:49:02
add year to id django
import datetime from uuid import uuid4 def create_id(): now = datetime.datetime.now() return str(now.year)+str(now.month)+str(now.day)+str(uuid4())[:7] # in your model: id = models.CharField(primary_key=True, default=create_id, editable=False) Add solution -
Python 2021-08-30 16:05:01
autoslugfield django 3
# models.py from django.db import models from django_extensions.db.fields import AutoSlugField class MyModel(models.Model): title = models.CharField(max_length=42) slug = AutoSlugField(populate_from=['title', 'description', 'get_author_name']) Add solution
Best helpers
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5
+5