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 -
-
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'
-
-
-
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 :)
6 2002
This one (and all the others above it) looks wrong: -
-
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
-
# THIS CLASS IS INDENTED TOO FAR #
-
class Meta:
-
db_table = 'transaction'
This one looks right to me: -
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'
-
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.
This one (and all the others above it) looks wrong: -
-
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
-
# THIS CLASS IS INDENTED TOO FAR #
-
class Meta:
-
db_table = 'transaction'
This one looks right to me: -
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'
-
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?
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: -
-
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'
-
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 :)
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.
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...:)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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"....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| | |