View difference between Paste ID: xQiipBh5 and UxBY4kts
SHOW: | | - or go back to the newest paste.
1
from django.db import models
2
 
3-
# Create your models here.
3+
...
4
5
class Picture(models.Model):
6-
#dimensions & shapes
6+
	
7-
#
7+
	...
8-
#shape - simple draw of an object
8+
9-
#dim - dimensions for specific shape
9+
10
		
11-
class Shape(models.Model):
11+
	...
12-
	pic = models.CharField(max_length=200)
12+
13-
#	dims = models.CharField()
13+
14-
#	coordinates = models.CharField()
14+
		#saving the picture first, because it must be uploaded and stored first
15
		super(Picture, self).save(*args, **kwargs)
16
		#moving picture if needed
17-
#types
17+
		if blablabla:
18-
class T(models.Model):
18+
19-
	name = models.CharField(max_length=100)
19+
20-
	shape = models.ForeignKey(Shape)
20+
			path = settings.MEDIA_ROOT + somedirname + '/'
21
			if not os.path.exists(path):
22-
#
22+
23-
class Item(models.Model):
23+
24-
	name = models.CharField(max_length=100)
24+
			#self.pic is ImageFieldFile object
25-
	t = models.ForeignKey(T)
25+
			self.pic = somedir + '/' + self.pic.name.split('/')[-1]
26-
	date = models.DateField('data published')
26+
			#self.pic is string object
27-
	dims = models.CharField(max_length=50)
27+
			super(Picture, self).save(*args, **kwargs)
28-
	about = models.CharField(max_length=1000)
28+
			#now it's again an ImageFieldFile object with new path