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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:43:32+00:00 2026-05-12T06:43:32+00:00

i want to save data in two table mysql, that was nice, but now

  • 0

i want to save data in two table mysql, that was nice, but now i change a field form Interget to FK.. the problem is that now i cant send the data to the field FK….

im new with Django, but im working in this way:

@login_required
def agregar_diligencia(request):    
    if request.method =='POST':
        form = DiligenciaForm(request.POST)
        #trac = Tracking()
        tracknum = 'ABCD458LK'
        if form.is_valid():
            from django.contrib.auth.models import User            
            User = User.objects.get(pk=request.user.id)            
            obj = form.save(commit=False)                        
            obj.socio = User            
            obj.status = 0            
            obj.secuencia = 1
            obj.save()
            t = Tracking()            
            t.track = tracknum
            t.diligencia = obj.id
            t.save()

            return HttpResponseRedirect('/accounts/diligencias/activas')


    else:  
        form = DiligenciaForm()

    return render_to_response('account/agregar_diligencia_form.html', 
                 { 'formulario':form },context_instance = RequestContext(request))

Where t.diligencia = obj.id (t.diligencia) is my FK and obj.id is the data that i want to save in the FK

Sorry with my English and thanks.

  • 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-12T06:43:33+00:00Added an answer on May 12, 2026 at 6:43 am

    You haven’t at all stated what the problem is.

    However one thing that I can see is that you’re overwriting User in this line:

        User = User.objects.get(pk=request.user.id)
    

    You should be assigning to user with a lower-case u – but I doubt that’s the source of your problem, whatever it is.

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

Sidebar

Related Questions

So I have an unbound form that I use to save data to a
i've got some binary data which i want to save as an image. When
I want to save and store simple mail objects via serializing, but I get
So I have an input form that I want to use to update a
I wish to save some semantic information about data in a table. How can
What's the best way to save my MySQL data model and automatically apply changes
I'm selecting data from two different tables which have a common field date and
I want to save the objects I generated in a program. After restart the
I want to open a save file dialog, have the user enter a filename,
I'm having what seems to be a concurrency problem while using MySQL and PHP

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.