Saturday, September 1, 2018

Re: text editor


Hi to all,
            Which is the best editor for django framework  in Ubuntu os 18.04




On Sun, Sep 2, 2018 at 1:46 AM +0530, "RONAK JAIN" <jainronak877@gmail.com> wrote:

Namaste !!

Dear ,

I have two models categories and Project.

 created like that :

class Category(models.Model):
    categorys = models.ManyToManyField('Category',blank=True)
    name = models.CharField(max_length=100)
    created_at = models.DateTimeField(auto_now=False, auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)



    class Meta:
        verbose_name_plural = "Categories"

    def __str__(self):
        return self.name

    def __unicode__(self):
        return self.categorys

class Project(models.Model):
    categorys = models.ManyToManyField('Category',blank=True)
    name = models.CharField(max_length=100)
    description = models.CharField(max_length=100)
    created_at = models.DateTimeField(auto_now=False, auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    photo = models.ImageField(upload_to="pictures")


    def __str__(self):
        return self.name

    def __unicode__(self):
        return self.categorys

and Views I did here :

from web.models import Category,Project

class Portfolio(TemplateView):
    template_name = "web/protfolio.html"

    def post(self, request, *args, **kwargs):
        context = self.get_context_data()
        return super(TemplateView, self).render_to_response(context)
    
    def portfolio(request):
          context = RequestContext(request)
          # Project_list = Project.objects.order_by('-likes')[:3]
          # context_dict = {'Project': project_list}
          # return render(template_name, context_dict, context
          brand_list = Category.objects.all()
          return render(template_name, {'brand_list' : brand_list}, context)

I need correct relationship both I mean project and categories. How can I do correct here ? 
Note : I attached picture please analyse briefly.

How to do approch html page and   I want  the html(view) page should load from our db.
please give me quickly answer.
How can i do ?


Thanks
Ronak

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/63ecd6f1-411a-4581-b245-296efbd49303%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment