class Article(models.Model): title = models.CharField(max_length=100) body = models.TextField() status = models.CharField(max_length=1, choices=STATUS_CHOICES) def __str__(self): # __unicode__ on Python 2 return self.title
class Product(models.Model): name = models.CharField(max_length=300) price = models.FloatField() description = models.TextField() count = models.IntegerField() category = models.ForeignKey(Category, on_delete=models.CASCADE, default=1) def to_json(self): return { 'id': self.id, 'name': self.name, 'price': self.price, 'description': self.description, 'count': self.count, 'category_id': self.category.id, }
class Character(models.Model): created_by = models.ForeignKey(User,related_name='player', on_delete=models.CASCADE) created_date = models.DateTimeField(blank=True, default=datetime.datetime.now) first_name = models.CharField(max_length=32) surname = models.CharField(max_length=32) age = models.PositiveSmallIntegerField(default=18) race = models.CharField(max_length=12) aura = models.CharField(max_length=64) sembelence = models.CharField(max_length=64) gender = models.CharField(max_length=10) fanuas_type = models.CharField(max_length=32, blank=True, null=True) citizenship = models.CharField(max_length=32) occupation = models.CharField(max_length=32) background = models.TextField(max_length=512, blank=True, null=True) def __str__(self): return self.surname + ", " + self.first_name
class Image(Orderable): def get_media_path(self, filename): pages = self.gallery.placeholder.page_set.all() return pages[0].get_media_path(filename) gallery = models.ForeignKey(GalleryPlugin, verbose_name=_("Gallery")) src = models.ImageField(_("Image file"), upload_to=get_media_path, height_field='src_height', width_field='src_width') src_height = models.PositiveSmallIntegerField(_("Image height"), editable=False, null=True) src_width = models.PositiveSmallIntegerField(_("Image height"), editable=False, null=True) title = models.CharField(_("Title"), max_length=255, blank=True) alt = models.TextField(_("Alt text"), blank=True) def __unicode__(self): return self.title or self.alt or str(self.pk)
class Book(models.Model): title = models.CharField(max_length=255) description = models.TextField() # whatever other fields/relationships created_at = models.DateTimeField(auto_now=True) updated_at = models.DateTimeField(auto_now_add=True)
class Event(models.Model): class Meta: verbose_name = _('event') verbose_name_plural = _('events') ordering = ['-event_date', '-start_time', '-title'] get_latest_by = 'event_date' permissions = (("change_author", ugettext("Change author")), ) unique_together = ("event_date", "slug") def __unicode__(self): return _("%(title)s on %(event_date)s") % { 'title': self.title, 'event_date': self.event_date } @models.permalink def get_absolute_url(self): return ('agenda-detail', (), { 'year': self.event_date.year, 'month': self.event_date.month, 'day': self.event_date.day, 'slug': self.slug }) objects = models.Manager() on_site = CurrentSiteManager() published = PublicationManager() # Core fields title = models.CharField(_('title'), max_length=255) slug = models.SlugField(_('slug'), db_index=True) event_date = models.DateField(_('date')) start_time = models.TimeField(_('start time'), blank=True, null=True) end_time = models.TimeField(_('end time'), blank=True, null=True) location = models.ForeignKey(Location, blank=True, null=True) description = models.TextField(_('description')) calendar = models.ForeignKey("Calendar", blank=True, null=True, related_name='events') # Extra fields add_date = models.DateTimeField(_('add date'), auto_now_add=True) mod_date = models.DateTimeField(_('modification date'), auto_now=True) author = models.ForeignKey(User, verbose_name=_('author'), db_index=True, blank=True, null=True) publish_date = models.DateTimeField(_('publication date'), default=datetime.now()) publish = models.BooleanField(_('publish'), default=True) allow_comments = models.BooleanField(_('Allow comments'), default=True) sites = models.ManyToManyField(Site) def save(self): super(Event, self).save() if not settings.DEBUG: try: ping_google() except Exception: import logging logging.warn('Google ping on save did not work.')
class allEHFPI(models.Model): ehfpiAcc = models.CharField(max_length=255, primary_key=True) #gene geneSymbol = models.CharField(max_length=255) geneDescription = models.CharField(max_length=255) #!!added previousName = models.CharField(max_length=255) synonyms = models.CharField(max_length=255) entrezId = models.CharField(max_length=255) uniprotId = models.CharField(max_length=255) proteinName = models.CharField(max_length=255) ensemblGeneId = models.CharField(max_length=255) targetOrganism = models.CharField(max_length=255) drosophilaGene = models.CharField(max_length=255) humanHomolog = models.CharField(max_length=255) go = models.TextField() pathway = models.CharField(max_length=255) # chromosomeName = models.CharField(max_length=255) # geneStart = models.IntegerField() # geneEnd = models.IntegerField() isVTP = models.IntegerField() resources = models.CharField(max_length=255) geneNote = models.CharField(max_length=255) #pathogen fullName = models.CharField(max_length=255) abbreviation = models.CharField(max_length=255) aliases = models.CharField(max_length=255) strain = models.CharField(max_length=255) species = models.CharField(max_length=255) speciesTaxonomy = models.CharField(max_length=255) genus = models.CharField(max_length=255) genusTaxonomy = models.CharField(max_length=255) family = models.CharField(max_length=255) familyTaxonomy = models.CharField(max_length=255) group = models.CharField(max_length=255) kingdom = models.CharField(max_length=255) kingdomTaxonomy = models.IntegerField() #publication title = models.CharField(max_length=255) author = models.CharField(max_length=255) pubmedId = models.CharField(max_length=255) firstAuthor = models.CharField(max_length=255) year = models.IntegerField() journal = models.CharField(max_length=255) abstract = models.TextField() articleFile = models.FileField(upload_to='files/') doi = models.CharField(max_length=255) #screen scope = models.CharField(max_length=255) assayType = models.CharField(max_length=255) #change from type reagent = models.CharField(max_length=255) targetOrganism = models.CharField(max_length=255) phenotype = models.CharField(max_length=255) #level = models.CharField(max_length=255) #remove to gene note bioModelDescription = models.CharField(max_length=255) #change from confirmatoryScreenDescription = models.CharField(max_length=255) primaryScreenDescription = models.CharField(max_length=255) hitsNumber = models.CharField(max_length=255) confirmedHitsNumber = models.CharField(max_length=255) primaryHitsNumber = models.CharField(max_length=255) screenNote = models.CharField(max_length=255) # display the class def __unicode__(self): # Python 3: def __str__(self): return str( self.ehfpiAcc ) + " " + self.geneSymbol + " " + self.strain + " " + self.title #this is the view in the mysql database class Meta: db_table = 'mainView'
class Movie(models.Model): Name = models.TextField(default='3Idiots') Hero = models.RelationField(relation='MEMBER', cls=Hero)
class Hero(models.Model): Name = models.TextField(default='kailash') Type = models.TextField(default='Hero')
class Message(models.Model): room = models.ForeignKey(Room, related_name="messages") handle = models.TextField() message = models.TextField()
class Room(models.Model): name = models.TextField() label = models.SlugField(unique=True)