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

  • SEARCH
  • Home
  • 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 6070845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:58:47+00:00 2026-05-23T09:58:47+00:00

I’m using Pinax to create a new project. For this project I needed to

  • 0

I’m using Pinax to create a new project. For this project I needed to create a new app ‘Business’ which is much like Profiles but they wanted to keep everything seperate for Businesses.

I’m trying to have the admin be able to change the logo or “avatar” for the business profile. Im using the ImageModel class from Photologue to control the image upload, etc but I ran into a problem. When going through the form, the form goes through and redirects but the image doesn’t actually get updated. When you go through the django admin, the image uploads fine.

If someone could take a look and see if something is missing, I’ve been staring at it for too long, so I need a fresh pair of eyes.

Business Models.py

class Business(models.Model):
name = models.CharField(verbose_name="Name", max_length=140)
desc = models.TextField(verbose_name="Description", null=True, blank=True)
bus_type = models.CharField(verbose_name="Business Type", choices=BUSINESS_TYPES, max_length=20)
location = models.CharField(_("location"), null=True, blank=True, max_length=200)
website = models.URLField(_("website"), null=True, blank=True, verify_exists=False)
created_by = models.ForeignKey(User, related_name="Created By")
admin = models.ManyToManyField(User, related_name="Admin User", null=True, blank=True)
followers = models.ManyToManyField(User, related_name="Followed by", null=True, blank=True)
date_added = models.DateField(verbose_name="Date Added")

class Meta:
    verbose_name = "Business"
    verbose_name_plural = "Businesses"

def __unicode__(self):
    return self.name

class BusinessLogo(ImageModel):
business = models.ForeignKey(Business, related_name="Business Association")

My views.py

@login_required
def changeLogo(request, bus_id):
user = request.user
b = get_object_or_404(Business, pk = bus_id)
if request.method == 'POST':
    form = ChangeLogoForm(request.POST, request.FILES, instance = b)
    if form.is_valid():
        biz_logo = form.save(commit=False)
        biz_logo.save()

        return HttpResponseRedirect('/')

else:
    form = ChangeLogoForm()

return render_to_response('business/changelogo.html',
                        {'user': user, 'form':form, 'b':b}, context_instance=RequestContext(request))

Forms.py

class ChangeLogoForm(ModelForm):
class Meta:
    model = BusinessLogo

def save(self, force_insert=False, force_update=False, commit=True):
    f = super(ChangeLogoForm, self).save(commit=False)
    if commit:
        f.save()
        print "form save method was called with commit TRUE"
    return f

And finally my changelogo.html

...
{% block body %}
<h1>Change Logo</h1>
<form method="POST" action="" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Upload">
</form>

{% endblock %}
...

Thanks everyone, for taking a look.

Steve

  • 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-23T09:58:47+00:00Added an answer on May 23, 2026 at 9:58 am

    The ChangeLogoForm‘s model is BusinessLogo, but when calling it’s constructor you pass it a Business instance:

    b = get_object_or_404(Business, pk = bus_id)
    ...
    form = ChangeLogoForm(request.POST, request.FILES, instance = b)
    

    (And you should probably use a OneToOneField field instead of ForeignKey)

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

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.