Re:

2020-05-06 Thread Nomeh Uchenna Gabriel
That's quite easy -
___
models.py:
class num(models.Model):
item = models.BigIntegerField(...)
___
views.py:
from . import models
def funct(request):
mdl = models.num.objects.get(id__exact=1)
mdl2 = models.num.objects.get(id__exact=1)

adds = int(mdl.item) + int(mdl2.item)
dict = {"adds_temp" : adds}
return render(request, "home.html", context=dict)

___
templates/home.html


  Addition: {{adds_temp}}



On Tuesday, May 5, 2020, fahad rasool  wrote:

> Can someone tell that how to perform an operation ,for example we retreive
> two numbers from database and want to add them and display on template in
> django
>
> --
> 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 django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CACqgSmCzazz4W5AuwKOzgvyjSDAMb
> XwgD-B%3DkM%2BtG3T0t2Mb%3DQ%40mail.gmail.com
> 
> .
>

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALcUgYyh9G157%2BZb8XaM2nNc9fdUfHwejGTLJAB4XwpjQStNZQ%40mail.gmail.com.


Re: Best hosting for Django Application?

2020-05-06 Thread Nomeh Uchenna Gabriel
please don't ever use "python-anywhere" for a serious project unless you have 
enough tears  in your eye balls to cry out when the time comes.

... I suggest "digitalocean/linode" so that the heavy problems of "SSL 
certificates" won't beat you up

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ee7b3e5b-20f8-4f70-aca2-3fc689a30a37%40googlegroups.com.


Re: A learner following a Mosh Tutorial on Django and having a problem saving a product to SQLite

2020-05-06 Thread Nomeh Uchenna Gabriel
That's great to hear! 

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56235ef4-df14-4857-9c73-53a48f27acfe%40googlegroups.com.


Re: A learner following a Mosh Tutorial on Django and having a problem saving a product to SQLite

2020-05-06 Thread Nomeh Uchenna Gabriel
delete the migrations again, then run this to reset the tracking:

>>> py manage.py migrate --fake [app_Name] zero

then redo the process I stated before. 
... makemigrations [app_Name]
... migrate [app_Name]

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/06d0ec9b-9860-4a90-ba93-031217256161%40googlegroups.com.


Page 404 error after running Django server

2020-05-04 Thread Nomeh Uchenna Gabriel
Hi! you're just visiting a different url from what you specified in your 
"urls.py" file.

look closely at the routes "django" is telling you that it tried:

[admin/, welcome.html/]

