Photologist Integration

I want to integrate a photologist with my Django app and use it to display photos in my vehicle inventory ... like what Boost Motor Group Inc. offers. I already integrated the application, so the next step, m is trying to figure out how to connect it to my car model, as well as how to display photos. My car model looks like this BTW

class Vehicle(models.Model): stock_number = models.CharField(max_length=6, blank=False) vin = models.CharField(max_length=17, blank=False) common_vehicle = models.ForeignKey(CommonVehicle) exterior_colour = models.ForeignKey(ExteriorColour) interior_colour = models.ForeignKey(InteriorColour) interior_type = models.ForeignKey(InteriorType) odometer_unit = models.ForeignKey(OdometerUnit) status = models.ForeignKey(Status) odometer_reading = models.PositiveIntegerField() selling_price = models.PositiveIntegerField() purchase_date = models.DateField() sales_description = models.CharField(max_length=60, blank=False) feature_sets = models.ManyToManyField(FeatureSet, blank=True) features = models.ManyToManyField(Feature, blank=True) def __unicode__(self): return self.stock_number 
+4
source share
2 answers

I am using ImageKit (great!)

model.py

 from imagekit.models import ImageModel class Photo(ImageModel): name = models.CharField(max_length=100) original_image = models.ImageField(upload_to='photos') num_views = models.PositiveIntegerField(editable=False, default=0) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey('content_type', 'object_id') class IKOptions: # This inner class is where we define the ImageKit options for the model spec_module = 'cms.specs' cache_dir = 'photos' image_field = 'original_image' save_count_as = 'num_views' class Vehicle(models.Model): images = generic.GenericRelation('Photo', blank = True, null = True) 

specs.py

 from imagekit.specs import ImageSpec from imagekit import processors from imagekit.lib import * # first we define our thumbnail resize processor class ResizeThumb(processors.Resize): width = 100 height = 75 crop = True # now lets create an adjustment processor to enhance the image at small sizes class EnchanceThumb(processors.Adjustment): contrast = 1.2 sharpness = 1.1 # now we can define our thumbnail spec class Thumbnail(ImageSpec): processors = [ResizeThumb, EnchanceThumb] 

in your template you will get access to the following thumbnails:

 {% for p in vehicle.images.all %} {{ p.get_thumbnail.url }} {% endfor %} 

admin.py might look like this:

 class ImagesInline(generic.GenericTabularInline): model = Photo max_num =4 class VehicleAdmin(admin.ModelAdmin): inlines = [ImagesInline] 

About user ImageKit

add the specs.py file to your application and tell ImageKit about it like this

  class IKOptions: # This inner class is where we define the ImageKit options for the model spec_module = 'cms.specs # ur_app.specs 

add a field to your photo model to save what kind / content it displays. i.e. ChoiceField

In the view / template you can filter it

+5
source

For your purposes, I would recommend you check out django-imagekit (I wrote both imagekit and photologist). It was designed to be integrated into other applications, and not as a standalone application. After that, as Dominic said, we will need to learn more about your requirements.

+8
source

All Articles