Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 686905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:04:20+00:00 2026-05-14T02:04:20+00:00

I am having problems with django forms and image uploads. I have googled, read

  • 0

I am having problems with django forms and image uploads. I have googled, read the documentations and even questions ere, but cant figure out the issue. Here are my files

my models

class UserProfile(User):
    """user with app settings. """
    DESIGNATION_CHOICES=(
    ('ADM', 'Administrator'),
    ('OFF', 'Club Official'),
    ('MEM', 'Ordinary Member'),
    )
    onames = models.CharField(max_length=30, blank=True)
    phoneNumber = models.CharField(max_length=15)
    regNo = models.CharField(max_length=15)
    designation = models.CharField(max_length=3,choices=DESIGNATION_CHOICES)
    image = models.ImageField(max_length=100,upload_to='photos/%Y/%m/%d', blank=True, null=True)
    course = models.CharField(max_length=30, blank=True, null=True)
    timezone = models.CharField(max_length=50, default='Africa/Nairobi')
    smsCom = models.BooleanField()
    mailCom = models.BooleanField()
    fbCom = models.BooleanField()

    objects = UserManager()

    #def __unicode__(self):
    #   return '%s %s ' % (User.Username, User.is_staff)


    def get_absolute_url(self):
        return u'%s%s/%s' % (settings.MEDIA_URL, settings.ATTACHMENT_FOLDER, self.id)

    def get_download_url(self):
        return u'%s%s/%s' % (settings.MEDIA_URL, settings.ATTACHMENT_FOLDER, self.name)

…

class reports(models.Model):
    repID = models.AutoField(primary_key=True)
    repSubject = models.CharField(max_length=100)
    repRecepients = models.ManyToManyField(UserProfile)
    repPoster = models.ForeignKey(UserProfile,related_name='repposter')
    repDescription = models.TextField()  
    repPubAccess = models.BooleanField()
    repDate = models.DateField()
    report = models.FileField(max_length=200,upload_to='files/%Y/%m/%d' )
    deleted = models.BooleanField()

    def __unicode__(self):
        return u'%s ' % (self.repSubject)

my forms

from django import forms
from django.http import HttpResponse
from cms.models import *
from django.contrib.sessions.models import Session
from django.forms.extras.widgets import SelectDateWidget

class UserProfileForm(forms.ModelForm):
        class Meta:
        model= UserProfile
        exclude = ('designation','password','is_staff', 'is_active','is_superuser','last_login','date_joined','user_permissions','groups')

…

class reportsForm(forms.ModelForm):
    repPoster = forms.ModelChoiceField(queryset=UserProfile.objects.all(), widget=forms.HiddenInput())
    repDescription = forms.CharField(widget=forms.Textarea(attrs={'cols':'50', 'rows':'5'}),label='Enter Report Description here')
    repDate = forms.DateField(widget=SelectDateWidget())
    class Meta:
        model = reports
        exclude = ('deleted')

my views

@login_required
def reports_media(request):
    user = UserProfile.objects.get(pk=request.session['_auth_user_id'])
    if request.user.is_staff== True:
        repmedform = reportsForm(request.POST, request.FILES)
        if repmedform.is_valid():
            repmedform.save()
            repmedform = reportsForm(initial = {'repPoster':user.id,})

       else:
            repmedform = reportsForm(initial = {'repPoster':user.id,})
       return render_to_response('staffrepmedia.html', {'repfrm':repmedform, 'rep_media': reports.objects.all()})

    else:

        return render_to_response('reports_&_media.html', {'rep_media': reports.objects.all()})

…

@login_required
def settingchng(request):

user = UserProfile.objects.get(pk=request.session['_auth_user_id'])
    form = UserProfileForm(instance = user)
    if request.method == 'POST':
        form = UserProfileForm(request.POST, request.FILES, instance = user)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/settings/')

    else:
        form = UserProfileForm(instance = user)

    if request.user.is_staff== True:    
        return render_to_response('staffsettingschange.html', {'form': form})   
    else:
        return render_to_response('settingschange.html', {'form': form})    

…

@login_required 
def useradd(request):

    if request.method == 'POST':

        form = UserAddForm(request.POST,request.FILES )

        if form.is_valid():
            password = request.POST['password']
            request.POST['password'] = set_password(password)
            form.save()

    else:
        form = UserAddForm()

    return render_to_response('staffadduser.html', {'form':form})

Example of my templates

{% if form.errors %}
 <ol>
    {% for field in form %}
      <H3 class="title">
      <p class="error"> {% if field.errors %}<li>{{ field.errors|striptags }}</li>{% endif %}</p>
      </H3>
    {% endfor %}
</ol>
  {% endif %} 
 <form method="post" id="form" action="" enctype="multipart/form-data" class="infotabs accfrm">
    {{ repfrm.as_p }}
   <input type="submit" value="Submit" />
</form> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:04:20+00:00Added an answer on May 14, 2026 at 2:04 am

    the issue was actually that this line

    <form method="post" id="form" action="" enctype="multipart/form-data" class="infotabs accfrm">
    

    appeared as

    <form method="post" id="form" action="" enctype="multipart/form
    -data" class="infotabs accfrm">
    

    hence the forms were not uploading. And to think I have had this issue for 2 weeks. If its ok with you guys, i will delete this question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.