These are chat archives for django/django

12th
Apr 2017
cs89gr
@cs89gr
Apr 12 2017 13:35

can i create a function in models.py where every time user upload some file then that function automate update the name of model with the filename or filepath because i use multi upload file and user cant gine name in the field name.

my model

class book(models.Model):
    user = models.ForeignKey(User)
    name = models.CharField(max_length=255)
    upload = models.FileField(upload_to='images')
Mark Winterbottom
@LondonAppDev
Apr 12 2017 15:01
@cs89gr you could override save() on the model
Check the image name and assign that to name
cs89gr
@cs89gr
Apr 12 2017 15:05
@LondonAppDev how to do that ?
Mark Winterbottom
@LondonAppDev
Apr 12 2017 15:07
How do you override the save function?
cs89gr
@cs89gr
Apr 12 2017 15:11
@LondonAppDev i want automate for ex if file name is likes this 'aaaaaaaaaaa.file' then name take that name from file upload automate
Mark Winterbottom
@LondonAppDev
Apr 12 2017 15:14

ok... so do this:
1) Look up how to properly override the save() function a model using the Django docs and/or the SO link I sent above
2) Find out how to extract the name of the uploaded file on a FileField (https://docs.djangoproject.com/en/1.11/ref/models/fields/#filefield)
3) Set the name field to the name of the file in the FileField in save.

Also you may want to consider switching FileField for ImageField (https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.ImageField)

Dave Merwin
@davemerwin
Apr 12 2017 16:21
Hey folks. I'm looking for some recommendations for apps that can do the following: Allow me to login, create a team and invite members to that team. I love Django Allauth, looking for other app recomendations for the team and invites bit
John
@flyboy1565
Apr 12 2017 17:36
@LondonAppDev , love the teaching method :+1:
take
take'em to water, but make them drink
Mark Winterbottom
@LondonAppDev
Apr 12 2017 18:01
lol :D
Thanks @flyboy1565
Dave Merwin
@davemerwin
Apr 12 2017 18:25
Anyone know how to add a save button to the top of a list view in Django Admin for list_editable?
ikhahmedov
@ikhahmedov
Apr 12 2017 18:38
Hi guys, I have a question related to Single Page Application and SEO. I am trying to build my side project as Single Page Application with REST backend, but friend of mine told me it would be difficult to promote this kind of web apps in Google, because Google will not always evaluate JS or even if it does, they will not wait more than 100ms of your AJAX requests. SPA is very convenient for end-users, but seems not for crawlers. What is the options for the next steps?
Who did what in this situation and able to save performance/SEO/convenience for end-users?
William Hakizimana
@willyhakim
Apr 12 2017 22:56
Quick question for you all. So if I receive the following from an NFC reader what is the best practice to parse the information after the question mark into the database?
https://example.com/new_timer?UID=046F1572564080&runtime=1102&seconds=30&stillrunning=1&numstoredtimes=3&storedtimes=13:2-23:32-48:43&checksum=71