473,287 Members | 1,708 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Database setup got problem, not sure where went wrong

hi

this is my database in models.py in the Django application, however, i don not know where is the error, i have tried many times, but always got error to set up database, sometimes they claim indention, however, i checked very carefully the indentation should be correct. the following is my database tables

Expand|Select|Wrap|Line Numbers
  1.  
  2. from django.db import models
  3. from django import newforms as forms
  4.  
  5. import datetime
  6.  
  7. # Create your models here.
  8.  
  9. class Car(models.Model):
  10.     car_brand = models.CharField(maxlength=50)
  11.     car_model = models.CharField(maxlength=60)
  12.     car_specification = models.TextField()
  13.     booking_price = models.FloatField(max_digits=5, decimal_places=2)
  14.     car_status = models.CharField(maxlength=50)
  15.     car_inventory = models.IntegerField()
  16.     carshot = models.ImageField(upload_to='/images/')
  17.  
  18.     def __str__(self):
  19.         return self.car_brand
  20.  
  21.         class Admin:
  22.             pass
  23.  
  24.         class Meta:
  25.             db_table = 'car'
  26.  
  27. class Address(models.Model):
  28.     unit_level = models.CharField(maxlength=50)
  29.     block_number = models.IntegerField()
  30.     unit_number = models.IntegerField()
  31.     post_code = models.IntegerField()
  32.     street_name = models.TextField()
  33.  
  34.     def __str__(self):
  35.         return self.unit_level
  36.  
  37.         class Admin:
  38.             pass
  39.  
  40.         class Meta:
  41.             db_table = 'address'
  42.  
  43. class Transaction(models.Model):
  44.     customer = models.ForeignKey("auth_user")
  45.     payment_type = models.CharField(maxlength=50)
  46.     total_amount = models.FloatField(max_digits=5, decimal_places=2)
  47.        payment_date = models.DateTimeField()
  48.  
  49.     def __str__(self):
  50.         return self.payment_type    
  51.  
  52.         class Meta:
  53.             db_table = 'transaction'   
  54.  
  55. class Booking(models.Model):
  56.     car_status = models.ForeignKey("car")
  57.     start_date = models.DateTimeField()
  58.     return_date = models.DateTimeField()
  59.     location = models.CharField(maxlength=50)
  60.  
  61.     def __str__(self):
  62.             return self.car_status
  63.  
  64.     class Admin:
  65.             pass
  66.  
  67.     class Meta:
  68.             db_table = 'booking'  
  69.  
  70.  
  71.  
thanks for any help given to enable me set up this database, as without this set up, i can not do any application. i am quite new to this framework, thanks for any kind of help :)
Nov 4 '07 #1
6 2002
bartonc
6,596 Expert 4TB
This one (and all the others above it) looks wrong:
Expand|Select|Wrap|Line Numbers
  1.  
  2. class Transaction(models.Model):
  3.     customer = models.ForeignKey("auth_user")
  4.     payment_type = models.CharField(maxlength=50)
  5.     total_amount = models.FloatField(max_digits=5, decimal_places=2)
  6.        payment_date = models.DateTimeField()
  7.  
  8.     def __str__(self):
  9.         return self.payment_type    
  10.    # THIS CLASS IS INDENTED TOO FAR #
  11.         class Meta:
  12.             db_table = 'transaction'   
This one looks right to me:
Expand|Select|Wrap|Line Numbers
  1. class Booking(models.Model):
  2.     car_status = models.ForeignKey("car")
  3.     start_date = models.DateTimeField()
  4.     return_date = models.DateTimeField()
  5.     location = models.CharField(maxlength=50)
  6.  
  7.     def __str__(self):
  8.             return self.car_status
  9.  
  10.     class Admin:
  11.             pass
  12.  
  13.     class Meta:
  14.             db_table = 'booking'  
  15.  
Please not that CODE tags look like CODE=python in side the braces and you have an hour to edit your post if it doesn't look right after you hit the Submit button. Thanks.
Nov 4 '07 #2
This one (and all the others above it) looks wrong:
Expand|Select|Wrap|Line Numbers
  1.  
  2. class Transaction(models.Model):
  3.     customer = models.ForeignKey("auth_user")
  4.     payment_type = models.CharField(maxlength=50)
  5.     total_amount = models.FloatField(max_digits=5, decimal_places=2)
  6.        payment_date = models.DateTimeField()
  7.  
  8.     def __str__(self):
  9.         return self.payment_type    
  10.    # THIS CLASS IS INDENTED TOO FAR #
  11.         class Meta:
  12.             db_table = 'transaction'   
This one looks right to me:
Expand|Select|Wrap|Line Numbers
  1. class Booking(models.Model):
  2.     car_status = models.ForeignKey("car")
  3.     start_date = models.DateTimeField()
  4.     return_date = models.DateTimeField()
  5.     location = models.CharField(maxlength=50)
  6.  
  7.     def __str__(self):
  8.             return self.car_status
  9.  
  10.     class Admin:
  11.             pass
  12.  
  13.     class Meta:
  14.             db_table = 'booking'  
  15.  
Please not that CODE tags look like CODE=python in side the braces and you have an hour to edit your post if it doesn't look right after you hit the Submit button. Thanks.
thanks for your kind reminder, but i am still not sure where went wrong? can tell me what i should do in order to set up this database correctly?
Nov 5 '07 #3
bartonc
6,596 Expert 4TB
thanks for your kind reminder, but i am still not sure where went wrong? can tell me what i should do in order to set up this database correctly?
It turns out that you do have indentation errors (3 tabs instead of 2, etc.). Here it is, corrected:
Expand|Select|Wrap|Line Numbers
  1.  
  2. from django.db import models
  3. from django import newforms as forms
  4.  
  5. import datetime
  6.  
  7. # Create your models here.
  8.  
  9. class Car(models.Model):
  10.     car_brand = models.CharField(maxlength=50)
  11.     car_model = models.CharField(maxlength=60)
  12.     car_specification = models.TextField()
  13.     booking_price = models.FloatField(max_digits=5, decimal_places=2)
  14.     car_status = models.CharField(maxlength=50)
  15.     car_inventory = models.IntegerField()
  16.     carshot = models.ImageField(upload_to='/images/')
  17.  
  18.     def __str__(self):
  19.         return self.car_brand
  20.  
  21.     class Admin:
  22.         pass
  23.  
  24.     class Meta:
  25.         db_table = 'car'
  26.  
  27. class Address(models.Model):
  28.     unit_level = models.CharField(maxlength=50)
  29.     block_number = models.IntegerField()
  30.     unit_number = models.IntegerField()
  31.     post_code = models.IntegerField()
  32.     street_name = models.TextField()
  33.  
  34.     def __str__(self):
  35.         return self.unit_level
  36.  
  37.     class Admin:
  38.         pass
  39.  
  40.     class Meta:
  41.         db_table = 'address'
  42.  
  43. class Transaction(models.Model):
  44.     customer = models.ForeignKey("auth_user")
  45.     payment_type = models.CharField(maxlength=50)
  46.     total_amount = models.FloatField(max_digits=5, decimal_places=2)
  47.        payment_date = models.DateTimeField()
  48.  
  49.     def __str__(self):
  50.         return self.payment_type    
  51.  
  52.     class Meta:
  53.         db_table = 'transaction'   
  54.  
  55. class Booking(models.Model):
  56.     car_status = models.ForeignKey("car")
  57.     start_date = models.DateTimeField()
  58.     return_date = models.DateTimeField()
  59.     location = models.CharField(maxlength=50)
  60.  
  61.     def __str__(self):
  62.         return self.car_status
  63.  
  64.     class Admin:
  65.         pass
  66.  
  67.     class Meta:
  68.         db_table = 'booking'  
  69.  
Nov 5 '07 #4
It turns out that you do have indentation errors (3 tabs instead of 2, etc.). Here it is, corrected:
[code=python]

from django.db import models
from django import newforms as forms

import datetime

# Create your models here.

class Car(models.Model):
car_brand = models.CharField(maxlength=50)
car_model = models.CharField(maxlength=60)
car_specification = models.TextField()
booking_price = models.FloatField(max_digits=5, decimal_places=2)
car_status = models.CharField(maxlength=50)
car_inventory = models.IntegerField()
carshot = models.ImageField(upload_to='/images/')

