Advertisement
Guest User

Untitled

a guest
May 26th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. from django.db import models
  2. from django.contrib import admin
  3. from django.forms import ModelForm
  4.  
  5. class Image(models.Model):
  6.     url = models.CharField(max_length=500)
  7.     description = models.CharField(max_length=200)
  8.    
  9.     def __unicode__(self):
  10.         return self.url.url
  11.        
  12. class ImageAdminForm(ModelForm):
  13.     url = models.ImageField(upload_to='img_post')
  14.     description = models.CharField(max_length=200)
  15.    
  16.     class Meta:
  17.         model = Image
  18.    
  19.  
  20. class ImageAdmin(admin.ModelAdmin):
  21.     form = ImageAdminForm
  22.  
  23. admin.site.register(Image, ImageAdmin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement