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 3312144
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:57:36+00:00 2026-05-17T21:57:36+00:00

I have been working on my CSV upload for a little while now, and

  • 0

I have been working on my CSV upload for a little while now, and I finally got it working (sort of haha) As it stands right now, my code will only pull the first record from the CSV file, and I have been looking at it too long, and Im sure I am missing something. Here is my views.py

@login_required
def importClient(request):
print "its being called"
if request.FILES:
    form = ImportClientForm(request.POST, request.FILES)
    if form.is_valid():
        print "its valid!!"
        if '.csv' in request.FILES['contact_file'].name:
            print "It's a CSV file!!!"
            importfile = csv.DictReader(request.FILES['contact_file'])
            for row in importfile:
                #establish client name
                cn = row.get('Customer', None)

                c = Clients(
                    client_name = cn,
                    phone = "",
                    phone_cell = "",
                    fax = "",
                    email = "",
                    add_1 = "",
                    add_2 = "",
                    city = "",
                    province = "",
                    country = "",
                    postal = "",                        
                )

                #check to see if client exists already
                already_there = Clients.objects.filter(client_name = cn)[:1]
                if not already_there:
                        c.save()

                return HttpResponseRedirect('/clients/')

else:
    form = ImportClientForm()

    return render_to_response('clients/importClients.html', {
            'form': form}, context_instance=RequestContext(request))

Is there something that I am missing, I am sure its really simple.

Thanks,
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-17T21:57:37+00:00Added an answer on May 17, 2026 at 9:57 pm

    Unindent the following line:

     return HttpResponseRedirect('/clients/')
    

    You put it inside the for row in importfile: loop, making your code return a HTTP response after the first iteration.

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

Sidebar

Related Questions

I have been working on a Windows Mobile app for a little while now
I have been working on an application in Xcode for a while now and
i have been working on this code ! and i couldn't done it right
I have been working on this problem for 2 days now and it's an
I've been working on this simple code that puts a CSV file into a
Have been working on a Tower Defense game for iOS for some time now.
I have been working with a script to change my CSV file to Tab
I have been working in Python for a few months now, and it has
I have been working on some legacy C++ code that uses variable length structures
Have been working on this question for a couple hours and have come close

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.