Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to make a code-name(*i.e: Test Post will be TP-1, TP-2 ...*) thing on Django. There is **news** model, and **post** model i got. When user create news title hence post's codename will be according it's news's title. For example the

`news.title='Test News'`

then assume that I created a first post and assign it in variable **a**

`print a.codename` must return `TN-1`

Currently i can take News title by it's abbreviation in 2 or 3 letter and problem is how to add number after letters. And Posts are **related** to News by `ForeignKey` therefore number should increase according news like shown below.

* Test news
1. TN-1
2. TN-2
* Foo news
1. FN-1
2. FN-3
3. FN-4
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900