Category : django

I have a django model that looks like this: class Character(models.Model): character_Name = models.CharField(max_length=50) user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) level = models.PositiveSmallIntegerField(validators=[MaxValueValidator(20), MinValueValidator(1)], default=1) def __str__(self): return self.character_Name with an html file(main.html) that looks like this: <!DOCTYPE html> <html lang="en"> <body> <h1>{{ characters.character_Name }}</h1> <h4>Level: {{ characters.level }}</h4> <button onclick="increase_level()"> + 1 </button> </body> a function ..

Read more

Some time ago I started to learn python and I created commandline application that manages your home bar and cocktails recipes (you can add alcohol bottles to it, add recipes, check if you have ingredients to create given cocktail and so on) that uses sqlite3 database. Class called BarmanShell is kind of api of this ..

Read more

I have model class TransHeader(models.Model): th_type = models.CharField(max_length=200) th_code = models.CharField(max_length=200) th_status=models.CharField(max_length=1,default=0) my view: class SalTransactions(TemplateView): template_name = "wstore/sales_transactions.html" def get_context_data(self, **kwargs): context = {} if kwargs[‘post’]==’UNPOSTED’: context[‘transactions’] = TransHeader.objects.filter(th_type=kwargs[‘transtype’]) .filter(th_status=’0′) else: context[‘transactions’] = TransHeader.objects.filter(th_type=kwargs[‘transtype’]) return context my url line: path(‘saltransactions/<str:transtype>/<str:post>’,views.SalTransactions.as_view(), name=’saltransactions’), my link through menu is working fine showing all records with given trans ..

Read more