473,595 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database setup got problem, not sure where went wrong

88 New Member
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 2016
bartonc
6,596 Recognized Expert Expert
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
kang jia
88 New Member
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 Recognized Expert Expert
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
kang jia
88 New Member
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.Mode l):
car_brand = models.CharFiel d(maxlength=50)
car_model = models.CharFiel d(maxlength=60)
car_specificati on = models.TextFiel d()
booking_price = models.FloatFie ld(max_digits=5 , decimal_places= 2)
car_status = models.CharFiel d(maxlength=50)
car_inventory = models.IntegerF ield()
carshot = models.ImageFie ld(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.CharFiel d(maxlength=50)
block_number = models.IntegerF ield()
unit_number = models.IntegerF ield()
post_code = models.IntegerF ield()
street_name = models.TextFiel d()

def __str__(self):
return self.unit_level

class Admin:
pass

class Meta:
db_table = 'address'

class Transaction(mod els.Model):
customer = models.ForeignK ey("auth_user" )
payment_type = models.CharFiel d(maxlength=50)
total_amount = models.FloatFie ld(max_digits=5 , decimal_places= 2)
payment_date = models.DateTime Field()

def __str__(self):
return self.payment_ty pe

class Meta:
db_table = 'transaction'

class Booking(models. Model):
car_status = models.ForeignK ey("car")
start_date = models.DateTime Field()
return_date = models.DateTime Field()
location = models.CharFiel d(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(uplo ad_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 Recognized Expert Expert
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(uplo ad_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
kang jia
88 New Member
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
3034
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 write some PHP code which should, I think, be able to to auto create the tables. The SQL looks like this:
8
4874
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 have only one database (besides the master, model,etc)on the server. What has happend to me several times is that the primary database in question try's to expand the main datafile for the database (.mdf). I setup the database to not expand...
2
5062
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 (Each running 2000) logging in each day. Four of these terminals access the server via Citrix. Currently the database is about 60MB, but it grows to 150 and larger each week. I am constantly having to compact it to keep it running smoothly. ...
10
6029
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 computers cannot access the database. The message is...
6
2250
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 shared drive mounted and the application run via the shared drive. I have tried once before, but came across some file locking issues. I thought i had addressed these file locking issues, but it came apparent I hadn't when data started to get...
2
1411
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 exist or access denied." error. Well, the strangeness is that I have a SQL Query tool installed on this server and can connect to the database fine using the exact same connection parameters that I have specified in my web app. Even more strange...
2
2003
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 through the appropriate steps in attaching the solution dependencies. After completing the setup package, I attempted to install the application on a co-worker's computer. Usually, the installation consist of several screens which directs the...
9
3823
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 site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
24
3361
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 without 'utf8' in it, then things start to go downhill: 2a. The app assumes unicode objects internally. i.e. Whenever there is
0
7955
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8019
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5418
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.