def __str__(self):
return self.car_brand

class Admin:
pass

class Meta:
db_table = 'car'

class Address(models.Model):
unit_level = models.CharField(maxlength=50)
block_number = models.IntegerField()
unit_number = models.IntegerField()
post_code = models.IntegerField()
street_name = models.TextField()

def __str__(self):
return self.unit_level

class Admin:
pass

class Meta:
db_table = 'address'

class Transaction(models.Model):
customer = models.ForeignKey("auth_user")
payment_type = models.CharField(maxlength=50)
total_amount = models.FloatField(max_digits=5, decimal_places=2)
payment_date = models.DateTimeField()

def __str__(self):
return self.payment_type

class Meta:
db_table = 'transaction'

class Booking(models.Model):
car_status = models.ForeignKey("car")
start_date = models.DateTimeField()
return_date = models.DateTimeField()
location = models.CharField(maxlength=50)

def __str__(self):
return self.car_status

class Admin:
pass

class Meta:
db_table = 'booking'
[-code]
really thanks for your so kind help, i have setted up my database. actually, i did not import image library of Django and i use in the field ImageField(upload_to='/images/'), thus the program complain. however, here i still have one question.
As you know i make use of Django's user authentication system to set up my database tables, thus it only provide me two fields available in the template, i mean only username and password field, how can i include Email, NRIC ( for Singaporean) and Passport No for foreigner? do i really have to setup another table for user/member? can i add into auth_user table, in fact, i have noticed that auth_user table got one field called Email, but i am not sure how to activate its function. can help me with this. thanks so much :)
Nov 5 '07 #5
bartonc
6,596 Expert 4TB
really thanks for your so kind help, i have setted up my database. actually, i did not import image library of Django and i use in the field ImageField(upload_to='/images/'), thus the program complain. however, here i still have one question.
As you know i make use of Django's user authentication system to set up my database tables, thus it only provide me two fields available in the template, i mean only username and password field, how can i include Email, NRIC ( for Singaporean) and Passport No for foreigner? do i really have to setup another table for user/member? can i add into auth_user table, in fact, i have noticed that auth_user table got one field called Email, but i am not sure how to activate its function. can help me with this. thanks so much :)
I'm sorry to say that I don't know a thing about internet programming.
I have only been able to spot errors in your python code because I have been working with python every day for years.
Nov 5 '07 #6
I'm sorry to say that I don't know a thing about internet programming.
I have only been able to spot errors in your python code because I have been working with python every day for years.
never mind, i still would like to thank you for your kind help, however, if possible, could forward my problems to some one who know more of Django, i am really sorry about this as this is my Final year project, thus the time line is also quite tight, there is only few weeks before i submit. thanks for all your kind help to me...:)
Nov 5 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
8
by: 2centbob | last post by:
Has anyone had an issue with SQL Server not being able to expand against a RAID 5 file system? My current configuration is that the server is started and stopped using the local system account. I...
2
by: Rosy Moss | last post by:
I am in the process of cleaning up a database that our company uses to track jobs, time and expense, and customer information. We are running Windows 2000 Server with approximately 20 terminals...
10
by: MHenry | last post by:
Hi, We were going merrily along for 6 years using this database to record all client checks that came into our office, including information about what the checks were for. Suddenly, network...
6
by: alanknipmeyer | last post by:
Hi, I`m in the process of migrating a Access 2002 (Run in 2000 mode) from Windows 98 to Win2K Server. It is a shared resource via a file share on the 98 Server. Client systems are Win98 with the...
2
by: Buddy Ackerman | last post by:
I have a web app that I have setup on numerous web servers. I've set one up for a new client at their hosting facility and cannot get it to connect to their database. I get a "SQL Server does not...
2
by: A.Carter | last post by:
I am developing a windows application with Visual Studio 2003 using C#. The application is complete so naturally I went to create a setup package. I added a setup project to the solution and I went...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
24
by: Donn Ingle | last post by:
Hello, I hope someone can illuminate this situation for me. Here's the nutshell: 1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale. 2. If this returns "C" or anything...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.