Hey , 

I am facing a lot of issues regarding this foreign key !.

Scenario is a s follows :-

models.py

class ComponentDeprecation(models.Model):
    row_id = models.IntegerField(primary_key=True)
    component = models.ForeignKey('SsComponents', db_column='component')
    submitter = models.CharField(max_length=12)
    description = models.CharField(max_length=4000)
    deprecation_date = models.DateField()
    submitted_date = models.DateTimeField()
    deprecated_by = models.CharField(max_length=12, blank=True, null=True)
    deprecated_date = models.DateTimeField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'component_deprecation'


class SsComponents(models.Model):
    component = models.CharField(primary_key=True, max_length=40)
    ddts_class = models.CharField(max_length=20)
    vob = models.CharField(max_length=20)
    vob_rel_path = models.CharField(max_length=30)
    owner = models.CharField(max_length=16, blank=True, null=True)
    comp_main_branch = models.CharField(max_length=60, blank=True, 
null=True)
    starting_version = models.CharField(max_length=10, blank=True, 
null=True)
    include_list = models.CharField(max_length=60, blank=True, null=True)
    other_list = models.CharField(max_length=60, blank=True, null=True)
    created_by = models.CharField(max_length=16)
    created_date = models.DateField()
    comp_type = models.CharField(max_length=3, blank=True, null=True)
    lifecycle = models.CharField(max_length=20, blank=True, null=True)
    description = models.CharField(max_length=4000, blank=True, null=True)
    component_approval = models.ForeignKey(ComponentApproval, blank=True, 
null=True)
    component_deprecation = models.ForeignKey(ComponentDeprecation, 
blank=True, null=True)
    migrated = models.NullBooleanField()
    migrated_date = models.DateField(blank=True, null=True)
    last_updatetime = models.DateField(blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'ss_components'

views.py 

def lc_depr_detail_form(request):
    '''
    Returns the Fields in the form of List containing Dictionary to be 
rendered to HTML Page for Deprecate Report.
    '''
    user_name = request.META['REMOTE_USER']
    #Fetching the field values from the HTML Page
    component = request.POST.get('comp')
    submitter = request.POST.get('submitter')
    submitted_date = request.POST.get('sub_date')
    deprecated_by = request.POST.get('dep_by')
    deprecated_date = request.POST.get('dep_date')
    stri = ""
    #Putting the field  values in a string variable
    if(component and component!= "None"):
        comp1= component.replace("*", ".*")
        stri=stri+" ,component=r'^%s$'" % (comp1)
    if(submitter and submitter!= "None"):
        submitter1=submitter.replace("*", ".*")
        stri=stri+" ,submitter__regex=r'^%s$'" % (submitter1)
    if(submitted_date and submitted_date!= "None"):
        sub_date1=submitted_date.replace("*", ".*")
        stri=stri+" ,submitted_date__regex=r'^%s$'" % (sub_date1)
    if(deprecated_by and deprecated_by!= "None"):
        dep_by1=deprecated_by.replace("*", ".*")j
        stri=stri+" ,deprecated_by__regex=r'^%s$'" % (dep_by1)
    if(deprecated_date and deprecated_date!= "None"):
        dep_date1=deprecated_date.replace("*", ".*")
        stri=stri+" ,deprecated_date__regex=r'^%s$'" % (dep_date1)
    #Substituting the first comma with a space
    data= re.sub(r',',"",stri,1)
    #Checking when no data is Entered in the Form
    if (data == ''):
        return render(request, 
'lc_depr.html',{'user':user_name,'message':'Please provide atleast one 
Input','page':r'help/home.html'})
    
details="ComponentDeprecation.objects.filter(%s).order_by('-deprecated_date').values('component','deprecated_by','deprecated_date')"
 
% (data)
    print details
    #Evaluates the details as a Python Expression
    details_list = eval(details)
    print details_list
    #Checking if the list is empty due to Wrong data Input by the User
    if not details_list:
        return render(request, 
'lc_depr_report.html',{'user':user_name,'message':'Oops! Couldnot figure 
out what you were searching for.Please recheck the inputs provided for the 
query','page':r'help/home.html'})
    else:
        return render(request, 
'lc_depr_report.html',{'user':user_name,'details_list':details_list,'page':r'help/home.html'})
                                                                            
                                                     

i am getting this error: related field got invalid lookup: regex component 
only 
i dont know how to access the value of component .. for other fields no 
error is comming .




-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/773176fa-3560-49eb-afbd-0ca8eac30b1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to