I don't think you will get anyone to wade through your code and correct it for you. You need to be much more specific in your question. What behavior do you expect from your code, what is it doing that it shouldn't be doing, what doe the error logs say, where is the specific problem in your code, (give just that snippet), and what have you tried to solve the problem?
Read this: http://www.catb.org/esr/faqs/smart-questions.html, and try again. If you follow this guide, you will get lots of excellent support from open source communities. Mark On Sun, Sep 22, 2013 at 5:37 PM, ghenessa sabaldan <ghene...@gmail.com>wrote: > I am really stuck in my code. I have this printing project I have created. > I wanted that in my student profile class, it will automatically update the > the total printout and the available printout after the user has inputted > the corresponding value in the prinout class. and also the report > generation will be by computer lab rooms. this is done in the default > administration of django. Im using by the way python 2.7, django 1.5.2, > Eclipse Standard/SDK and mysql workbench 5.2.47 CE. thanks. Attach here is > a zip file of my programs. > > *model.py* >> >> class Student_Profile(models.Model): >> id_number = models.CharField(max_length= 60, unique = True) >> first_name = models.CharField(max_length= 60) >> middle_name = models.CharField(max_length= 60) >> last_name = models.CharField(max_length= 60) >> active = models.BooleanField() >> date_created = models.DateTimeField('date created') >> >> >> def my_property(self): >> return self.last_name + ', ' + self.first_name + ' ' + self.middle_name >> my_property.short_description = "Full name of the person" >> >> name = property(my_property) >> >> def __unicode__(self): >> return u'%s, %s %s' % (self.last_name, self.first_name, self.middle_name) >> >> >> class Semester(models.Model): >> #I manually encode it to mysql workbenc >> semester = models.CharField(max_length= 60) >> >> def __unicode__(self): >> return self.semester >> >> >> class Student_Subject(models.Model): >> >> Student_Profile = models.ForeignKey(Student_Profile) >> subject_code = models.CharField(max_length= 60) >> teacher = models.CharField(max_length= 60) >> total_printout = models.PositiveSmallIntegerField(default=0) >> available_printout = models.PositiveSmallIntegerField(default=50) >> room = models.CharField(max_length= 60) >> semester = models.ForeignKey(Semester) >> school_year = models.CharField(max_length= 30) >> date_joined = models.DateField() >> >> >> >> def __unicode__(self): >> return self.subject_code >> >> >> class Room(models.Model): >> #I manually encode it to mysql workbenc >> room = models.CharField(max_length= 60) >> >> def __unicode__(self): >> return self.room >> >> >> class Printout(models.Model): >> Student_Name = models.ForeignKey(Student_Profile) >> Subject = ChainedForeignKey( >> Student_Subject, >> chained_field="Student_Name", >> chained_model_field="Student_Profile", >> show_all=False, >> auto_choose=True >> ) >> room = models.ForeignKey(Room) >> printout = models.PositiveSmallIntegerField(default=0) >> created_by = models.ForeignKey(User, null=True, blank=True) >> date_created = models.DateField() >> time_created = models.TimeField() >> >> *admin.py* >> >> from django.contrib import admin >> from models import Student_Profile, Student_Subject, Printout >> >> >> class Student_SubjectInline(admin.TabularInline): >> model = Student_Subject >> extra = 1 >> >> class Student_ProfileAdmin(admin.ModelAdmin): >> >> inlines = (Student_SubjectInline,) >> search_fields = ['last_name', 'first_name', 'id_number'] >> list_display = ('name', 'id_number') >> ordering = ('last_name', 'first_name', 'middle_name',) >> pass >> >> admin.site.register(Student_Profile, Student_ProfileAdmin) >> >> >> >> from django.contrib.auth.models import User >> >> class PrintoutAdmin(admin.ModelAdmin): >> >> list_display = ('room', 'created_by', 'Student_Name', 'printout', >> 'Subject', 'date_created', 'time_created' ) >> #search_fields = ['room'] >> list_filter = ['room'] >> >> def formfield_for_foreignkey(self, db_field, request, **kwargs): >> if db_field.name == 'created_by': >> kwargs['queryset'] = User.objects.filter(username=request.user.username) >> return super(PrintoutAdmin, self).formfield_for_foreignkey(db_field, >> request, **kwargs) >> >> def get_readonly_fields(self, request, obj=None): >> if obj is not None: >> return self.readonly_fields + ('created_by',) >> return self.readonly_fields >> >> def add_view(self, request, form_url="", extra_context=None): >> data = request.GET.copy() >> data['created_by'] = request.user >> request.GET = data >> return super(PrintoutAdmin, self).add_view(request, form_url="", >> extra_context=extra_context) >> pass >> >> admin.site.register(Printout, PrintoutAdmin) >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.