These are chat archives for django/django

Oct 2018
Henrik Wirth
Oct 23 2018 01:38
Anyone an idea how to make multipart file/image uploads with retrofit 2.x? Is it possible to make one Api-Call passing multiple images, a User and Geolocation? Can't find any proper tutorials that work for me.
Tanveer Ahmed
Oct 23 2018 12:12
Here is my Code Please Help :( Getting Error |name 'artwork' is not defined|
import random
class art_detail(DetailView):
    model = Artwork
    template_name = 'gallery/art_detail.html'
    pk_url_kwarg = "art_id"
    def get_context_data(self, *args, **kwargs):
        def art_detail(request, art_id):
            artwork = Artwork.objects.filter(gcategory=gcategory)
            next_artwork = artwork.get_next_by_published_date()
            while next_artwork.gcategory != artwork.gcategory:
                next_artwork = next_artwork.get_next_by_published_date()
        except (ObjectDoesNotExist, MultipleObjectsReturned):
            next_artwork = None
            previous = artwork.get_previous_by_published_date()
            while previous.gcategory != artwork.gcategory:
                previous = previous.get_previous_by_published_date()
        except (ObjectDoesNotExist, MultipleObjectsReturned):
            previous = None
        return render(request, 'gallery/art_detail.html', 
            {'artwork': artwork, 'next': next_artwork, 'previous': previous})
        context = super(art_detail, self).get_context_data(*args, **kwargs)
        instance = self.get_object()
        context["related"] = sorted(Artwork.objects.all()[:6], key= lambda x: random.random())
        return context
Screenshot from 2018-10-23 16-57-31.png
Frank Godo
Oct 23 2018 13:28
@tanveerobjects_twitter Is your tabbing correct on this paste? It looks like most of the art_detail method contents is missing an intent
Tanveer Ahmed
Oct 23 2018 14:46
@frankintrahouse I am not sure I want this task for next object and previews object next and previous buttons
Scott Dillon
Oct 23 2018 19:12
@tanveerobjects_twitter you are creating the artwork object in the art_detail function but you're not returning it. Then when you reference it in the try block which is scoped to the get_context_data, you get your error.
You need to indent everything under the art_detail function down to the return line.
Karan Kharecha
Oct 23 2018 19:23
Hey guys.! I just joined this channel right now..
Oct 23 2018 19:23
@scottdillon is there any reason to confuse things by defining art_detail inside get_context_data?
@tanveerobjects_twitter definitely sort your indents out, please!
Karan Kharecha
Oct 23 2018 19:24
I have been working with python since last 6-7 months, and more inclined to data science.. but have never explored Django, can anyone suggest me stuffs about Django, from where do I get started?
Scott Dillon
Oct 23 2018 19:49
@ajostergaard I wouldn't think so but the line where context is set is kind of a mess and I don't know what's intended there.
@karankharecha The django docs are really good. This guy does a good job with a multipart blog post on django too.
Oct 23 2018 19:53
Oct 23 2018 23:43
Hi, I want to get involved more in contribution to django. If anyone has a priority for a bug that isnt being addressed yet, PM me a link and I'll try to take a look tonight. Going afk for now