Exemple #1
0
                        class Grades(models.Model):

                           gname    =    models.CharField(max_length=20)   # 最长20个字节

                           gdate    =    models.DateTimeaField()    # 时间类型

                           ggirlnum =    models.IntegerField()   

                           gboynum  =    models.IntegerField()

                           isDelete =    models.BooleanField(default=False)      
Exemple #2
0
class Classroom(models.Model):
	name = models.CharField(max_length=120)
	subject = models.CharField(max_length=120)
	year = models.IntegerField()

	def get_absolute_url(self):
		return reverse('classroom-detail', kwargs={'classroom_id':self.id})
class Work(models.Model):
    title = models.CharField(max_length=100)
    year = models.IntegerField()
    desc = models.CharField(max_length=255)
    author = models.ForeignKey(User, related_name="works")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = WorkManager()
Exemple #4
0
class District(Place):
    name_std = models.CharField(max_length=200,
                                db_index=True,
                                verbose_name="standard name")
    location = models.PointField()
    population = models.IntegerField()
    city = models.ForeignKey(City)

    @property
    def parent(self):
        return self.city
Exemple #5
0
class City(Place):
    name_std = models.CharField(max_length=200,
                                db_index=True,
                                verbose_name="standard name")
    location = models.PointField()
    population = models.IntegerField()
    region = models.ForeignKey(Region, null=True, blank=True)
    subregion = models.ForeignKey(Subregion, null=True, blank=True)
    country = models.ForeignKey(Country)
    elevation = models.IntegerField(null=True)
    kind = models.CharField(
        max_length=10)  # http://www.geonames.org/export/codes.html
    timezone = models.CharField(max_length=40)

    class Meta:
        verbose_name_plural = "cities"

    @property
    def parent(self):
        return self.region
Exemple #6
0
class Work(models.Model):
    title = models.CharField(max_length=100)
    year = models.IntegerField()
    desc = models.CharField(max_length=255)
    worktype = models.CharField(max_length=100, default="")
    author = models.ForeignKey(Author, related_name="works")
    excerpt = models.CharField(max_length=1500, default="")
    link = models.CharField(max_length=200, default="")
    liked_by = models.ManyToManyField(Member, related_name="liked_work")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    objects = WorkManager()
Exemple #7
0
                        class Student(models.Model):

                           sname   = models.CharField(max_length=20)

                           sgender = models.BooleanField(default=True)

                           sage    = models.IntegerField()

                           scontend= models.CharField(max_length=20)

                           isDelete= models.BooleanField(default=False)
                            # 关联外键
                           sgrade  =  models.ForeignKey("Grades")
Exemple #8
0
class Country(Place):
    code = models.CharField(max_length=2, db_index=True)
    code3 = models.CharField(max_length=3, db_index=True)
    population = models.IntegerField()
    area = models.IntegerField(null=True)
    currency = models.CharField(max_length=3, null=True)
    currency_name = models.CharField(max_length=50, null=True)
    languages = models.CharField(max_length=250, null=True)
    phone = models.CharField(max_length=20)
    continent = models.CharField(max_length=2)
    tld = models.CharField(max_length=5)
    capital = models.CharField(max_length=100)
    neighbours = models.ManyToManyField("self")

    class Meta:
        ordering = ['name']
        verbose_name_plural = "countries"

    @property
    def parent(self):
        return None

    def __unicode__(self):
        return force_unicode(self.name)
Exemple #9
0
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 User(models.Model):
    """

    This class use a template as a user in this App
    we got a basic information about user.

    fisrt_name -- name user
    last_name -- last name user
    email_user -- email user
    phone_user -- phone user

    """
    fisrt_name = models.CharField(blank=True, max_length=50)
    last_name = models.CharField(blank=True, max_length=50)
    email_user = models.EmailField(blank=True, max_length=50)
    phone_user = models.IntegerField(blank=True,max_length=10)


    def __str__(self):
        return '%s, #%s' % (self.fisrt_name,self.phone_user)

    def __repr__(self):
        return '{} #{}'.format(self.fisrt_name,self.phone_user)
Exemple #11
0
class Person(object):
    first_name = models.CharField(size=30, primary_key=True)
    last_name = models.CharField(size=30)
    age = models.IntegerField()
    dob = models.DatetimeField()
    isMale = models.BooleanField()
Exemple #12
0
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'
Exemple #13
0
    def home(request):
        List = map(str, range(100))  # 一个长度为100的 List
        return render(request, 'home.html', {'List': List})
{% for item in List %}
    {{ item }}{% if not forloop.last%},{% endif %}
{% endfor %}

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.core.context_processors.tz",
    "django.contrib.messages.context_processors.messages",
)


<a href="{{ request.path }}?{{ request.GET.urlencode }}&delete=1">当前网址加参数 delete</

from django.db import models


class Person(models.Model):
    name = models.CharField(max_length=30)
    age = models.IntegerField()

    def __unicode__(self):
        # 在Python3中使用 def __str__(self)
        return self.name
Exemple #14
0
class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)
Exemple #15
0
 def fields(self, **kwargs):
     self.normal_string = models.CharField(**kwargs)
     self.string_with_default = models.CharField(
         default="this is a default", **kwargs)
     self.normal_int = models.IntegerField(**kwargs)
Exemple #16
0
class Animal(object):
    species = models.CharField(size=30, primary_key=True)
    life_expectancy = models.IntegerField()