You are getting this because the database needs to have a value for
existing row(s), you can set default value or make the new field nullable
Either of these would work for you

Transactions(models.Model):
    income = models.IntegerField(null=True, blank=True)
    expense = models.IntegerField(null=True, blank=True)


Or


Transactions(models.Model):
    income = models.IntegerField(default=0)
    expense = models.IntegerField(default=0)

On Thu, Feb 8, 2024, 18:29 Janet Anastacia <[email protected]>
wrote:

> RE: DJANGO MODELS
> i have created an application called expense in django which has two
> fields in the models.py file which looks like class
> Transactions(models.Model):
>     income = models.IntegerField(null=False, blank=False)
>     expense = models.IntegerField(null=False, blank=False)
>
> I want my application to allow users to enter their expense and income
> themselves and these fields must be provided, it should not be empty. But
> when i run the command python manage.py makemigrations i get the this: It
> is impossible to add a non-nullable field 'expense' to transactions without
> specifying a default. This is because the database needs something to
> populate existing rows.
> Please select a fix: 1) Provide a one-off default now (will be set on all
> existing rows with a null value for this column) 2) Quit and manually
> define a default value in models.py. Select an option: Please select a
> valid option: Please select a valid option:
> i have chosen option 2 but still got the same prompt. how do solve this.
>
>
> On Sat, Feb 3, 2024 at 9:00 PM Kevin Tuo <[email protected]> wrote:
>
>> Good idea, Thanks!
>>
>> Envoyé à partir de Outlook pour Android <https://aka.ms/AAb9ysg>
>> ------------------------------
>> *From:* [email protected] <[email protected]> on
>> behalf of Obam Olohu <[email protected]>
>> *Sent:* Saturday, February 3, 2024 4:15:02 PM
>> *To:* [email protected] <[email protected]>
>> *Subject:* Re: Book
>>
>> why don't you learn directly from a tutor?
>>
>>
>> On Thu, Feb 1, 2024 at 3:14 AM Kevin Tuo <[email protected]> wrote:
>>
>> Hello, Please can I get a book for building a portfolio website with
>> django?
>>
>>
>> Envoyé à partir de Outlook pour Android <https://aka.ms/AAb9ysg>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/AS4PR09MB55764DA8881C3AB572B7468AFA7C2%40AS4PR09MB5576.eurprd09.prod.outlook.com
>> <https://groups.google.com/d/msgid/django-users/AS4PR09MB55764DA8881C3AB572B7468AFA7C2%40AS4PR09MB5576.eurprd09.prod.outlook.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMc8uwNeDWk8QRicjFHg_Ph6%3DrN7ARRgGxAQBzxVM7ASFupL9g%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAMc8uwNeDWk8QRicjFHg_Ph6%3DrN7ARRgGxAQBzxVM7ASFupL9g%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/VI1PR07MB511726EE0F530FF06C424722FA412%40VI1PR07MB5117.eurprd07.prod.outlook.com
>> <https://groups.google.com/d/msgid/django-users/VI1PR07MB511726EE0F530FF06C424722FA412%40VI1PR07MB5117.eurprd07.prod.outlook.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAA_zVTGp-HouU4Fe4KVWyTuzGTN_C%2BOXPfiDGg6AKxHHuYMgcw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAA_zVTGp-HouU4Fe4KVWyTuzGTN_C%2BOXPfiDGg6AKxHHuYMgcw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPUD46tc5XjYP2VAVM0n3W%3Dx0ch1vKWCirbEmrMiaqV-4simAA%40mail.gmail.com.

Reply via email to