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 2016 bartonc 6,596
Recognized Expert Expert
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?
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: -
-
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.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 :)
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.
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 write some PHP code which should, I think, be able to to auto create
the tables.
The SQL looks like this:
|
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...
|
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. ...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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
|
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...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |