0

I can't use i .nizo.name if citizen.nizo.name == category.name <a> should work.

my one_category.html

    {% for i in citizen %}
    {% if  i.nizo == category.name %}
    <p>if</p>
        <a href="{% url 'citizen' i.slug %}"><h3> {{ i.name }} - haqida malumuot</h3> </a> <br>
    {% else %}
    <p>else</p>
    
    {% endif %}
    {% endfor %}

my models.py

class Citizen (models.Model) : 
   name = models.CharField(max_length=255, verbose_name= "F.I.SH",blank=True,null=True) #widget=models.TextInput(attrs={'class':'form-input'})
   tugilgan_sanasi = models.DateField(max_length=255, verbose_name= "Tug'ilgan sanasi",blank=True,null=True)
   slug = models.SlugField(max_length=255, unique=True,verbose_name= "Slug")
   yashash_manzili = models.CharField(max_length=240, verbose_name= "Yashah manzili",blank=True,null=True)
   content = models.TextField(verbose_name ="Текст статьи",blank=True)
   photo = models.ImageField(upload_to="photos/%Y/%m/%d/", verbose_name="Izoh",blank=True,null=True)
   is_published = models.BooleanField(verbose_name= "Organilgan/Organilmagan")
   time_create = models.DateTimeField(auto_now_add=True, verbose_name="Время создания",blank=True,null=True)
   time_update = models.DateTimeField(auto_now=True, verbose_name="Время изменения",blank=True,null=True)
   nizo_shaxs =models.CharField(max_length=240, verbose_name="Nizoloshyatgan Shaxs F.I.SH",blank=True,null=True)
   nizo = models.ForeignKey('Category',on_delete=models.PROTECT, null=True,blank=True, verbose_name ="Nizo не выбрана")
   mah = models.ForeignKey('Mahalla',on_delete=models.PROTECT,null=True,blank=True, verbose_name= "Mahalla не выбрана")
        
   def __str__(self):
      return self.name

   def get_absolute_url(self):
      return reverse('iib:citizen', kwargs={'citizen_slug': self.slug})

class Category(models.Model):
    name = models.CharField(max_length=100, db_index=True, verbose_name="Nizo")
    slug = models.SlugField(max_length=255, unique=True, db_index=True, verbose_name="URL")

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('iib:category', kwargs={'nizo_slug': self.pk})

    class Meta:
        verbose_name = 'Nizo'
        verbose_name_plural = 'Nizo'

my views.py

def show_one_category(request,nizo_slug:str):
    citizen = Citizen.objects.all()
    category = get_object_or_404(Category, slug=nizo_slug)
    context = {
        'category':category,
        'citizen':citizen,
        }
    return render(request, 'main/one_category.html', context)
Ruli
  • 2,592
  • 12
  • 30
  • 40

1 Answers1

0

Create a Universal Windows Project and check that you can run a project correctly

Update Windows to version 1903

load visual studio and run a Universal Windows Project. Check that it works, by running the project.

Create a new Unity project. Navigate to your project and select build to create a .sln file. Note: not Build and Release.

Make sure AppX includes a copy of the files from the subdirectory inside your project folder.

Copy 3 dll's and paste them into your AppX directory where the exe for you project is located. They are: vccorlib140_app.dll, VCRUNTIME140_APP.dll and MSVCP140_APP.dll.

Test your exe inside the APPX folder to check that there are no complaints about the dll's.

Go back into Unity select UWP and then select build and run.

  • Post.objects.values('cid') would only give you the pk of the Category. To access the category_name of the Category you should also include that in the values(): # Note the double underscore between cid and category_name `Post.objects.values('cid', 'cid__category_name')` Now that the category_name is available, access it in the template like this: {{ stat.cid__category_name }} While this is specific to your case, a better answer is here: https://stackoverflow.com/a/27181936/10951070 – MUTANT CHANNEL Dec 22 '22 at 21:54