You are not logged in.

Change Language:

Freelancer? Consultant? Check out: WorkTrail - Time Tracking made easy
Profile for arwa

Name arwa
Email Address n/a
Posts46
  • Re: import modules in to apache
    Board » Django » Templates
    Your enviroment variables now is not used by apache/wsgi (like runserver for your user).
    Probably you have an wsgi file that say how apache interprets python.
    When it breaks your browser shows something like this: http://stackoverflow.com/questions/2125080/how-can-i-see-error-logs-of-django-views
    After python version you have python paths.
    Try to see if there is D:\share\django\myFirstSite
    If is not in you must to modify wsgi file for your apache.

    I hope that this info is userful for you to solve the problem.
  • Re: import modules in to apache
    Board » Django » Templates
    Hi, in your project "myFirstSite" in app "mySite" try to see "views.py"

    Exception Type: ImportError
    Exception Value: No module named mySite.models
    Exception Location: //vschnws2001/share/django\myFirstSite\mySite\views.py in <module>, line 6


    At line 6 you have something like this: "from mySite.models import *"
    Is possibile that your PYTHON_PATH is not correctly set.
    If you want you can use this view to see all paths in pythonpath:
    def test_paths(request):
      out = '<br>'.join(sys.path)
      return HttpResponse(out)
    

    I think that you have also all these paths in exception page in debug mode.


    --- Last Edited by arwa at 2012-02-21 07:07:13 ---
  • Re: query data with date as column name.
    Board » Django » Templates
    no problem ;-)
  • Re: query data with date as column name.
    Board » Django » Templates
    I don't think that I understood very well but the idea is really ok.
    Some months ago I start something like this to create a product like TRAC (is this your purpose ?).
    I try to give you some ideas on it.
    Put one column for one day is not a good idea.
    Is better to have a model with date and, a field with text, and a FK to user (and percentage if you want).
    This is an example about model relations (you can put percent in task also):
    class Task(models.Model):
      project    = models.ForeignKey('Project')
      activity   = models.ForeignKey('Activity')
      date       = models.DateField()
      time_from  = models.TimeField(blank=True,null=True,help_text='If sets, this overload delta values')
      time_to    = models.TimeField(blank=True,null=True,help_text='If sets, this overload delta values')
      time_delta_mins  = models.IntegerField(blank=True,null=True)
      time_delta_hours = models.IntegerField(blank=True,null=True)
      note       = models.TextField(blank=True)
      billable   = models.BooleanField(blank=True)
      user       = models.ForeignKey('auth.User')
      class Meta:
        verbose_name        = _(u'Task')
        verbose_name_plural = _(u'Tasks')
        db_table            = 'data_tasks'
      def __unicode__(self):
        return '%s - %s' %(self.date,self.user)
      def time_delta(self):
        return '%s:%s' % (self.time_delta_hours,self.time_delta_mins)
    
    class Project(models.Model):
      name     = models.CharField(max_length=255)
      customer = models.ForeignKey('Customer',blank=True,null=True)
      users    = models.ManyToManyField('auth.User',blank=True,null=True)
      class Meta:
        verbose_name        = _(u'Project')
        verbose_name_plural = _(u'Projects')
        db_table            = 'data_projects'
      def __unicode__(self):
        return '%s' %(self.name)
    
    class Customer(models.Model):
      name  = models.CharField(max_length=255)
      piva  = models.CharField(max_length=31,blank=True,null=True)
      cf    = models.CharField(max_length=31,blank=True,null=True)
      phone = models.CharField(max_length=31,blank=True,null=True)
      cell  = models.CharField(max_length=31,blank=True,null=True)
      fax   = models.CharField(max_length=31,blank=True,null=True)
      email = models.EmailField(max_length=255,blank=True,null=True)
      class Meta:
        verbose_name        = _(u'Customer')
        verbose_name_plural = _(u'Customers')
        db_table            = 'data_customers'
      def __unicode__(self):
        return '%s' %(self.name)
    
    class Activity(MPTTModel):
      name        = models.CharField(max_length=255)
      description = models.TextField(blank=True,null=True)
      # mptt system
      level    = models.IntegerField(_('Level'),editable=False)
      parent   = models.ForeignKey("self",blank=True,null=True, related_name='children',verbose_name=_('Parent'))
      lft      = models.IntegerField(_(u'Left'))
      rght     = models.IntegerField(_(u'Right'))
      tree_id  = models.IntegerField(_(Tree ID'))
      projects = models.ManyToManyField('Project',blank=True,null=True)
      class Meta:
        verbose_name        = _(u'Activity')
        verbose_name_plural = _(u'Activities')
        db_table            = 'data_activities'
      def __unicode__(self):
        return '%s' %(self.name)
    
  • Re: query data with date as column name.
    Board » Django » Templates
    In your model if you don't want to have this 2012-02-16 for field name you can use db_column.
    https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.db_column
    Ex.
    class MyModel(models.Model):
      mydate = models.YourTypeField(db_column='2012-02-16')
    

    In this way you can use this for template {{yourdata.mydate}}

    One question: You are sure that you want 2012-02-16 for a db column name :-) ?
  • Re: how to concatenate numbers as strings in template vars?
    Board » Django » Templates
    The problem is in add filter definition in django source code:
    https://code.djangoproject.com/browser/django/trunk/django/template/defaultfilters.py#L672
    @register.filter(is_safe=False)
    def add(value, arg):
        """Adds the arg to the value."""
        try:
            return int(value) + int(arg)
        except (ValueError, TypeError):
            try:
                return value + arg
            except Exception:
                return ''
    

    In this way I suggest to create a new filter:
    @register.filter(is_safe=False)
    def merge_string(value, arg):
        """Merge string."""
        try:
            return str(value) + str(arg)
        except (TypeError):
            return ''
    
  • Re: looping and related fields
    Board » Django » Templates
    Another think:
    https://docs.djangoproject.com/en/dev/ref/models/querysets/#django.db.models.query.QuerySet.select_related
    Your django code for select related probably is not correct: from documentation yuo want to use this:
    hotfix_data = Hotfixes.objects.all().select_related('patch__name').filter(patch__name__isnull=False).order_by('-patch_id')[:30]
    and not this
    hotfix_data = Hotfixes.objects.all().select_related('patch_id__name').filter(patch_id__name__isnull=False).order_by('-patch_id')[:30]
  • Re: looping and related fields
    Board » Django » Templates
    In this way the problem is in your HTML code I think:
    You use this:
    {% for o on obj %} 
      {{ o.patch_id.name }} 
    {% endfor %}
    

    but if "o" is an Hotfixes instance, from Hotfixes model I think that the fk to Patches is only "patch":
    {% for o on obj %} 
      {{ o.patch.name }} 
    {% endfor %}
    

  • Re: how to get two form values in one def
    Board » Django » Templates
    Hi, I suggest to see django forms to work better on form.
    https://docs.djangoproject.com/en/dev/topics/forms/

    And this is a solution for your problem:
    <form action="." method="get">
    
    <table align="center">
      <tr><td>Enter Employee ID:<input type = "text" name = "empid"/ ></td></tr>
      <tr><td><input type = "submit" value = "Submit" onclick="javascript: form.action='/searchid/';" /> </td></tr>
    </table>
    
    <table align="center">
    <tr><td>Enter No.of Days:  <input type = "text" name = "leaveDays" /></td></tr>
    <tr><td><input type = "submit" value = "Update" onclick="javascript: form.action='/leaveUpdate/';" /></td></tr>
    </table>
    
    </form>
    
  • Re: __File__
    Board » General Category » General Discussion
    Hi,

    your ticket object solve your problem :-)
    Put double _ before and after file string like this -> __File__ (and not _File_)
    That is all.


Powered by Sphene Community Tools