... these are truly the two paths that you specified, why on earth are you 
trying to visit a non-existing path(http://127.0.0.1:8000/)

... kindly visit (http://127.0.0.1:8000/welcome.html)

and face your next error in the "views.py" file ('HttpRequest' instead of 
'HttpResponse') 

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f9c805f3-c264-46c6-ab20-153b3c7b9291%40googlegroups.com.


Re: A learner following a Mosh Tutorial on Django and having a problem saving a product to SQLite

2020-05-04 Thread Nomeh Uchenna Gabriel
Hi! the reason is probably because you happened to have deleted "some but not 
all of your migrations" 

... django will always look for the latest "sqlmigrate" with the versions in 
the right order(0001,0002,000x...) before it allows "makemigrations" add a new 
one.

To fix, this you must:

delete all your migration files located at "app_Name/migrations" then run 

>>> py manage.py makemigrations [app_Name]


>>> py manage.py migrate [app_Name]

...you can skip app_Name if it's the only app in your project but I advise you 
add it anyway. 

after that you can run:
>>> py manage.py sqlmigrate [app_Name]0001

if that shows your latest migrations, then it's done bro! your project should 
work now.

also check out your migrations and see how django added the new one. 

where app_Name === your app name (the one that you added to 'installed_apps' of 
settings.py

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d1564bb-67c9-4215-8a2b-92afa3e0bcab%40googlegroups.com.


How to get previously uploaded Images in Django

2020-05-04 Thread Nomeh Uchenna Gabriel
You should read about customising the admin here: 
https://docs.djangoproject.com/en/3.0/intro/tutorial07/

... but I suggest that you build your own website control panel which will 
control your website with API's 

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/37568d09-e5a6-4ab4-be12-ed2881d6d119%40googlegroups.com.


Re: not a valid UUID.

2020-05-04 Thread Nomeh Uchenna Gabriel
[CONTINUED] 
I just saw "unique=true" on that field

... you may not face the problems of using "random" just yet but must face it 
at some "random time in the future" - once you see something like this:

   >>>: IntegrityError

... then shall you remember my reply.

The best option is to use a well guided function - I could even help you with 
that if you don't know much about it on my leisure. 

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a55e8d2f-1511-4678-9c9a-1b40a93a8025%40googlegroups.com.


Re: not a valid UUID.

2020-05-04 Thread Nomeh Uchenna Gabriel
That looks good to you but is definitely a dangerous approach if the "12 
digits" should be unique for each QuerySet since "random.random" can return 
dublicate numbers when called multiple times.

... I suggest you make a function for that or novicely adds the item's 'pk' to 
the random number making sure that it's still not more than 12 digits

-- 
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 django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/71c45bae-8cb2-433d-ae27-2d4275c7182c%40googlegroups.com.


Re: not a valid UUID.

2020-05-03 Thread Nomeh Uchenna Gabriel
On Sunday, May 3, 2020 at 9:10:28 AM UTC+1, Benedict Uwazie wrote:
> Still facing the same issue
> 
> On Sunday, 3 May 2020 03:27:46 UTC+1, Motaz Hejaze  wrote:
> default=cast_trans
> cast_trans = int(pass_trans)
> 
> UUID is string not int
> 
> 
> On Sun, May 3, 2020 at 4:05 AM Benedict Uwazie  wrote:
> 
> 
> 
> On Sunday, 3 May 2020 01:38:16 UTC+1, Benedict Uwazie  wrote:
> 
> I added a field called transaction_id in my models.py I want that field to be 
> used to track every transaction on my "DuesLevy" model I imported uuid to 
> this to happen, but each time I migrate I get this error.
> How do i prevent this error from occurring each time I migrate (python 
> manage.py migrate) File 
> "C:\Users\Benedict\Miniconda3\envs\django3\lib\site-packages\django\db\models\fields\__init__.py",
>  line 2344, in to_python
> params={'value': value},
> django.core.exceptions.ValidationError: ["'13615773708697' is not a valid 
> UUID."]
> 
> 
> my models.py
> 
> 
> trans_id = uuid.uuid4()
> trans_str = trans_id.int
> pass_trans = str(trans_str)[:12]
> cast_trans = int(pass_trans)
> class DuesLevy(models.Model):
> class_of_dues = models.CharField(max_length=30, default=options.CHOOSE, 
> choices=options.CLASS_OF_DUES, blank=True)
> payment_circle = models.CharField(max_length=30, default=options.CHOOSE, 
> choices=options.PAYMENT_CIRCLE)
> payment_option = models.CharField(max_length=30, default=options.CHOOSE, 
> choices=options.PAYMENT_OPTION)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> transaction_id = models.UUIDField(max_length=100, unique=True, null=True, 
> blank=True, editable=False, default=cast_trans)
> payment_channel = models.CharField(max_length=30, default=options.CHOOSE, 
> choices=options.PAYMENT_CHANNEL_TYPE)
> payment_date = models.DateField()
> date_recorded = models.DateTimeField(auto_now_add=True)
> user = models.ForeignKey(settings.AUTH_USER_MODEL, 
> on_delete=models.CASCADE)
> description = models.TextField(blank=True, null=True)
> 
> def __str__(self):
> return self.amount
> 
>   
> def get_absolute_url(self):
> return reverse('backend:detail_dues', kwargs={'pk': self.id})
> 
> 
> 
> 
> 
> 
> -- 
> 
> 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 django...@googlegroups.com.
> 
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/4a1d77cc-d1b8-4bd4-84cd-cd78e6d2eb76%40googlegroups.com.



On Sunday, May 3, 2020 at 9:10:28 AM UTC+1, Benedict Uwazie wrote:
> Still facing the same issue
> 
> On Sunday, 3 May 2020 03:27:46 UTC+1, Motaz Hejaze  wrote:
> default=cast_trans
> cast_trans = int(pass_trans)
> 
> UUID is string not int
> 
> 
> On Sun, May 3, 2020 at 4:05 AM Benedict Uwazie  wrote:
> 
> 
> 
> On Sunday, 3 May 2020 01:38:16 UTC+1, Benedict Uwazie  wrote:
> 
> I added a field called transaction_id in my models.py I want that field to be 
> used to track every transaction on my "DuesLevy" model I imported uuid to 
> this to happen, but each time I migrate I get this error.
> How do i prevent this error from occurring each time I migrate (python 
> manage.py migrate) File 
> "C:\Users\Benedict\Miniconda3\envs\django3\lib\site-packages\django\db\models\fields\__init__.py",
>  line 2344, in to_python
> params={'value': value},
> django.core.exceptions.ValidationError: ["'13615773708697' is not a valid 
> UUID."]
> 
> 
> my models.py
> 
> 
> trans_id = uuid.uuid4()
> trans_str = trans_id.int
> pass_trans = str(trans_str)[:12]
> cast_trans = int(pass_trans)
> class DuesLevy(models.Model):
> class_of_dues = models.CharField(max_length=30, default=options.CHOOSE, 
> choices=options.CLASS_OF_DUES, blank=True)
> payment_circle = models.CharField(max_length=30, default=options.CHOOSE, 
> choices=options.PAYMENT_CIRCLE)
> payment_option = models.CharField(max_length=30, default=options.CHOOSE, 
> choices=options.PAYMENT_OPTION)
> amount = models.DecimalField(max_digits=8, decimal_places=2)
> transaction_id = models.UUIDField(max_length=100, unique=True, null=True, 
> blank=True, editable=False, default=cast_trans)
> payment_channel = models.CharField(max_length=30, default=options.CHOOSE, 
> choices=options.PAYMENT_CHANNEL_TYPE)
> payment_date = models.DateField()
> date_recorded = models.DateTimeField(auto_now_add=True)
> user = models.ForeignKey(settings.AUTH_USER_MODEL, 
> on_delete=models.CASCADE)
> description = models.TextField(blank=True, null=True)
> 
> def __str__(self):
> return self.amount
> 
>   
> def get_absolute_url(self):
> return reverse('backend:detail_dues', kwargs={'pk': self.id})
> 
> 
> 
> 
> 
> 
> -- 
> 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 
> To unsubscribe from this group and