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 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

I want to setup a table that can: Save the data on the user's
I want to save and load my xml data using XmlReader. But I don't
I have some arbitrary pixel data that I want to save as a PNG.
I want an adaptable database scheme. But still use a simple table data gateway
I want to save some custom data into application configuration file and I need
I want to use a variable-sized multi-dimensional array in my app to save data.
I want to save Image in Database with JSON web service .without image data
I want to provide the ability to save some rendered data/charts (with the titles
I want to write data to an output file and save it on a
I want to make a MySQL to get daily differential values from a table

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.