my models.py :
def get_upload_file_name(instance, filename):
return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), filename)
class Status(models.Model):
status = models.TextField()
image = models.ImageField(upload_to=get_upload_file_name, blank=True)
pub_date = models.DateTimeField(default=datetime.now)
creator = models.ForeignKey(User, related_name="creator_set")
likes = models.ManyToManyField(User, through="Like")
class Meta:
ordering = ['-pub_date']
verbose_name_plural = ('Status')
def __unicode__(self):
return self.status
On Thu, Sep 5, 2013 at 10:39 PM, Robin Lery <[email protected]> wrote:
> This is my template. Can you please check where I am wrong... Thank you
> though!
>
> {% block content %}
> <div class="status">
> <div class="inner">
> {% for Status in status %}
> <p class="user">{{ Status.creator.get_full_name
> }}</p>
> {% if Status.image %}
> <div class="image_image">
> <center>
> <img src="{{Status.image
> |thumbnail_url:'status'}}"/>
> </center>
> </div>
> <p class="status_image">{{Status}}</p>
> <span class="clear"></span>
> <hr>
> {% else %}
> <p class="status_status">{{Status}}</p>
> <span class="clear_right"></span>
> <hr>
> {% endif %}
> {% endfor %}
> </div>
> </div>
> {% endblock %}
>
>
>
> On Thu, Sep 5, 2013 at 9:51 PM, Kelvin Wong <[email protected]> wrote:
>
>> Check your templates. I bet your tag there is giving the wrong root
>> relative path to the user uploads.
>>
>>
>> https://docs.djangoproject.com/en/dev/ref/templates/builtins/#get-media-prefix
>>
>> If Apache is giving you problems, what does it say in your Apache logs?
>> Try debugging this like you would an Apache configuration error.
>>
>> K
>>
>>
>> On Thursday, September 5, 2013 8:35:49 AM UTC-7, Robin Lery wrote:
>>
>>> I did as you told, but I can only see it, when I reload the page served
>>> by the django's inbuilt server. Kindly check this -
>>> https://mail.google.com/**mail/u/0/#sent/**140ee7fdc09d4f22<https://mail.google.com/mail/u/0/#sent/140ee7fdc09d4f22>
>>>
>>>
>>> On Thu, Sep 5, 2013 at 2:29 AM, Kelvin Wong <[email protected]> wrote:
>>>
>>>> The MEDIA_ROOT is the local system location where the FileField in your
>>>> models is going to store incoming files. Users submit files and they are
>>>> placed in the location specified by the 'upload_to' setting of the field
>>>> (usually a directory within MEDIA_ROOT).
>>>>
>>>> https://docs.djangoproject.**com/en/dev/ref/models/fields/#**
>>>> django.db.models.FileField.**upload_to<https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to>
>>>>
>>>> You should remove your MEDIA_ROOT from STATICFILES_DIRS.
>>>>
>>>> Then you should review this documentation.
>>>>
>>>> https://docs.djangoproject.**com/en/dev/topics/http/file-**uploads/<https://docs.djangoproject.com/en/dev/topics/http/file-uploads/>
>>>>
>>>> The 'collectstatic' command collects your static assets, not user
>>>> submitted content. Your system is misconfigured and that is why it is
>>>> collecting user submitted files.
>>>>
>>>> K
>>>>
>>>
>>> --
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.