Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Dominoes
Sep 20, 2007

I've been troubleshooting getting forms to display cleanly in Django. The way I learned to display forms in the template from the Polls tutorial looks like this:

code:
        <form id="target_form" method="post" action="/target/">
            {% csrf_token %}

            {% for hidden in form.hidden_fields %}
                {{ hidden }}
            {% endfor %}

            {% for field in form.visible_fields %}
                {{ field.errors }}
                {{ field.help_text}}
                {{ field }}<br/>
            {% endfor %}

        <input class="btn btn-primary" type="submit" name="submit" value="Submit"/>
You'd use 'help_text' in the form class for display text.

Unable to get it formatted cleanly, I found online that using '{{ form.as_p }}' will show anything with 'label' in the form class as a label tag, which you can then manipulate with CSS. The method I used with help_text showed un-tagged text above the <input> tags in source view. The official docs on forms mention both methods. Thoughts? Also looking for advice on getting the labels/help_text to align left, and the fields to align right.


I've tried this:
code:
        <form id="target_form" method="post" action="/target/">
            {% csrf_token %}

        <div id="form-left">
            {% for field in form.visible_fields %}
                {{  field.label }}<br/>
            {% endfor %}
        </div>


        <div id="form-right">
            {% for field in form.visible_fields %}
                {{ field.errors }}
                {{ field }}<br/>
            {% endfor %}
        </div>


        <input class="btn btn-primary" type="submit" name="submit" value="Submit"/>
        </form>
This provides some CSS flexibility, but I still can't get a solution where the forms are aligned, the labels are aligned, and the labels are on the same line as the field.

Dominoes fucked around with this message at 10:20 on May 26, 2014

Adbot
ADBOT LOVES YOU

Dominoes
Sep 20, 2007

Lumpy posted:

Python code:
{% for field in form.visible_fields %}
<div class="fieldWrapper">
                {{  field.label }}
                {{ field.errors }}
                {{ field }}
</div>
 {% endfor %}
Now use CSS to lay out .fieldWrapper input, .fieldWrapper label, etc. If you post an image of what you want (even just crudely drawn boxes) and a JSFiddle of what the HTML that comes out looks like, I'll be happy to CSS it up for you.
Thanks a lot. Here's the default Django implementation, which is still better than anything I've been able to do myself messing with the position, float, display css tags:


Here's an MS-paint mockup of what I'd like:

Dominoes
Sep 20, 2007

Dude! That worked!

