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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:31:28+00:00 2026-05-13T07:31:28+00:00

I have an app that lets people create tickets, and each Account owner using

  • 0

I have an app that lets people create tickets, and each Account owner using my app can create tickets.

Firstly, should it be unique per account do you think? Or, should it be completely unique?

Like this:

class Ticket(models.Model):
    """
    An ticket created by an Account holder.
    """
    account = models.OneToOneField('Account')
    number = models.CharField(max_length=20, verbose_name='Ticket Number')

    class Meta:
        unique_together = (('account', 'number'),)

or this, respectively:

class Ticket(models.Model):
    """
    An ticket created by an Account holder.
    """
    account = models.OneToOneField('Account')
    number = models.CharField(unique=True, max_length=20, verbose_name='Ticket Number')

Then, of course I want the order numbers to represent the account, so possibly a sample order number for an account that has the id: “chris” could be “chris-41984” or something like that. Would you create a model method for this, or…?

  • 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-13T07:31:28+00:00Added an answer on May 13, 2026 at 7:31 am

    If users can create more than one ticket, then a one-to-one field is not appropriate. Secondly, the ticket number is purely arbitrary, right? In other words, it only needs to be unique (I don’t see any reason why it should be unique per user from what you have said so far), so you might as well just use the primary key, unless you’re planning on integrating with some other data store.

    So you can simply say:

    class Ticket(models.Model):
        account = models.ForiegnKey(Account)
    
        # "ticket number" is just ticket.id.
        # if you don't like that, then say:
        #number = models.CharField(primary_key=True)
    

    Note that if you uncomment the number definition, you’ll need to specify it when you create the model instance – primary keys cannot be None. Alternately, override the save method to auto-generate the ticket number field based on your requirements.

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

Sidebar

Related Questions

I have a web app that lets users create groups. On the front page
Let's say I have an app that matches two People against each other, kind
I have an app that lets the user search over a number of fields
I have a web app that lets a client define a daily rate for
I have a Rails 3 app that lets users enter comments. I want any
Let's say I have a fairly simple app that lets users store information on
Lets say you have a web app related Android app that requires the user
I have got a demo script that lets me authorize with my app and
Have an app that has listings - think classified ads - and each listing
I am creating a feature in my app that lets people take photo in

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.