These are chat archives for django/django

10th
Feb 2016
rishu-18
@rishu-18
Feb 10 2016 09:58
hi ..
i want to upload image file in django ... from web page .. but i am not getting it

my code is like this
Models.py
def content_file_name(instance, filename):
fname = filename.split('.')
fname[0] = instance.user.username + '.' + fname[1]
return '/'.join(['image',fname[0]])

class Preference(models.Model):
user = models.ForeignKey(User)

`timezone_positive = models.BooleanField()`
`timezone_hours = models.SmallIntegerField()`
`timezone_minutes = models.SmallIntegerField()`
`image = models.ImageField(upload_to=content_file_name)`

`def __str__(self):`
    `return self.user.username`
and views.py is ...
@api_view(['POST'])
@authentication_classes((SessionAuthentication, BasicAuthentication))
@permission_classes((IsAuthenticated,))
def image_submit(request):
print type(request.data['file']),request.FILES
preference = Preference.objects.get(pk=2)
preference.image = request.FILES['file']
print preference.image
print "success"
return Response({'data':'a'})
rishu-18
@rishu-18
Feb 10 2016 10:16
problem solved :)
Jon Earley
@jonearley
Feb 10 2016 19:21
Hey, all! Anyone hiring a Django developer?
Omar Quimbaya
@WritingPanda
Feb 10 2016 20:44
we are!
cs89gr
@cs89gr
Feb 10 2016 21:40

hello i have some python scripts with mathematical functions and i want to upload on my website to help the user to take results for some mathematical problem,but i dont know how to written on my views.py and template tag for example one my script:

total_inputs= int(input("number of numbers to input: "))
   for i in range (total_inputs)
    Num = input("Enter a number: ")
    NList.append(int(Num))
    ..................................
    progress
    .................................
    result1=result
    result2=listresult
    print(result1)
    print(result2)

user define the number to want for input and next input integer numbers on the list(NList) that list go to progress and exported one variable result outpout and list of variables results. i dont upload the progress code because i think not is nesecery for my questions.

Răzvan Ionescu
@ionescu77
Feb 10 2016 21:41
@WritingPanda remote also