CSS code:
label {
    width: 180px;
    float: left;
}
Django code:
{% for field in form.visible_fields %}
                {{ field.errors }}
                <label>
                    {{ field.label }}
                </label>
{#                {{ field.help_text}}#}
                {{ field }}<br/>
            {% endfor %}
Should I be using Django's label, or help_text? They both appear to do the same thing.

Dominoes fucked around with this message at 20:09 on May 26, 2014

Dominoes
Sep 20, 2007

Thanks. Any words on how to make a login page redirect to page that triggered it? This Stack Overflow post addresses it, but the solution only works if logging in from a link; I'm using the @login_required method, with no link to reference.

I've tried this:
Python code:
 if user.is_active:
                # If the account is valid and active, we can log the user in.
                # We'll send the user back to the homepage.
                login(request, user)
                origin_url = request.GET.get('next')
                return HttpResponseRedirect(origin_url)
request.GET.get('next') works initially when the page requiring login loads, but is then empty when I need it. Perhaps I could pass it through two requests?

I feel like this is a very common problem - most major websites I use that have logins don't address this - and it's really annoying! Ie you navigate a few pages deep in a website, are met with a login wall, then are spit out at the top after logging in.

Dominoes fucked around with this message at 08:20 on May 28, 2014

Dominoes
Sep 20, 2007

supermikhail posted:

One (rather complicated) way I can think of is have the login button be part of a form with a hidden field for the current url (found like this http://stackoverflow.com/questions/2882490/get-the-current-url-within-a-django-template). This goes to your GET login view which passes the hidden field on to the login page, from which you POST it back to the login view, and voila. But maybe I'm overthinking it.

Edit: I'm sure you can have log in with a link and pass the current url as an argument, too.

Nimrod posted:

request.META['HTTP_REFERER'] ?

Thermopyle posted:

FWIW, I use django-allauth on all my projects requiring registration and login stuff, and when you get redirect to a login page it appends the url to redirect to on login to the url.

So, like if you visit www.example.com/dashboard/ it will redirect you to www.example.com/login/?next=/dashboard/ and then, on login redirects back to www.example.com/dashboard/.

It's been awhile since I configured any of this on any project, so I can't recall if I had to do anything specific to set that up or not...

ufarn posted:

Here is what project of mine looks like:

In login.html:

HTML code:
<input type="submit" value="Submit" />
<input type="hidden" value="{{ next }}" name="next" />
In views.py (I'm currently using django-registration):
Python code:
from django.contrib.auth.views import login

# ...

def custom_login(request, **kwargs):
    if request.user.is_authenticated():
        return HttpResponseRedirect(reverse('myproject.views.home', args=()))
    else:
        return login(request, **kwargs)
Maybe you're not passing the `next` token in your kwargs, or you're forgetting to send it via the HTML form in the first place.

Thank you very much. I used Nimrod's solution of request.META['HTTP_REFERER']:
Python code:
referer = request.META['HTTP_REFERER']
# The last part of the referring URL corresponds to the view in urls.py.
origin = re.search(r'/[a-z]*/$', referer).group()
return HttpResponseRedirect(origin)

Dominoes fucked around with this message at 12:35 on May 31, 2014

Dominoes
Sep 20, 2007

I'm getting duplicates in queries involving many-to-one relationships.

One airfield can have many runways. The query below is returning the Airfield object for each runway that meets the length criteria. Ie if I have an Airfield that has three Runways greater than min_rwy_len, the airfield is in the result 3 times.

Python code:
passed_rwy_len = Airfield.objects.filter(runway__length__gte=min_rwy_len)
Is there a way to avoid this? Can I dedupe it? sort() doesn't work.


edit: running distinct() at the end of the query fixes this.

Dominoes fucked around with this message at 06:33 on Sep 8, 2014

Dominoes
Sep 20, 2007

I have a basic form view. It's redirecting to the top-level url, (For the test server, http://127.0.0.1:8000/) and therefor returning a Page Not Found error instead of staying on the same url and displaying the result, as it should.

Python code:
def view(request):
    if request.method == 'POST':
        form = DivertForm(request.POST)
        if not form.is_valid():
            return HttpResponse("<h2>Something went wrong - try again.</h2>")

        flight_path = form.cleaned_data['flight_path']
        ...

        divert_fields = diverts_code.find_diverts(flight_path, max_dist, min_rwy_len)

        context = {
            'divert_fields': divert_fields
        }
        return render(request, 'diverts/diverts_results.html', context)

    else:
        form = DivertForm()
        context = {'form': form}
        print('bottom form')

        return render(request, 'diverts/index.html', context)
Nothing in the 'if request.method == 'POST':' block is being executed on form submission. The bottom 'else:' block code gets executed properly when loading the page before submitting.

Dominoes
Sep 20, 2007

Thanks - good call. The problem was in the action field of my HTML template.

Dominoes fucked around with this message at 23:37 on Sep 9, 2014

Dominoes
Sep 20, 2007

Is there a way to query for anything, like a wildcard? Improvised method below, looking for something more explicit.

Python code:
if paved_only:
    surface = Q(runway__surface='ASPH') | Q(runway__surface='CONC'))
else:
    surface = ~Q(runway__surface='Unicorn poop')

Airfield.objects.filter(surface, runway__length__gte=8000)

Dominoes fucked around with this message at 13:25 on Sep 12, 2014

Dominoes
Sep 20, 2007

I want to be able to allow any surface, if paved_only is False.

Dominoes
Sep 20, 2007

surface might have a value. Repeating the filter statement for each if/or doesn't make sense if there are multiple filter fields; ie the solution I posted, while convoluted, is cleaner. I'm looking for something like query_parameter=anything

Dominoes
Sep 20, 2007

fletcher posted:

I want to store a latitude & longitude in a Django model and display the points on a Google Maps widget. My database is PostgreSQL. Should I just use floats? django-geoposition? GeoDjango?
Floats; one for lat, one for lon. No minutes/seconds, just degrees with decimals. Let me know if you have specific questions on drawing on Gmaps; I built a somewhat specialized Django/JS module.

Dominoes fucked around with this message at 12:01 on Oct 29, 2014

Dominoes
Sep 20, 2007

I'm setting up a simple database of books, and am looking for advice on database design.

I'm leaning towards having a separate entry with a unique ISBN, with a field that links each entry to other entries that are of the same work. How would I set up this relationship? It's somewhat like a ManyToMany, but with items of the same table.

An alternative setup would be to have one entry for each work, with different ISBNs for each edition or w/e causes works to be fragmented. Or two tables, one with Works and a second for ISBNs, and a ManyToOne relationship of ISBNs to Works. How would y'all set this up, and if I went with my first option, how do you actually code a ManyToMany with the same table?

Dominoes
Sep 20, 2007

Mata posted:

If each work has one or more ISBNs, I would suggest dividing them up between two tables, to minimize data redundancy. If you want to go with the first option, you still need a second table to model the relationships within the first table. I did a similar thing where I want users to have relationships with other users (e.g. you can block users or add them as friends) for which I created a "Relationship" table where each row describes the relationship between two users:

code:
class ClientUser(models.Model): 
   relationships = models.ManyToManyField('self', symmetrical=False, through='Relationship')

class Relationship(models.Model):
    from_clientuser = models.ForeignKey(ClientUser, related_name='from_clientuser')
    to_clientuser = models.ForeignKey(ClientUser, related_name='to_clientuser')
    status = models.IntegerField(choices=RELATIONSHIP_STATUSES)
That looks like a good way to solve this.

Here's what the two-table approach I described looks like:
Python code:
class Work(models.Model):
    title = models.CharField(max_length=255)
    author = models.CharField(max_length=255)


class ISBN(models.Model):
    isbn10 = models.TextField(unique=True)
    isbn13 = models.TextField(unique=True)
    publication_date = models.DateField()
    work = models.ForeignKey(Work)

Dominoes fucked around with this message at 15:47 on Oct 9, 2015

Dominoes
Sep 20, 2007

Checkout enumfields

I'm looking for advice on querying a Django Postgres database based on string similarity. One approach would be to query all objects in the database, then use the builtin difflib library on the results, but that would be slower than a natural query. Is there any way to do this using a query?

Dominoes fucked around with this message at 13:30 on Oct 22, 2015

Dominoes
Sep 20, 2007

fletcher posted:

Probably have to use some raw sql to get to the more advanced functions, I would imagine: http://www.postgresql.org/docs/9.5/static/fuzzystrmatch.html
Thank you.

For model fields, what's the difference between help_text and label?

Dominoes
Sep 20, 2007

porksmash posted:

Label is the name of the field, help text is generally more verbose on how to use the field. Like for a create password field, the label would be 'New Password' and the help text might be '8 characters or more, requires at least one number and special character'
Thanks

Dominoes
Sep 20, 2007

I'm looking for help with forms. It's easy to find instructions on making HTML/js forms, and using Bootstrap etc to make them look nice. I'm having trouble integrating this with Django . I'm using Crispy forms, and am trying to make a search bar with a clickable submit button with a mag-glass icon. Here's the code I'm using to make what I describe, but without the button being clickable; submit works only with enter button:

Python code:
    def __init__(self, *args, **kwargs):
        super(TripForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.layout = Layout(
            AppendedText('cities', '<i class="fa fa-search"></i>',
                         placeholder='search for [s]stuff[/s]'),
        )
How can I turn appended text icon into a submit button? I could use this example code on Bootstrap's site to make it call a JS function, but I don't know how to integrate that with Django.

Dominoes fucked around with this message at 21:48 on Dec 1, 2015

Dominoes
Sep 20, 2007

Thanks. Do you know if there's a way to make FieldWithButtons work with the icon (seems to only work with text), and placeholder text? The documentation only references it via one example, and with only the button text and name.

Dominoes
Sep 20, 2007

I'm curious too. I've been making a file called private.py that I put on gitignore. I use an if/else statement based on a server environment var in settings.py to prevent an import error when deployed. It seems like an awkward solution.

Dominoes
Sep 20, 2007

Connecting to a Heroku database locally. Or storing API keys.

Dominoes
Sep 20, 2007

Does anyone know how to make date / time / datetime widgets work in Django forms? I've found nothing but broken addons and ancient admin hacks.

Dominoes
Sep 20, 2007

Hey dudes: How do I access files (like a pdf or w/e) from code in a django app on Heroku? I've been pulling my hair out regarding this!!


-Works locally
-When I clone, the file's there, so it is getting pushed to Heroku
-Static files like Javascript and css work fine; dj-static configured.


I've tried dumping the file I need the code to access everywhere; main proj and app static, staticfiles directories, the main proj directory, the main app directory. Nothing, and no leads on troubleshooting since it's only reproducible when deployed. You should see my commit log! I get a standard FileNotFound Error.

Based on my weak understanding of serving static files, this is one one in the trad sense; it's accessed by the code, not the user.


edit: Got it working, after dropping the file in about ~10 locations simultaneously; no idea which one was correct!

Dominoes fucked around with this message at 11:50 on Feb 6, 2017

Dominoes
Sep 20, 2007

Hey dudes. Looking to send data from javascript to Django, concluding with a page refresh. I've been sending data like this:

JavaScript code:
    $("#ScheduleTraining").click(function () {
        $.ajax({
            method: "POST",
            headers: {"X-CSRFToken": getCookie('csrftoken')},
            url: "/ground-training/",
            data: {type: 'scheduled', selected: findSelected(), date: $('#dateVal').val()}
        })
I can then parse this (super-mangled data) with python in my view, but can't get the page to refresh after, which I need to do since these are database updates. I think AJAX is the wrong tool, but googling always points me to it. Haven't found an obvious way to make the page refresh, even though the view points to the same info after handling the post it would to load a fresh page.

edit: Looks like I can get a better result by modifying elements with Jquery to look like how they would after a page refresh; should be more responsive, although with more/clumsier code.

Dominoes fucked around with this message at 00:42 on Feb 25, 2017

Dominoes
Sep 20, 2007

Data Graham posted:

Add a success: callback function in your ajax call, and do a document.location.reload() in it.
Thx homes.

Dominoes
Sep 20, 2007

-

Dominoes fucked around with this message at 21:56 on Mar 1, 2017

Dominoes
Sep 20, 2007

Thermopyle posted:

edit: this post made more sense in relation to the previous post that was removed! I'll leave it as commiseration.
My workflow's like this:

-Use migrations until they break. Adding tables and fields is usually fine; modifications are a gamble.
-If there's no real data in the db, ie it's early in the dev process, wipe the DB and migrations; start fresh. Always fixes it.
-If there's real data saved, update the DB with SQL from a console for the app that's broken (Ie other apps might still work with migrations). Migrations will never work again for that app, but your website and database will work.

Is there a way to unbreak migrations, once they're broken?

Dominoes fucked around with this message at 18:08 on Mar 2, 2017

Dominoes
Sep 20, 2007

And then you get errors because django can't find so and so field because DUH YOU DELETED IT!


Root cause is probably I'm not making proper migration files, and relying too much on makemigrations. I feel like this is a problem that could be solved by Django telling you "Whoah I'm not sure what you're doing, please make a migration file", rather than irreversibly* breaking.

* Irreversibly meaning like when a car's totaled; not that it's broken beyond repair, but when it's easier to back everything up and start fresh, or do everything in SQL, than troubleshoot. I feel like I'm not out of line saying this is an unusually counterintuitive process for Python.

Tell me if I'm off-base here: makemigrations is how you change your database, after editing, adding, or removing model fields. Unless your modification is unsuitable for makemigrations... And there's no official guidance about what unsuitable means, and django doesn't warn you, or provide an undo option if it doesn't work. So yes, I expect them to break. And I expect there's room for improvement, ie this will be fixed within a few years.

Dominoes fucked around with this message at 23:14 on Mar 2, 2017

Dominoes
Sep 20, 2007

Hey dudes. Do y'all use Django's forms, or make your own in HTML/JS?

Django recommends you use their forms when able due to validation etc, but it seems like if you're doing something other than a very basic form that matches a model directly, they're a PITA. Ie: Want a date/time picker widget? Dynamic behaviour? A customisable layout? Doable, but a pain.

Dominoes fucked around with this message at 18:11 on Apr 28, 2017

Dominoes
Sep 20, 2007

That sounds familiar. It's been a different reason that drives it each time. For example, today I switched from a Django model form to an HTML form submitted via AJAX since I wanted date/time widgets, a checkbox that automatically sets the time to a certain thing and disables the inputs, and customized dropdowns. Another case was having items be read-only on the page, but have a button that turns them into dropdowns and input fields in an 'edit' mode. I suppose this all depends on the use case.

These things could be handled by Django, but AFAIK, the API's not there. (It wouldn't surprise me if we get elegant input-widget handling in a future release; it seems so obvious.)

Dominoes
Sep 20, 2007

Hey dudes, I'm looking for info on what Django Rest framework is used for. Context: I was reading about using Django and React together (AFAICT it's straightforward; just put a <div> in your template that ReactDOM's render func points to), and almost all results pointed to Django Rest Framework. From skimming their site, it seems like it's supposed to clean up messes when passing AJAX data to/from the front end?

ie avoid awkward deserializing code like this?
Python code:
    data = dict(request.POST)

    date = saturn.from_iso(data['date'][0])
    lines = json.loads(data['lines'][0])
    sims = json.loads(data['sims'][0])
    duties = json.loads(data['duties'][0])
    meetings = json.loads(data['meetings'][0])

    data_py = {'date': date, 'lines': lines, 'sims': sims, 'duties': duties, 'meetings': meetings}

So you could call a serializer from DRF to just import the POST data as a dict? And maybe more functionality than django.http's JsonResponse for sending serialized data?

Dominoes
Sep 20, 2007

I'm looking for wisdom on encrypting DB fields. I stumbled acrossthis module called Django extensions, which offers an EncryptedCharField doing what I'd like; however, it requires on a package called KeyCzar, which no longer works. Does anyone know how to handle encrypting DB fields with Django?

Dominoes
Sep 20, 2007

I'm working on a scheduling webapp for a government agency as part of a quasi-official function at work. I'd just like to encrypt first/last and organization names. I'm forcing an HTTPS connection, and it seems like the Heroku/AmazonAWS database setup is fairly secure. This is unknown territory, and is a gray area. ie software like this is traditionally hosted locally or semi-locally, takes years to make, costs millions of dollars, sucks, and the devs don't know what users want. The info's not particularly sensitive, but the names are considered PII, especially when associated with the org. Do you have any recommendations, encryption or otherwise?

Dominoes fucked around with this message at 20:51 on Jun 13, 2017

Dominoes
Sep 20, 2007

Thermopyle posted:

Its of note, that on production tiers Heroku/Amazon already encrypts the data volumes including your database...so what you're wanting to do with a single field is basically already done for your whole db. A compromise would have to be specific enough to catch the data on the fly or getting access to Amazon's key storage.

...


Maybe my rambling will help you ask better questions of whoever you need to ask about what your actual requirements or responsibilities actually are.
Thank you v much for the detailed explanation. It sounds like this may be the heart of your answer. I'd mainly like to be able to answer questions from higher-ups when they ask about security/PII. So far, I've answered by saying the server's secure, and the connection is encrypted, which seemed to be acceptable thus far.

Dominoes
Sep 20, 2007

Is there a template system that works for django that lets you wright full-up python in the Templates? I never liked how restricted Django templates are: simple things work, but anything else (calling functions, methods etc) requires setting up intermediate data structures or custom template tags in the Python code. React's JSX provides an alternative where you write full-up JS with HTML tags; it has none of the template system's limitations. For pages that don't require interaction, it'd be nice to have something as powerful as JSX but in Python; is this possible?

Dominoes fucked around with this message at 20:55 on Aug 12, 2017

Dominoes
Sep 20, 2007

Thanks. It feels awkward for me; I made many attempts to get used to this style, but never succeeded. I don't like bouncing back and forth between python code and templates when setting up how my page should look. Ie I may have something written in my template, but want to change something later that requires a function call; have to rewrite the whole thing in Python, then find a way to wrap it in a template-friendly dict etc. Or guess where I put the logic when looking at older code. I also don't like creating throw-away data structures for templates; ie I may have a consistent data structure or way of passing around info that's consistent throughout my program, that is incompatible with rigid templates.

I suspect this is similar to the front-end philosophy difference between React's JSX and Angular's templates; ie some people can't stand how JSX mixes program logic with UI.

Dominoes fucked around with this message at 22:48 on Aug 12, 2017

Dominoes
Sep 20, 2007

Thermopyle posted:

Split code into these modules by thinking in commands.

There's two types of queries you're probably concerned about. Presentational queries and business logic queries. Often, custom tags and filters work for presentational queries.

Python code:
@register.filter
def user_in_esperanto(user):
    return translate_api.translate(user.name)

Data Graham posted:

Something that I've only fairly recently come to make friends with is the notion of putting your derived data into @property methods in your models.
These cut to the core of what doesn't feel natural to me: The work done to make your data accessible to the view is performed in a preparatory way (special methods/properties in your models, specialized @register.filters, pre-computed data structures). To me, it makes more sense to keep the Python code (what you refer to as business logic?) generic, and write the view-specific code during the view itself; antithetical to the two-scoops snipped Therm quoted.

Dominoes
Sep 20, 2007

Thermopyle posted:

I mean, if, as part of your view, you have code that does x, y, and z, how are you going to use that code elsewhere? What if you want a view later that wants x, y, and z along with other stuff?
I'm referring to code that's made specifically to accommodate Django's rigid templates; ie code that you don't need anywhere else. (register.filters, pre-computed data structures, modifications to the models etc)

Dominoes
Sep 20, 2007

Hey dudes. Looking for wisdom on what URL to query for Django Rest tied to a Create-React-App setup.

Setup: standard, unejected CRA folder inside Django folder. Django's static and temple settings point to frontend/build. Dummy package.json in main folder that tells Heroku which node version and packages to install, then points to the real one in frontend, which commands a build on install.

Can use locally from http://localhost:8000 for Django; eg using the built frontend, admin page etc, or http://localhost:3000 for the hot-loading CRA server.

How I'm making the API calls:
JavaScript code:
axios.post(
    'http://localhost/api/search',
    {} // data
).then(//...
When loading on Heroku or locally it... queries my own local dev server! How do I set this up properly? Ie something like.

JavaScript code:
let BASE_URL = on_heroku? 'https://myapp.herokuapp.com' : 'http://localhost.com:8000'
Is this an appropriate solution, and if so, how do I let the frontend determine if we're on heroku? Tutorials online demonstrate calls to process.env, or 'http://0.0.0.0', which I can't get working.

edit: Trying something like this:
JavaScript code:
const HOSTNAME = window && window.location && window.location.hostname

let ON_HEROKU = false
if (HOSTNAME === 'myapp.herokuapp.com' || HOSTNAME === 'mydomain.org') {
    ON_HEROKU = true
}

export const BASE_URL = ON_HEROKU ? 'https://readseek.herokuapp.com/api/' : 'localhost:8000/api/'

Dominoes fucked around with this message at 13:13 on Apr 14, 2018

Adbot
ADBOT LOVES YOU

Dominoes
Sep 20, 2007

Hey dudes. Looking for wisdom on creating a non-saved subclass in a model. Eg I don't want to save a separate entry; just using it to reduce code.

Python code:
class Address(models.Model):
    country = models.CharField(max_length=3)  # ISO 3166-1 alpha-3
    address1 = models.CharField(max_length=150)
    address2 = models.CharField(max_length=150)
    town = models.CharField(max_length=100)
    postal = models.IntegerField()
    phone = models.IntegerField()


class Order(models.Model):
    datetime = models.DateTimeField()

    shipping_address = models.ForeignKey(Address, on_delete=CASCADE)
    billing_address = models.ForeignKey(Address, on_delete=CASCADE)
Ie: I don't want to save Address entries to the DB; I just don't want to repeat the code, and want their data to be in the Order table, self-contained. OneToOneFields ?

Eg without the DB tie-in:

Python code:
@dataclass
class Address:
    country: str
    address1: str
    address2: str
    #...

@dataclass
class Order:
    shipping_address: Address
    billing_address: Address

Dominoes fucked around with this message at 07:45 on Aug 3, 2018

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply