Quantcast
Channel: Jack @ ASP.NET » Python
Viewing all articles
Browse latest Browse all 8

define models class in django

$
0
0
__author__ = ‘Administrator’ from django.db import models from django.contrib import admin class AvaliabeSites(models.Model): name = models.CharField(max_length=200) code = models.CharField(max_length=200) def __unicode__(self): return self.name admin.site.register(AvaliabeSites) class Keyword(models.Model): user = models.ForeignKey(User, editable=True) keyword =  models.CharField(max_length=100) def __str__(self): return str(self.keyword) # add new one     def AddKeyword(self, keyword): keyword = keyword.strip() checkKeyword = Keyword.objects.filter(user=self.user) if not checkKeyword:    [...]

Viewing all articles
Browse latest Browse all 8

Trending Articles