Thanks I thnk this is almost done. This is a pretty small app, but
changing it over is teaching me a lot about django, and this admin
error should be the last thing. I saw that it is not in the oldforms
like formfields and validators, thus I get is this error:
ViewDoesNotExist: Tried index in module
intraweb.apps.timesheets.views. Error was: 'module' object has no
attribute 'Admin'
class models:
admin = models.Admin()
Seem to be the lines, is this a sub class that only the main class can
see.
How should I refer to it now?
new code:
from django.db import models
from django.contrib.auth.models import User
#from django.contrib.auth.models import users
from django.oldforms import FormField, validators
from datetime import date
import datetime
def isValidTime(field_data, all_data):
if all_data.has_key('worked') and all_data['worked'] == "on":
try:
if not (0<=int(field_data)<=100):
raise validators.ValidationError("Percent Federal Time must be
between 0 and 100")
except ValueError:
raise validators.ValidationError("Percent Federal Time must be
between 0 and 100")
class Entry(models.Model):
date = models.DateField('entry date', default=date.today())
user = models.ForeignKey(User, unique_for_date="date")
time = models.SmallIntegerField('federal percent', default=0,
validator_list=[isValidTime])
worked = models.BooleanField('did work', default=True)
def __repr__(self):
return "(%s) %s" % (self.date.__str__(),
self.get_user().get_full_name())
def get_absolute_url(self):
return "/app/timesheets/%s/%i/%i/%i/" %
(self.get_user().username,
self.date.year, self.date.month, self.date.day)
class models:
admin = models.Admin()
def isok(self, cutoff_date = datetime.date.today()):
return (self.id!='') or (self.date>cutoff_date)
def get_date(self):
return self.date.strftime("%x")
def get_weekday(self):
return self.date.strftime("%a")
def istoday(self):
return self.date == datetime.date.today()
def status_text(self):
if not self.worked: s = "--"
elif self.date <= datetime.date.today():
if not self.isok(): s = "Missing"
else: s = "%i%%" % self.time
elif self.id != '': s = "%i%%" % self.time
else: s = ''
return s
class JobPosition(models.Model):
position = models.CharField('Job Title', maxlength=30)
address1 = models.CharField('Address Line 1', maxlength=40)
address2 = models.CharField('Address Line 1', maxlength=40,
blank=True)
city = models.CharField('City', maxlength=20)
state = models.CharField('State', maxlength=2)
zip = models.CharField('Zip', maxlength=5)
user = models.OneToOneField(User)
class models:
admin = models.Admin()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---