1

It seems that i am stuck. I need your help in order to fix this error. I think the regex on the URL is rotten. Any help will be much appreciated.

This is the error:

File "/Users/cohen/Documents/project/sanctions/batches/urls.py", line 2, in from . import views File "/Users/cohen/Documents/project/sanctions/batches/views.py", line 23 def detail_businessname(request): ^ SyntaxError: invalid syntax

These are my models:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models


class Batches(models.Model):
    BatchNumber = models.IntegerField(null=True)
    FileName= models.CharField(max_length=250)
    UploadedDate= models.DateField(max_length=250)
    UploadedBy = models.CharField(max_length=250)
    NumberOfRows= models.IntegerField(null=True)
    Hits= models.IntegerField(null=True)
    Status= models.CharField(max_length=250)

    class Meta:
        verbose_name_plural = "Batches"
    def __str__(self):
        return self.FileName + '- ' + str(self.Hits) + '- ' + str(self.NumberOfRows) + '- ' + self.Status



class BusinessName(models.Model):
    AccountingCode = models.CharField(max_length=50)
    RefID = models.CharField(max_length=50, default="")
    FullName = models.CharField(max_length=250)
    Aliases = models.CharField(max_length=250)
    Address = models.CharField(max_length=500)
    City= models.CharField(max_length=50)
    ZipCode= models.IntegerField(null=True)
    State = models.CharField(max_length=250)
    Country= models.CharField(max_length=250)
    TypeOfSanction= models.CharField(max_length=250)
    Monitoring= models.CharField(max_length=50)
    BatchNumber= models.IntegerField(null=True)  # tr pus automat
    FileName= models.CharField(max_length=250)  # tr pus automat1
    UploadDate = models.DateField(max_length=250) # tr pus automat
    UploadBy= models.CharField(max_length=250) # tr pus automat
    Decision= models.CharField(max_length=250) # tr pus Ulterior
    Status= models.CharField(max_length=250) # tr pus automat
    EngineDecision= models.CharField(max_length=250) # tr pus automat
    WhoAdjudicated= models.CharField(max_length=250)
    DateOfAdjudication= models.CharField(max_length=250)
    SdnType = models.CharField(max_length=250)  #Entity or Individual

    class Meta:
        verbose_name_plural = "Business Names"
    def __str__(self):
        return self.FullName + '-' + self.Address  + '-' + self.City + '-' + '-' + self.State + '-' + self.Country

class Individuals(models.Model):
    AccountingCode = models.CharField(max_length=50)
    RefID = models.IntegerField(null=True)
    FullName = models.CharField(max_length=250)
    FirstName= models.CharField(max_length=250)
    Lastname= models.CharField(max_length=250)
    DayOfBirth = models.IntegerField(null=True)
    MonthOfBirth = models.IntegerField(null=True)
    YearOfBirth= models.IntegerField(null=True)
    FullDOB = models.DateField(max_length=250)
    Aliases = models.CharField(max_length=250)
    Address = models.CharField(max_length=500)
    City= models.CharField(max_length=50)
    ZipCode= models.IntegerField(null=True)
    State = models.CharField(max_length=250)
    Country= models.CharField(max_length=250)
    TypeOfSanction= models.CharField(max_length=250)
    Monitoring= models.CharField(max_length=50)
    BatchNumber= models.IntegerField(null=True)  # tr pus automat
    FileName= models.CharField(max_length=250)  # tr pus automat
    UploadDate= models.DateField(max_length=250) # tr pus automat
    UploadBy= models.CharField(max_length=250) # tr pus automat
    Decision= models.CharField(max_length=250) # tr pus Ulterior
    Status= models.CharField(max_length=250) # tr pus automat
    EngineDecision= models.CharField(max_length=250) # tr pus automat
    WhoAdjudicated= models.CharField(max_length=250)
    DateOfAdjudication= models.CharField(max_length=250)
    More= models.CharField(max_length=250)
    SdnType = models.CharField(max_length=250)  #Entity or Individual

    class Meta:
        verbose_name_plural = "Individuals"

    def __str__(self):
        return self.FullName + '-' + self.Address + '-' + self.City  + '-' + '-' + self.State + '-' + self.Country

This is my views:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from .models import BusinessName
from .models import Individuals
from .models import Batches

from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
def index(request):
    all_Batches = Batches.objects.all()
    html = ''
    for batch in all_Batches:
        url = '/batches/' + str(batch.id) + '/'
        html += '<a href="#"' + url + '">' + str(Batches.BatchNumber)+ '</a><br>'
    return  HttpResponse(html)

def detail(request, BatchNumber):
    return HttpResponse("<h2>Details for Batches ID:"  + str(BatchNumber + "</h2")


def detail_businessname(request):
    all_BusinessNames = BusinessName.objects.all()
    html = ''
    for BN in all_BusinessNames:
        url = '/businessname/' + str(BusinessName.id) + '/'
        html += '<a href="#"' + url + '">' + BusinessName.FullName + '</a><br>'
    return HttpResponse(html)


def detail_individuals(request):
    return HttpResponse("<h2>Details for Individual Names ID:"  + str(Individuals.id) + "</h2")

And these are the urls:

from django.conf.urls import url
from . import views

urlpatterns = [
    # /batches/
    url(r'^$', views.index, name='index'),

    # /batches/2
    url(r'^(?P<batches_id>[0-9]+)/$',views.detail, name="detail"),

    # businessname/1
    url(r'^(?P<businessname_id>[0-9]+)/$',views.detail_businessname, name="detail_businessname"),

    # individuals/1
    url(r'^(?P<individuals_id>[0-9]+)/$', views.detail_individuals, name="detail_individuals"),

Thank you a lot, Cohen

1 Answer 1

2

You miss closed braket

return HttpResponse("<h2>Details for Batches ID:"  + str(BatchNumber + "</h2"))
Sign up to request clarification or add additional context in comments.

1 Comment

@JohnCohen If you get a syntax error and can't figure out why, looking at the previous line will normally help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.