예제 #1
0
class About(models.Model):
    short_description = models.Textfield()
    description = models.Textfield()
    image = models.ImageField(upload_to='about')

    class Meta:
        verbose_name = 'About me'
        verbose_name_plural = 'About me'

    def __str__(self):
        return 'About me'
예제 #2
0
class Podcast(models.Model):
    Id = models.Integerfield(blank=False, null=False)
    Name = models.Charfield(max_length=100, null=False, blank=False)
    Duration = models.Decimalfield(max_digits=4, decimal_places=2, blank=False)
    Uploaded time = models.Integerfield(datetime.Datetime, blank=False)
    Host = models.Charfield(max_length=100, blank=False)
    Participants = models.Textfield(max_length=100, blank=True, end={''})
예제 #3
0
class Meals(models.Model):
    name = models.CharField(max_length=50)
    description = models.Textfield(max_length=500)
    people = models.IntegerField()
    price = models.DecimalField(max_digits=5, decimal_places=2)
    preparation_time = models.IntegerField()
    image = models.ImageField(upload_to='meals/')
예제 #4
0
class Package(models.Model):
    name = models.CharField(maxlength=300)
    version = models.CharField(maxlength=300, blank=True)
    home_page = models.URLField(blank=True)
    summary = models.TextField()
    description = models.TextField(blank=True)
    keywords = models.Textfield(blank=True)
    categories = models.ManyToManyField(Category, related_name="packages")
예제 #5
0
class Comment(models.Model):
    comment = models.Textfield()
    post = models.ForeignKey(Post, related_name="comments")
    user = models.ForeignKey(User, related_name="users")
    likes = models.ManyToManyField(User, related_name="comments_liked")
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    objects = CommentManager()
예제 #6
0
class Company(models.Model):
    name = models.Charfield(max_length=250)
    estd = models.DateTimeField(default=timezone.now)
    date_created = models.DateTimeField(auto_now_add=True)
    date_modified = models.DateTimeField(auto_now=True)
    description = models.Textfield()
    vat_number = models.CharField(max_length=40, blank=False, null=False)
    address = models.CharField(max_length=300)
예제 #7
0
class Job(models.Model):
    name = models.CharField(max_length=255)
    location = models.CharField(max_length=255)
    description = models.Textfield()
    creator = models.ForeignKey(User, related_name="job_created")
    acceptor = models.ForeignKey(User, related_name="job_accepted", null=True)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
예제 #8
0
class Company(models.Model):
    company_name = models.CHARFIELD(max_length=200)
    category =
    subcategory =
    company_url =
    company_description = models.Textfield()
    created_date = models.DateTimeField(default=timezone.now)

    def publish(self):
      self.save()

    def __str__(self):
      return self.company_name
예제 #9
0
IN VIEWS:
    def create(request):
        if request.method == "POST"
        request.session['name'] = request.POST['first_name']
        return redirect(/)
IN HTML
    {{request.session.name}}


MODELS:

from django.db import models

# Create your models here.
class User(models.Model):     #Class tends to be singular
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    description = models.TextField()    #No limit
    created_at = models.DateTimeField(auto_now_add=True)    #will add time at creation once
    updated_at = models.DateTimeField(auto_now=True)        #will add time everytime it updates

if "User" can have many of another class: One to Many Relationship like users to posts: Create a second class in models

class Post(models.Model):djan
    title = models.Charfield(max_length=45)
    message = models.Textfield(max_length=1000)
    user_id = models.ForeignKey(User)    #This connects the class "Post" to class "User" (one to many)
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    url(r'^users/(?P<id>)\d+)$', views.show)
예제 #10
0
class MeetingType(models.Model):
    meetingtitle=models.Charfield (max_length='64')
    meetingdate=models.Datefield()
    meetingtime=models=models.Integer(max_length = '4')
    meetinglocation==models.Charfield (max_length='256')
    meetingagenda=models.Textfield()
예제 #11
0
class Post(models.Model):
    author_name - models.CharField(max_length=20)
    title = models.CharField(max_length=100)
    content = models.Textfield()
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
예제 #12
0
class curso(models.Model):
   descripcion = models.Textfield()
   Asignatura = models.ManyToManyField(Asignatura)
예제 #13
0
class tipo(models.Model):
  nombre = models.Textfield()
예제 #14
0
class Item(models.Model):
    text = models.Textfield()