Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

stackoverflow Django ForeignKey

class Versao(models.Model):
    projeto=models.ForeignKey(Projeto, on_delete=models.CASCADE)
    local=models.FileField()
    num_versao=models.IntegerField(blank=True)

    def __str__(self):
        return str(self.projeto) + '_V' + str(self.num_versao)

    def save(self, force_update=False, force_insert=False):
        qtd_versoes=Versao.objects.filter(projeto=self.projeto).count()
        self.num_versao=qtd_versoes+1
        super(Versao, self).save(force_insert, force_update)
Comment

PREVIOUS NEXT
Code Example
Python :: python decorator generator to list 
Python :: increase tkinter window resolution 
Python :: how to reassign a key py 
Python :: django check if related object is None 
Python :: python two list into dictinaray list comprehension 
Python :: python Access both key and value using items() 
Python :: Python Program to Display Powers of 2 Using Anonymous Function 
Python :: how to downlaod file using python 
Python :: list box tkinter 
Python :: non venomous snakes 
Python :: nums: List[int] in python function 
Python :: python print statements 
Python :: tf.get_variable initializer 
Python :: forward fill pandas ffill 
Python :: File "demo_indentation_test.py", line 2 print("Five is greater than two!") ^ IndentationError: expected an indented block 
Python :: rotate an image python keras 
Python :: presto sequence example date 
Python :: multivariable traces f(x, y) = sin(x)cos(y) 
Python :: plt.plot(x, softmax(scores).T, linewidth=2) 
Python :: try finally return precedent 
Python :: max value from multiple columns pandas 
Python :: flask logging miguel grinberg 
Python :: pd drop a range of dates 
Python :: How to provide type hinting in UserDict? 
Python :: python as integer ratio 
Python :: assemblyai 
Python :: np logical and 
Python :: python project structure 
Python :: traint test split on column id 
Python :: appropriate graph for dataset visualization 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =